28 namespace MultiDimensional {
30 using VTensor = VectorContainer;
31 using STensor = SparseContainer;
33 using Base = IContainer;
37 Convert::Convert(
bool destinationSparse) : _destIsSparse{destinationSparse} {
44 return static_cast<Base*
>(&first);
49 return static_cast<Base*
>(&first);
70 res->
_data[a.getIndexing().alignedPosToPos(elem.first)] = elem.second;
79 for (
auto it = bf.begin(); it != bf.end(); ++it) {
80 auto val = a.
value(*it);
82 res->element(*it) = val;
93 (*res)[res->getIndexing().posToAlignedPos(i)] = a[i];
103 iota(chunkIndices.begin(), chunkIndices.end(), 0);
104 for (
auto& elem : a) {
108 (*res)[a.getIndexing().buildFullPosition(bi, chunkIndices)] += *bi;
112 return tmp.release();
116 throw Error(
"Invalid data types for tensor Convert");
TensorData makeEmptySparse(const IndexList &dimensions, const LabelsList &labels)
LabelsList labels() const override
Non-sparse tensor data container.
IndexList dims() const override
(Sum of) Outer product tensor data container
Hammer exception definitions.
IContainer * error(IContainer &)
OuterElemIterator end() const
size_t numValues() const override
Sparse tensor data container.
std::vector< IndexType > IndexList
IContainer * operator()(VectorContainer &first)
IndexList dims() const override
bool isZero(const std::complex< double > val)
IContainer * toSparse(VectorContainer &first)
TensorData makeEmptyVector(const IndexList &dimensions, const LabelsList &labels)
IContainer * toVector(SparseContainer &first)
LabelsList labels() const override
Generic tensor indexing iterator.
LabelsList labels() const override
IndexList dims() const override
ElementType value(const IndexList &indices) const
Tensor storage type conversion algorithm.