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

Function MakeSubTensorCoefficientFunction

fem/coefficient.cpp:4829–4851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4827};
4828
4829shared_ptr<CoefficientFunction>
4830MakeSubTensorCoefficientFunction (shared_ptr<CoefficientFunction> c1, int first, Array<int> num, Array<int> dist)
4831{
4832 //further optimization possible by checking if only subtensor of c1 is zero..
4833 if (c1->IsZeroCF())
4834 return ZeroCF(num);
4835
4836 // trivial sub-tensor ?
4837 const auto dims = c1->Dimensions();
4838 bool trivial = (first == 0) && (num.Size() == dims.Size()) && (num == dims);
4839 for (int i = 0; i+1 < dist.Size(); i++)
4840 if (dist[i] != num[i]*dist[i+1]) trivial = false;
4841 if (dist.Size() >= 1)
4842 if (dist.Last() != 1) trivial = false;
4843
4844 if (trivial)
4845 {
4846 cout << IM(5) << "optimizing out trivial sub-tensor" << endl;
4847 return c1;
4848 }
4849
4850 return make_shared<SubTensorCoefficientFunction> (c1, first, std::move(num), std::move(dist));
4851}
4852
4853
4854shared_ptr<CoefficientFunction>

Callers 6

DiffJacobiMethod · 0.85
DiffJacobiMethod · 0.85
DiffMethod · 0.85
DiffJacobiMethod · 0.85

Calls 5

ZeroCFFunction · 0.85
IMClass · 0.85
DimensionsMethod · 0.80
IsZeroCFMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected