Mercurial > hg > octave-terminal
changeset 1944:8cb4d3008c76
[project @ 1996-02-14 00:45:04 by jwe]
author | jwe |
---|---|
date | Wed, 14 Feb 1996 00:50:23 +0000 |
parents | 24f35e425e6a |
children | 8c4bce5e773e |
files | liboctave/CmplxCHOL.cc liboctave/QPSOL.cc liboctave/dbleCHOL.cc |
diffstat | 3 files changed, 48 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/CmplxCHOL.cc +++ b/liboctave/CmplxCHOL.cc @@ -45,31 +45,36 @@ { int a_nr = a.rows (); int a_nc = a.cols (); - if (a_nr != a_nc) - { - (*current_liboctave_error_handler) - ("ComplexCHOL requires square matrix"); - return -1; - } - int n = a_nc; - int info; + if (a_nr != a_nc) + { + (*current_liboctave_error_handler) + ("ComplexCHOL requires square matrix"); + return -1; + } - Complex *h = dup (a.data (), a.length ()); + int n = a_nc; + int info; + + chol_mat = a; + Complex *h = chol_mat.fortran_vec (); - F77_FCN (zpotrf, ZPOTRF) ("U", 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! + F77_XFCN (zpotrf, ZPOTRF, ("U", n, h, n, info, 1L)); - 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; + if (f77_exception_encountered) + (*current_liboctave_error_handler) ("unrecoverable error in zpotrf"); + else + { + // If someone thinks of a more graceful way of doing this (or + // faster for that matter :-)), please let me know! - return info; + 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; } /*
--- a/liboctave/QPSOL.cc +++ b/liboctave/QPSOL.cc @@ -155,11 +155,14 @@ Array<double> aw (lenw); double *w = aw.fortran_vec (); - F77_FCN (qpsol, QPSOL) (itmax, msglvl, n, nclin, nctotl, ncon, n, - n, bigbnd, pa, pbl, pbu, pc, featol, ph, - qphess, cold, lp, orthog, istate, px, - inform, iter, objf, pclambda, iw, leniw, w, - lenw); + F77_XFCN (qpsol, QPSOL, (itmax, msglvl, n, nclin, nctotl, ncon, n, + n, bigbnd, pa, pbl, pbu, pc, featol, ph, + qphess, cold, lp, orthog, istate, px, + inform, iter, objf, pclambda, iw, leniw, w, + lenw)); + + if (f77_exception_encountered) + (*current_liboctave_error_handler) ("unrecoverable error in qpsol"); return x; }
--- a/liboctave/dbleCHOL.cc +++ b/liboctave/dbleCHOL.cc @@ -45,6 +45,7 @@ { int a_nr = a.rows (); int a_nc = a.cols (); + if (a_nr != a_nc) { (*current_liboctave_error_handler) ("CHOL requires square matrix"); @@ -54,19 +55,23 @@ int n = a_nc; int info; - double *h = dup (a.data (), a.length ()); + chol_mat = a; + double *h = chol_mat.fortran_vec (); - F77_FCN (dpotrf, DPOTRF) ("U", n, h, n, info, 1L); - - chol_mat = Matrix (h, n, n); + F77_XFCN (dpotrf, DPOTRF, ("U", n, h, n, info, 1L)); - // If someone thinks of a more graceful way of doing this (or faster - // for that matter :-)), please let me know! + if (f77_exception_encountered) + (*current_liboctave_error_handler) ("unrecoverable error in dpotrf"); + else + { + // 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; + 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; }