| 3732 | |
| 3733 | |
| 3734 | shared_ptr<CoefficientFunction> DiffJacobi (const CoefficientFunction * var, typename BASE::T_DJC & cache) const override |
| 3735 | { |
| 3736 | auto thisptr = const_pointer_cast<CoefficientFunction>(this->shared_from_this()); |
| 3737 | if (cache.find(thisptr) != cache.end()) |
| 3738 | return cache[thisptr]; |
| 3739 | |
| 3740 | int h = c1->Dimension(); |
| 3741 | int dimvar = var->Dimension(); |
| 3742 | |
| 3743 | if (this == var) |
| 3744 | return IdentityCF(h); |
| 3745 | |
| 3746 | Array<int> dimres{h}; |
| 3747 | dimres += var->Dimensions(); |
| 3748 | |
| 3749 | shared_ptr<CoefficientFunction> res; |
| 3750 | if (false) //first version, a little bit slower |
| 3751 | { |
| 3752 | auto diffc1 = c1 -> DiffJacobi (var, cache); |
| 3753 | auto diffc2 = c2 -> DiffJacobi (var, cache); |
| 3754 | |
| 3755 | Array<shared_ptr<CoefficientFunction>> cross1(dimvar); |
| 3756 | Array<shared_ptr<CoefficientFunction>> cross2(dimvar); |
| 3757 | for (auto i : Range(dimvar)) |
| 3758 | { |
| 3759 | cross1[i] = CrossProduct(MakeSubTensorCoefficientFunction(diffc1,i,Array<int>({3}),Array<int>({dimvar})),c2); |
| 3760 | cross2[i] = CrossProduct(c1,MakeSubTensorCoefficientFunction(diffc2,i,Array<int>({3}),Array<int>({dimvar}))); |
| 3761 | } |
| 3762 | |
| 3763 | auto dcross1 = MakeVectorialCoefficientFunction (std::move(cross1))->Reshape(dimvar,h) -> Transpose() -> Reshape(dimres); |
| 3764 | auto dcross2 = MakeVectorialCoefficientFunction (std::move(cross2))->Reshape(dimvar,h) -> Transpose() -> Reshape(dimres); |
| 3765 | |
| 3766 | res = dcross1 + dcross2; |
| 3767 | } |
| 3768 | else //second version, a little bit faster |
| 3769 | { |
| 3770 | auto c11 = MakeComponentCoefficientFunction(c1,0); |
| 3771 | auto c12 = MakeComponentCoefficientFunction(c1,1); |
| 3772 | auto c13 = MakeComponentCoefficientFunction(c1,2); |
| 3773 | auto c21 = MakeComponentCoefficientFunction(c2,0); |
| 3774 | auto c22 = MakeComponentCoefficientFunction(c2,1); |
| 3775 | auto c23 = MakeComponentCoefficientFunction(c2,2); |
| 3776 | |
| 3777 | Array<shared_ptr<CoefficientFunction>> cross(3); |
| 3778 | cross[0] = c12*c23 - c13*c22; |
| 3779 | cross[1] = c13*c21 - c11*c23; |
| 3780 | cross[2] = c11*c22 - c12*c21; |
| 3781 | |
| 3782 | res = MakeVectorialCoefficientFunction(std::move(cross)) -> DiffJacobi (var, cache); |
| 3783 | |
| 3784 | } |
| 3785 | cache[thisptr] = res; |
| 3786 | return res; |
| 3787 | } |
| 3788 | |
| 3789 | }; |
| 3790 |
nothing calls this directly
no test coverage detected