/** * Description not yet available. * \param */ dvar_vector sfabs(const dvar_vector& t1) { RETURN_ARRAYS_INCREMENT(); dvar_vector tmp(t1.indexmin(),t1.indexmax()); for (int i=t1.indexmin(); i<=t1.indexmax(); i++) { tmp.elem(i)=sfabs(t1.elem(i)); } RETURN_ARRAYS_DECREMENT(); return(tmp); }
/** LU decomposition back susbstitution alogrithm for variable object. \param a A dmatrix containing LU decomposition of input matrix. \f$a\f$. \param indx Permutation vector from ludcmp. \param b A dvector containing the RHS, \f$b\f$ of the linear equation \f$A\cdot X = B\f$, to be solved, and containing on return the solution vector \f$X\f$. \n\n The implementation of this algorithm was inspired by "Numerical Recipes in C", 2nd edition, Press, Teukolsky, Vetterling, Flannery, chapter 2 */ void lubksb(dvar_matrix a, const ivector& indx,dvar_vector b) { int i,ii=0,ip,j,iiflag=0; dvariable sum; int lb=a.colmin(); int ub=a.colmax(); for (i=lb;i<=ub;i++) { ip=indx(i); sum=b(ip); b(ip)=b(i); if (iiflag) { for (j=ii;j<=i-1;j++) { sum -= a.elem(i,j)*b.elem(j); } } else if (!ISZERO(value(sum))) { ii=i; iiflag=1; } b(i)=sum; } for (i=ub;i>=lb;i--) { sum=b(i); for (j=i+1;j<=ub;j++) { // !!! remove to show bug sum -= a.elem(i,j)*b.elem(j); } // !!! remove to show bug b.elem(i)=sum/a.elem(i,i); } }