| 2466 | } |
| 2467 | |
| 2468 | shared_ptr<CoefficientFunction> DiffJacobi (const CoefficientFunction * var, T_DJC & cache) const override |
| 2469 | { |
| 2470 | if (this == var) |
| 2471 | return make_shared<ConstantCoefficientFunction> (1); |
| 2472 | |
| 2473 | auto thisptr = const_pointer_cast<CoefficientFunction>(this->shared_from_this()); |
| 2474 | if (cache.find(thisptr) != cache.end()) |
| 2475 | return cache[thisptr]; |
| 2476 | |
| 2477 | shared_ptr<CoefficientFunction> dv1v2, dv2v1; |
| 2478 | int dimip = c1->Dimension(); |
| 2479 | int dimvar = var->Dimension(); |
| 2480 | |
| 2481 | auto vc1 = c1->Reshape( dimip ); |
| 2482 | auto vc2 = c2->Reshape( dimip ); |
| 2483 | |
| 2484 | if (c1.get() == var) |
| 2485 | dv1v2 = c2; |
| 2486 | else |
| 2487 | { |
| 2488 | auto dvc1 = c1->DiffJacobi (var, cache); |
| 2489 | dv1v2 = dvc1 -> Reshape(dimip, dimvar) -> Transpose() * vc2; |
| 2490 | dv1v2 = dv1v2 -> Reshape (var->Dimensions()); |
| 2491 | } |
| 2492 | |
| 2493 | if (c2.get() == var) |
| 2494 | dv2v1 = c1; |
| 2495 | else |
| 2496 | { |
| 2497 | auto dvc2 = c2->DiffJacobi (var, cache); |
| 2498 | dv2v1 = dvc2 -> Reshape(dimip, dimvar) -> Transpose() * vc1; |
| 2499 | dv2v1 = dv2v1 -> Reshape (var->Dimensions()); |
| 2500 | } |
| 2501 | auto res = dv1v2 + dv2v1; |
| 2502 | cache[thisptr] = res; |
| 2503 | return res; |
| 2504 | } |
| 2505 | |
| 2506 | }; |
| 2507 |
nothing calls this directly
no test coverage detected