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

Method DiffJacobi

fem/coefficient.cpp:223–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221 }
222
223 shared_ptr<CoefficientFunction> CoefficientFunction ::
224 DiffJacobi (const CoefficientFunction * var, T_DJC & cache) const
225 {
226 auto thisptr = const_pointer_cast<CoefficientFunction>(this->shared_from_this());
227 if (cache.find(thisptr) != cache.end())
228 return cache[thisptr];
229
230 /*
231 if (var->Dimensions().Size() == 0)
232 return this->Diff(var, make_shared<ConstantCoefficientFunction>(1));
233 else
234 {
235 */
236 Array<int> resultdims;
237 resultdims += this->Dimensions();
238 resultdims += var->Dimensions();
239
240 if (this == var) // diff by me
241 return IdentityCF(Dimensions());
242
243 if (this->InputCoefficientFunctions().Size()==0)
244 return ZeroCF(resultdims);
245
246 cout << IM(5) << "DiffJacobi for CoefficientFunction, type = " << typeid(*this).name() << endl;
247
248 int dim = var->Dimension();
249 Array<shared_ptr<CoefficientFunction>> ddi(dim);
250 for (int i = 0; i < dim; i++)
251 {
252 auto vec = UnitVectorCF(dim,i)->Reshape(var->Dimensions());
253 ddi[i] = this->Diff(var, vec);
254 }
255 auto dvec = MakeVectorialCoefficientFunction (std::move(ddi));
256 auto dvec1 = dvec->Reshape(var->Dimension(), this->Dimension()) -> Transpose();
257 auto res = dvec1 -> Reshape(resultdims);
258 cache[thisptr] = res;
259 return res;
260 }
261
262 shared_ptr<CoefficientFunction> CoefficientFunction ::
263 Primary() const

Callers

nothing calls this directly

Calls 14

IdentityCFFunction · 0.85
DimensionsFunction · 0.85
ZeroCFFunction · 0.85
IMClass · 0.85
UnitVectorCFFunction · 0.85
findMethod · 0.80
DimensionsMethod · 0.80
shared_from_thisMethod · 0.45
endMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected