Scythe-1.0.3
template<typename T , matrix_order PO1, matrix_style PS1, matrix_order PO2, matrix_style PS2, typename FUNCTOR >
T scythe::gradfdifls ( FUNCTOR  fun,
alpha,
const Matrix< T, PO1, PS1 > &  theta,
const Matrix< T, PO2, PS2 > &  p 
)

Calculate the first derivative of the function using a forward difference formula.

This function numerically calculates the first derivative of a function with respect to alpha at $theta + alpha \cdot p$ using a forward difference formula. This function is primarily useful for linesearches.

Parameters:
funThe function to calculate the first derivative of. This function should take a single Matrix<T> argument and return a value of type T.
alphaDouble the step length.
thetaA Matrix (vector) of parameter values at which to calculate the gradient.
pA direction vector.
See also:
gradfdif(FUNCTOR fun, const Matrix<T,PO,PS>& theta)
jacfdif(FUNCTOR fun, const Matrix<T,PO,PS>& theta)
hesscdif(FUNCTOR fun, const Matrix<T,PO,PS>& theta)
Exceptions:
scythe_dimension_error(Level 1)
Note:
Users will typically wish to implement fun in terms of a functor. Using a functor provides a generic way in which to evaluate functions with more than one parameter. Furthermore, although one can pass a function pointer to this routine, the compiler cannot inline and fully optimize code referenced by function pointers.

References scythe::Matrix_base< ORDER, STYLE >::isColVector(), SCYTHE_CHECK_10, scythe::Matrix_base< ORDER, STYLE >::size(), and sqrt().

Referenced by linesearch2(), and zoom().