Mercurial > hg > octave-lyh
changeset 5797:11fcab4c461d
[project @ 2006-05-09 06:15:17 by dbateman]
author | dbateman |
---|---|
date | Tue, 09 May 2006 06:15:18 +0000 |
parents | 20f4bd627a74 |
children | 7e7ed81f5566 |
files | liboctave/ChangeLog liboctave/SparseCmplxQR.cc liboctave/SparseQR.cc liboctave/sparse-dmsolve.cc |
diffstat | 4 files changed, 51 insertions(+), 81 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,9 @@ +2006-05-09 David Bateman <dbateman@free.fr> + + * sparse-dmsolve.cc: Remove reference to ov-re-sparse.h, + ov-cx-sparse. and error_state. + * SparseQR.cc, SparseCmplxQR.cc (qrsolve): Return info = -1 on error. + 2006-05-08 David Bateman <dbateman@free.fr> * Sparse-op-defs.h (SPARSE_SPARSE_MUL): Set column pointers in
--- a/liboctave/SparseCmplxQR.cc +++ b/liboctave/SparseCmplxQR.cc @@ -223,13 +223,13 @@ ComplexMatrix qrsolve(const SparseComplexMatrix&a, const Matrix &b, octave_idx_type &info) { + info = -1; #ifdef HAVE_CXSPARSE octave_idx_type nr = a.rows(); octave_idx_type nc = a.cols(); octave_idx_type b_nc = b.cols(); octave_idx_type b_nr = b.rows(); ComplexMatrix x; - info = 0; if (nr < 1 || nc < 1 || nr != b_nr) (*current_liboctave_error_handler) @@ -238,10 +238,7 @@ { SparseComplexQR q (a, 2); if (! q.ok ()) - { - info = -1; - return ComplexMatrix(); - } + return ComplexMatrix(); x.resize(nc, b_nc); double _Complex *vec = reinterpret_cast<double _Complex *> (x.fortran_vec()); @@ -279,16 +276,14 @@ #endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } + info = 0; } else { SparseComplexMatrix at = a.hermitian(); SparseComplexQR q (at, 2); if (! q.ok ()) - { - info = -1; - return ComplexMatrix(); - } + return ComplexMatrix(); x.resize(nc, b_nc); double _Complex *vec = reinterpret_cast<double _Complex *> (x.fortran_vec()); @@ -332,6 +327,7 @@ #endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } + info = 0; } return x; @@ -343,6 +339,7 @@ SparseComplexMatrix qrsolve(const SparseComplexMatrix&a, const SparseMatrix &b, octave_idx_type &info) { + info = -1; #ifdef HAVE_CXSPARSE octave_idx_type nr = a.rows(); octave_idx_type nc = a.cols(); @@ -350,7 +347,6 @@ octave_idx_type b_nr = b.rows(); SparseComplexMatrix x; volatile octave_idx_type ii, x_nz; - info = 0; if (nr < 1 || nc < 1 || nr != b_nr) (*current_liboctave_error_handler) @@ -359,10 +355,7 @@ { SparseComplexQR q (a, 2); if (! q.ok ()) - { - info = -1; - return SparseComplexMatrix(); - } + return SparseComplexMatrix(); x = SparseComplexMatrix (nc, b_nc, b.nzmax()); x.xcidx(0) = 0; x_nz = b.nzmax(); @@ -422,16 +415,14 @@ } x.xcidx(i+1) = ii; } + info = 0; } else { SparseComplexMatrix at = a.hermitian(); SparseComplexQR q (at, 2); if (! q.ok ()) - { - info = -1; - return SparseComplexMatrix(); - } + return SparseComplexMatrix(); x = SparseComplexMatrix (nc, b_nc, b.nzmax()); x.xcidx(0) = 0; x_nz = b.nzmax(); @@ -496,6 +487,7 @@ } x.xcidx(i+1) = ii; } + info = 0; } x.maybe_compress (); @@ -508,6 +500,7 @@ ComplexMatrix qrsolve(const SparseComplexMatrix&a, const ComplexMatrix &b, octave_idx_type &info) { + info = -1; #ifdef HAVE_CXSPARSE octave_idx_type nr = a.rows(); octave_idx_type nc = a.cols(); @@ -516,7 +509,6 @@ const double _Complex *bvec = reinterpret_cast<const double _Complex *>(b.fortran_vec()); ComplexMatrix x; - info = 0; if (nr < 1 || nc < 1 || nr != b_nr) (*current_liboctave_error_handler) @@ -525,10 +517,7 @@ { SparseComplexQR q (a, 2); if (! q.ok ()) - { - info = -1; - return ComplexMatrix(); - } + return ComplexMatrix(); x.resize(nc, b_nc); double _Complex *vec = reinterpret_cast<double _Complex *> (x.fortran_vec()); @@ -562,16 +551,14 @@ #endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } + info = 0; } else { SparseComplexMatrix at = a.hermitian(); SparseComplexQR q (at, 2); if (! q.ok ()) - { - info = -1; - return ComplexMatrix(); - } + return ComplexMatrix(); x.resize(nc, b_nc); double _Complex *vec = reinterpret_cast<double _Complex *> (x.fortran_vec()); @@ -610,6 +597,7 @@ #endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } + info = 0; } return x; @@ -621,6 +609,7 @@ SparseComplexMatrix qrsolve(const SparseComplexMatrix&a, const SparseComplexMatrix &b, octave_idx_type &info) { + info = -1; #ifdef HAVE_CXSPARSE octave_idx_type nr = a.rows(); octave_idx_type nc = a.cols(); @@ -628,7 +617,6 @@ octave_idx_type b_nr = b.rows(); SparseComplexMatrix x; volatile octave_idx_type ii, x_nz; - info = 0; if (nr < 1 || nc < 1 || nr != b_nr) (*current_liboctave_error_handler) @@ -637,10 +625,7 @@ { SparseComplexQR q (a, 2); if (! q.ok ()) - { - info = -1; - return SparseComplexMatrix(); - } + return SparseComplexMatrix(); x = SparseComplexMatrix (nc, b_nc, b.nzmax()); x.xcidx(0) = 0; x_nz = b.nzmax(); @@ -700,16 +685,14 @@ } x.xcidx(i+1) = ii; } + info = 0; } else { SparseComplexMatrix at = a.hermitian(); SparseComplexQR q (at, 2); if (! q.ok ()) - { - info = -1; - return SparseComplexMatrix(); - } + return SparseComplexMatrix(); x = SparseComplexMatrix (nc, b_nc, b.nzmax()); x.xcidx(0) = 0; x_nz = b.nzmax(); @@ -774,6 +757,7 @@ } x.xcidx(i+1) = ii; } + info = 0; } x.maybe_compress ();
--- a/liboctave/SparseQR.cc +++ b/liboctave/SparseQR.cc @@ -214,6 +214,7 @@ Matrix qrsolve(const SparseMatrix&a, const Matrix &b, octave_idx_type& info) { + info = -1; #ifdef HAVE_CXSPARSE octave_idx_type nr = a.rows(); octave_idx_type nc = a.cols(); @@ -221,7 +222,6 @@ octave_idx_type b_nr = b.rows(); const double *bvec = b.fortran_vec(); Matrix x; - info = 0; if (nr < 1 || nc < 1 || nr != b_nr) (*current_liboctave_error_handler) @@ -230,10 +230,7 @@ { SparseQR q (a, 3); if (! q.ok ()) - { - info = -1; - return Matrix(); - } + return Matrix(); x.resize(nc, b_nc); double *vec = x.fortran_vec(); OCTAVE_LOCAL_BUFFER (double, buf, q.S()->m2); @@ -266,16 +263,14 @@ #endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } + info = 0; } else { SparseMatrix at = a.hermitian(); SparseQR q (at, 3); if (! q.ok ()) - { - info = -1; - return Matrix(); - } + return Matrix(); x.resize(nc, b_nc); double *vec = x.fortran_vec(); volatile octave_idx_type nbuf = (nc > q.S()->m2 ? nc : q.S()->m2); @@ -309,6 +304,7 @@ #endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } + info = 0; } return x; @@ -320,6 +316,7 @@ SparseMatrix qrsolve(const SparseMatrix&a, const SparseMatrix &b, octave_idx_type &info) { + info = -1; #ifdef HAVE_CXSPARSE octave_idx_type nr = a.rows(); octave_idx_type nc = a.cols(); @@ -327,7 +324,6 @@ octave_idx_type b_nc = b.cols(); SparseMatrix x; volatile octave_idx_type ii, x_nz; - info = 0; if (nr < 1 || nc < 1 || nr != b_nr) (*current_liboctave_error_handler) @@ -336,10 +332,7 @@ { SparseQR q (a, 3); if (! q.ok ()) - { - info = -1; - return SparseMatrix(); - } + return SparseMatrix(); x = SparseMatrix (nc, b_nc, b.nzmax()); x.xcidx(0) = 0; x_nz = b.nzmax(); @@ -395,16 +388,14 @@ } x.xcidx(i+1) = ii; } + info = 0; } else { SparseMatrix at = a.hermitian(); SparseQR q (at, 3); if (! q.ok ()) - { - info = -1; - return SparseMatrix(); - } + return SparseMatrix(); x = SparseMatrix (nc, b_nc, b.nzmax()); x.xcidx(0) = 0; x_nz = b.nzmax(); @@ -461,6 +452,7 @@ } x.xcidx(i+1) = ii; } + info = 0; } x.maybe_compress (); @@ -473,13 +465,13 @@ ComplexMatrix qrsolve(const SparseMatrix&a, const ComplexMatrix &b, octave_idx_type &info) { + info = -1; #ifdef HAVE_CXSPARSE octave_idx_type nr = a.rows(); octave_idx_type nc = a.cols(); octave_idx_type b_nc = b.cols(); octave_idx_type b_nr = b.rows(); ComplexMatrix x; - info = 0; if (nr < 1 || nc < 1 || nr != b_nr) (*current_liboctave_error_handler) @@ -488,10 +480,7 @@ { SparseQR q (a, 3); if (! q.ok ()) - { - info = -1; - return ComplexMatrix(); - } + return ComplexMatrix(); x.resize(nc, b_nc); Complex *vec = x.fortran_vec(); OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc)); @@ -555,16 +544,14 @@ for (octave_idx_type j = 0; j < nc; j++) vec[j+idx] = Complex (Xx[j], Xz[j]); } + info = 0; } else { SparseMatrix at = a.hermitian(); SparseQR q (at, 3); if (! q.ok ()) - { - info = -1; - return ComplexMatrix(); - } + return ComplexMatrix(); x.resize(nc, b_nc); Complex *vec = x.fortran_vec(); volatile octave_idx_type nbuf = (nc > q.S()->m2 ? nc : q.S()->m2); @@ -631,6 +618,7 @@ for (octave_idx_type j = 0; j < nc; j++) vec[j+idx] = Complex (Xx[j], Xz[j]); } + info = 0; } return x; @@ -642,6 +630,7 @@ SparseComplexMatrix qrsolve(const SparseMatrix&a, const SparseComplexMatrix &b, octave_idx_type &info) { + info = -1; #ifdef HAVE_CXSPARSE octave_idx_type nr = a.rows(); octave_idx_type nc = a.cols(); @@ -649,7 +638,6 @@ octave_idx_type b_nc = b.cols(); SparseComplexMatrix x; volatile octave_idx_type ii, x_nz; - info = 0; if (nr < 1 || nc < 1 || nr != b_nr) (*current_liboctave_error_handler) @@ -658,10 +646,7 @@ { SparseQR q (a, 3); if (! q.ok ()) - { - info = -1; - return SparseComplexMatrix(); - } + return SparseComplexMatrix(); x = SparseComplexMatrix (nc, b_nc, b.nzmax()); x.xcidx(0) = 0; x_nz = b.nzmax(); @@ -746,16 +731,14 @@ } x.xcidx(i+1) = ii; } + info = 0; } else { SparseMatrix at = a.hermitian(); SparseQR q (at, 3); if (! q.ok ()) - { - info = -1; - return SparseComplexMatrix(); - } + return SparseComplexMatrix(); x = SparseComplexMatrix (nc, b_nc, b.nzmax()); x.xcidx(0) = 0; x_nz = b.nzmax(); @@ -841,6 +824,7 @@ } x.xcidx(i+1) = ii; } + info = 0; } x.maybe_compress ();
--- a/liboctave/sparse-dmsolve.cc +++ b/liboctave/sparse-dmsolve.cc @@ -23,10 +23,7 @@ #include <config.h> #endif - -// FIXME -- liboctave should not be including files from the src directory. -#include "ov-re-sparse.h" -#include "ov-cx-sparse.h" +#include <vector> #include "MArray2.h" #include "MSparse.h" @@ -415,7 +412,7 @@ qrsolve (m, dmsolve_extract (btmp, NULL, NULL, dm->rr[2], b_nr, 0, b_nc), info); dmsolve_insert (retval, mtmp, q, dm->cc [3], 0); - if (dm->rr [2] > 0 && !info && !error_state) + if (dm->rr [2] > 0 && !info) { m = dmsolve_extract (a, pinv, q, 0, dm->rr [2], dm->cc [3], nc, nnz_remaining, true); @@ -428,8 +425,7 @@ // Structurally non-singular blocks // FIXME Should use fine Dulmange-Mendelsohn decomposition here. - if (dm->rr [1] < dm->rr [2] && dm->cc [2] < dm->cc [3] && - !info && !error_state) + if (dm->rr [1] < dm->rr [2] && dm->cc [2] < dm->cc [3] && !info) { ST m = dmsolve_extract (a, pinv, q, dm->rr [1], dm->rr [2], dm->cc [2], dm->cc [3], nnz_remaining, false); @@ -447,7 +443,7 @@ } dmsolve_insert (retval, mtmp, q, dm->cc [2], 0); - if (dm->rr [1] > 0 && !info && !error_state) + if (dm->rr [1] > 0 && !info) { m = dmsolve_extract (a, pinv, q, 0, dm->rr [1], dm->cc [2], dm->cc [3], nnz_remaining, true); @@ -459,7 +455,7 @@ } // Trailing under-determined block - if (dm->rr [1] > 0 && dm->cc [2] > 0 && !info && !error_state) + if (dm->rr [1] > 0 && dm->cc [2] > 0 && !info) { ST m = dmsolve_extract (a, pinv, q, 0, dm->rr [1], 0, dm->cc [2], nnz_remaining, true);