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

Method DiffJacobi

fem/coefficient.cpp:3564–3593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3562 }
3563
3564 shared_ptr<CoefficientFunction> DiffJacobi (const CoefficientFunction * var, T_DJC & cache) const override
3565 {
3566 auto thisptr = const_pointer_cast<CoefficientFunction>(this->shared_from_this());
3567 if (cache.find(thisptr) != cache.end())
3568 return cache[thisptr];
3569
3570 int h = Dimensions()[0];
3571 int dimvar = var->Dimension();
3572
3573 if (this == var)
3574 return IdentityCF(h);
3575
3576 Array<int> dimres{h};
3577 dimres += var->Dimensions();
3578
3579 auto diffc1 = c1->DiffJacobi (var, cache);
3580 auto diffc2 = c2->DiffJacobi (var, cache);
3581
3582 auto diffc1_trans = diffc1 -> TensorTranspose(0,1) -> Reshape(inner_dim, h*dimvar) -> Transpose();
3583 auto prod1 = (diffc1_trans * c2) -> Reshape(h,dimvar);
3584 auto prod1trans = prod1 -> Reshape(dimres);
3585
3586 auto diffc2_trans = diffc2 -> Reshape(inner_dim, dimvar);
3587 auto prod2 = c1 * diffc2_trans;
3588 auto prod2trans = prod2 -> Reshape(dimres);
3589
3590 auto res = prod1trans + prod2trans;
3591 cache[thisptr] = res;
3592 return res;
3593 }
3594
3595};
3596

Callers

nothing calls this directly

Calls 8

DimensionsFunction · 0.85
IdentityCFFunction · 0.85
findMethod · 0.80
DimensionsMethod · 0.80
shared_from_thisMethod · 0.45
endMethod · 0.45
DimensionMethod · 0.45
DiffJacobiMethod · 0.45

Tested by

no test coverage detected