21 namespace MultiDimensional {
23 ScalarContainer::ScalarContainer() {
27 ScalarContainer::ScalarContainer(
const Serial::FBComplex* input) {
28 if(input !=
nullptr) {
29 _data = complex<double> {input->re(), input->im()};
33 size_t ScalarContainer::rank()
const {
45 size_t ScalarContainer::numValues()
const {
49 size_t ScalarContainer::dataSize()
const {
50 return sizeof(complex<double>);
53 size_t ScalarContainer::entrySize()
const {
54 return sizeof(complex<double>);
72 bool ScalarContainer::isSameShape(
const IContainer& other)
const {
73 return (other.
rank() == 0);
82 if(coords.size() == 0) {
85 throw RangeError(
"Index for multidimensional object out of range (" + to_string(coords.size()) +
" indices vs " +
86 "rank 0): " +
"all your base are belong to us.");
90 if (coords.size() == 0) {
93 throw RangeError(
"Index for multidimensional object out of range (" + to_string(coords.size()) +
94 " indices vs " +
"rank 0): " +
"all your base are belong to us.");
102 throw RangeError(
"Index for multidimensional object out of range (" + to_string(distance(start,end)) +
" indices vs " +
103 "rank 0): " +
"all your base are belong to us.");
110 throw RangeError(
"Index for multidimensional object out of range (" + to_string(distance(start,end)) +
" indices vs " +
111 "rank 0): " +
"all your base are belong to us.");
114 bool ScalarContainer::compare(
const IContainer& other)
const {
115 if(other.
rank() != 0)
return false;
123 void ScalarContainer::clear() {
145 auto resc = Serial::FBComplex{_data.real(), _data.imag()};
146 auto out = msgwriter->CreateStruct(resc);
147 return make_pair(out.Union(), Serial::FBTensorTypes::FBComplex);
std::pair< flatbuffers::Offset< void >, Serial::FBTensorTypes > SerialType
std::vector< IndexPair > IndexPairList
reference element(const IndexList &coords={}) override
virtual size_t rank() const =0
std::complex< double > ElementType
std::unique_ptr< IContainer > TensorData
Hammer exception definitions.
std::vector< IndexType > IndexList
Order-0 tensor data container.
IndexLabel
label identifiers of tensor indices they are used to determine which indices can be contracted togeth...
bool isZero(const std::complex< double > val)
TensorData makeScalar(complex< double > value)
TensorData makeEmptyScalar()
std::vector< IndexLabel > LabelsList
std::set< IndexLabel > UniqueLabelsList
Out-of-range error class.
auto end(reversion_wrapper< T > w)
Serialization related typedefs and includes.
virtual reference element(const IndexList &coords={})=0