Commit 8f5f181f authored by Kirill Terekhov's avatar Kirill Terekhov

Fix and unit test

Fix hessian calculation for sqrt and add unit test
parent 9ea0f06c
......@@ -1106,7 +1106,13 @@ namespace INMOST
}
__INLINE void GetHessian(INMOST_DATA_REAL_TYPE multJ, Sparse::Row & J, INMOST_DATA_REAL_TYPE multH, Sparse::HessianRow & H) const
{
arg.GetHessian(0.5*multJ/value,J,-0.25*multH/::pow(value,3),H);
//general formula:
// (F(G))'' = F'(G) G'' + F''(G) G'.G'
Sparse::HessianRow htmp;
arg.GetHessian(multJ,J,multH,htmp);
Sparse::HessianRow::MergeJacobianHessian(-0.25/::pow(value,3.0),J,J,0.5/value,htmp,H);
for(Sparse::Row::iterator it = J.Begin(); it != J.End(); ++it) it->second *= 0.5/value;
//arg.GetHessian(0.5*multJ/value,J,-0.25*multH/::pow(value,3),H);
}
};
......
......@@ -17,3 +17,6 @@ endif(USE_MPI)
add_test(NAME autodiff_test000_hessian_sin COMMAND $<TARGET_FILE:autodiff_test000> 0)
add_test(NAME autodiff_test000_hessian_sin_mixed COMMAND $<TARGET_FILE:autodiff_test000> 1)
add_test(NAME autodiff_test000_hessian_cos_mixed COMMAND $<TARGET_FILE:autodiff_test000> 2)
add_test(NAME autodiff_test000_hessian_sin_mult COMMAND $<TARGET_FILE:autodiff_test000> 3)
add_test(NAME autodiff_test000_hessian_cos_mult COMMAND $<TARGET_FILE:autodiff_test000> 4)
add_test(NAME autodiff_test000_hessian_sqrt_mixed COMMAND $<TARGET_FILE:autodiff_test000> 5)
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment