Mercurial > hg > octave-lyh
diff liboctave/Matrix-ext.cc @ 182:2db13bf4f3e2
[project @ 1993-10-23 22:51:34 by jwe]
author | jwe |
---|---|
date | Sat, 23 Oct 1993 22:51:34 +0000 |
parents | 2cd2476fb32d |
children | 1a48a1b91489 |
line wrap: on
line diff
--- a/liboctave/Matrix-ext.cc +++ b/liboctave/Matrix-ext.cc @@ -229,6 +229,69 @@ } /* + * CHOL stuff + */ + +int +CHOL::init (const Matrix& a) +{ + if (a.nr != a.nc) + FAIL; + + char uplo = 'U'; + + int n = a.nc; + int info; + + double *h = dup (a.data, a.len); + + F77_FCN (dpotrf) (&uplo, &n, h, &n, &info, 1L); + + chol_mat = Matrix (h, n, n); + +// If someone thinks of a more graceful way of doing this (or faster for +// that matter :-)), please let me know! + + if (n > 1) + for (int j = 0; j < a.nc; j++) + for (int i = j+1; i < a.nr; i++) + chol_mat.elem (i, j) = 0.0; + + + return info; +} + + +int +ComplexCHOL::init (const ComplexMatrix& a) +{ + if (a.nr != a.nc) + FAIL; + + char uplo = 'U'; + + int n = a.nc; + int info; + + Complex *h = dup (a.data, a.len); + + F77_FCN (zpotrf) (&uplo, &n, h, &n, &info, 1L); + + chol_mat = ComplexMatrix (h, n, n); + +// If someone thinks of a more graceful way of doing this (or faster for +// that matter :-)), please let me know! + + if (n > 1) + for (int j = 0; j < a.nc; j++) + for (int i = j+1; i < a.nr; i++) + chol_mat.elem (i, j) = 0.0; + + return info; +} + + +/* * HESS stuff */