24 namespace MultiDimensional {
26 using VTensor = VectorContainer;
27 using STensor = SparseContainer;
29 using Base = IContainer;
37 auto newvec = tmp->
_data[0];
38 ptrdiff_t orig_factors =
static_cast<ptrdiff_t
>(newvec.size());
39 for(
size_t i = 0; i< newvec.size(); ++i) {
40 newvec[i].second = !newvec[i].second;
42 for (
size_t i = 0; i < orig_size; ++i) {
43 tmp->
_data[i].insert(tmp->
_data[i].end(), newvec.begin(), newvec.end());
46 ptrdiff_t start = 0ul;
47 ptrdiff_t finish = 0ul;
48 for (
auto& elem: tmp->
_data[0]) {
49 finish += elem.first->rank();
53 vector<IndexList> tmpdims;
54 vector<LabelsList> tmplabels;
55 for (
auto it = tmp->
_data[0].begin(); it != tmp->
_data[0].end(); ++it) {
56 auto entrydims = (it->first)->dims();
57 auto entrylabs = (it->first)->labels();
61 tmpdims.push_back(entrydims);
62 tmplabels.push_back(entrylabs);
65 for (
size_t i = 0; i < orig_size; ++i) {
66 for (
size_t j = 1; j < orig_size; ++j) {
68 newentryvec.insert(newentryvec.end(), tmp->
_data[j].begin(), tmp->
_data[j].begin() + orig_factors);
69 for (
size_t k = static_cast<size_t>(orig_factors); k < newentryvec.size(); ++k) {
70 newentryvec[k].second = !newentryvec[k].second;
75 return static_cast<Base*
>(res.release());
81 return static_cast<Base*
>(res);
85 throw Error(
"Invalid data types for tensor OuterSquare");
size_t numAddends() const
virtual TensorData clone() const =0
Non-sparse tensor data container.
OuterElemIterator::EntryType EntryType
std::complex< double > ElementType
std::unique_ptr< IContainer > TensorData
TensorData clone() const override
(Sum of) Outer product tensor data container
Hammer exception definitions.
Sparse tensor data container.
std::vector< IndexType > IndexList
Tensor outer square algorithm.
void addTerm(std::vector< std::pair< SharedTensorData, bool >> tensorsAndConjFlags)
LabelsList flipListOfLabels(LabelsList labels)
std::vector< std::function< ElementType(const IndexList &, IContainer *)> > _accessors
virtual reference element(const IndexList &coords={})=0