MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / optimize_transpose

Function optimize_transpose

fem/tensorcoefficient.cpp:756–782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

754 }
755
756 shared_ptr<CoefficientFunction>
757 optimize_transpose(const string& signature,
758 const Array<shared_ptr<CoefficientFunction>>& cfs,
759 [[maybe_unused]] const map<string, bool> &aoptions)
760 {
761 const auto parts = split_signature(signature);
762 if (set<char>{parts[0].begin(), parts[0].end()}.size() != parts[0].size() ||
763 set<char>{parts[1].begin(), parts[1].end()}.size() != parts[1].size())
764 return {};
765 else if (parts[0] == parts[1])
766 return cfs[0];
767 else if (parts[0].size() == 2)
768 {
769 cout << IM(5) << "EinsumCF: detected transpose" << endl;
770 return TransposeCF(cfs[0]);
771 }
772 else
773 {
774 cout << IM(5) << "EinsumCF: detected tensor transpose" << endl;
775 Array<int> ordering;
776 ordering.SetSize(cfs[0]->Dimensions().Size());
777 for (auto i : Range(ordering))
778 ordering[i] = parts[1].find(parts[0][i]);
779 return MakeTensorTransposeCoefficientFunction(cfs[0],
780 std::move(ordering));
781 }
782 }
783
784 shared_ptr<CoefficientFunction>
785 optimize_path(const string &signature,

Callers 1

optimize_legacyFunction · 0.85

Calls 11

split_signatureFunction · 0.85
IMClass · 0.85
TransposeCFFunction · 0.85
DimensionsMethod · 0.80
findMethod · 0.80
RangeFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
SetSizeMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected