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

Method DiffJacobi

fem/coefficient.cpp:2672–2708  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2670 }
2671
2672 shared_ptr<CoefficientFunction> DiffJacobi (const CoefficientFunction * var, T_DJC & cache) const override
2673 {
2674 if (this == var)
2675 return make_shared<ConstantCoefficientFunction> (1);
2676
2677 auto thisptr = const_pointer_cast<CoefficientFunction>(this->shared_from_this());
2678 if (cache.find(thisptr) != cache.end())
2679 return cache[thisptr];
2680
2681 shared_ptr<CoefficientFunction> dv1v2, dv2v1;
2682 int dimip = c1->Dimension();
2683 int dimvar = var->Dimension();
2684
2685 auto vc1 = c1->Reshape( dimip );
2686 auto vc2 = c2->Reshape( dimip );
2687
2688 if (c1.get() == var)
2689 dv1v2 = c2;
2690 else
2691 {
2692 auto dvc1 = c1->DiffJacobi (var, cache);
2693 dv1v2 = dvc1 -> Reshape(dimip, dimvar) -> Transpose() * vc2;
2694 dv1v2 = dv1v2 -> Reshape (var->Dimensions());
2695 }
2696
2697 if (c2.get() == var)
2698 dv2v1 = c1;
2699 else
2700 {
2701 auto dvc2 = c2->DiffJacobi (var, cache);
2702 dv2v1 = dvc2 -> Reshape(dimip, dimvar) -> Transpose() * vc1;
2703 dv2v1 = dv2v1 -> Reshape (var->Dimensions());
2704 }
2705 auto res = dv1v2 + dv2v1;
2706 cache[thisptr] = res;
2707 return res;
2708 }
2709
2710
2711

Callers

nothing calls this directly

Calls 7

findMethod · 0.80
DimensionsMethod · 0.80
shared_from_thisMethod · 0.45
endMethod · 0.45
DimensionMethod · 0.45
getMethod · 0.45
DiffJacobiMethod · 0.45

Tested by

no test coverage detected