Mercurial > octave-nkf
diff libinterp/dldfcn/chol.cc @ 20497:5ce959c55cc0
Propagate 'lower' in chol(a, 'lower') to underlying library function.
* chol.cc (chol): Send 'L' parameter correctly when chol is called with 'lower'.
* floatCHOL.cc (init): Propagate 'lower' to underlying library function.
* floatCHOL.h: Modify the prototype of methods.
* fMatrix.cc (inverse): Invoke chol with additional parameter.
* dbleCHOL.cc (init): Propagate 'lower' to underlying library function.
* dbleCHOL.h: Modify the prototype of methods.
* dMatrix.cc (inverse): Invoke chol with additional parameter.
* CmplxCHOL.cc (init): Propagate 'lower' to underlying library function.
* CmplxCHOL.h: Modify the prototype of methods.
* CMatrix.cc (inverse): Invoke chol with additional parameter.
author | PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> |
---|---|
date | Sun, 24 Aug 2014 19:35:06 +0530 |
parents | 075a5e2e1ba5 |
children | 0650b8431037 |
line wrap: on
line diff
--- a/libinterp/dldfcn/chol.cc Thu Aug 20 14:37:57 2015 -0400 +++ b/libinterp/dldfcn/chol.cc Sun Aug 24 19:35:06 2014 +0530 @@ -46,6 +46,13 @@ template <class CHOLT> static octave_value +get_chol (const CHOLT& fact) +{ + return octave_value (fact.chol_matrix()); +} + +template <class CHOLT> +static octave_value get_chol_r (const CHOLT& fact) { return octave_value (fact.chol_matrix (), @@ -162,10 +169,6 @@ if (tmp.compare ("vector") == 0) vecout = true; else if (tmp.compare ("lower") == 0) - // FIXME: currently the option "lower" is handled by transposing - // the matrix, factorizing it with the lapack function - // DPOTRF ('U', ...) and finally transposing the factor. It would - // be more efficient to use DPOTRF ('L', ...) in this case. LLt = true; else if (tmp.compare ("upper") == 0) LLt = false; @@ -266,18 +269,12 @@ octave_idx_type info; FloatCHOL fact; - if (LLt) - fact = FloatCHOL (m.transpose (), info); - else - fact = FloatCHOL (m, info); + fact = FloatCHOL (m, info, LLt != true); if (nargout == 2 || info == 0) { retval(1) = info; - if (LLt) - retval(0) = get_chol_l (fact); - else - retval(0) = get_chol_r (fact); + retval(0) = get_chol (fact); } else error ("chol: input matrix must be positive definite"); @@ -323,18 +320,12 @@ octave_idx_type info; CHOL fact; - if (LLt) - fact = CHOL (m.transpose (), info); - else - fact = CHOL (m, info); + fact = CHOL (m, info, LLt != true); if (nargout == 2 || info == 0) { retval(1) = info; - if (LLt) - retval(0) = get_chol_l (fact); - else - retval(0) = get_chol_r (fact); + retval(0) = get_chol (fact); } else error ("chol: input matrix must be positive definite"); @@ -349,18 +340,12 @@ octave_idx_type info; ComplexCHOL fact; - if (LLt) - fact = ComplexCHOL (m.transpose (), info); - else - fact = ComplexCHOL (m, info); + fact = ComplexCHOL (m, info, LLt != true); if (nargout == 2 || info == 0) { retval(1) = info; - if (LLt) - retval(0) = get_chol_l (fact); - else - retval(0) = get_chol_r (fact); + retval(0) = get_chol (fact); } else error ("chol: input matrix must be positive definite");