| 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 |
nothing calls this directly
no test coverage detected