Mercurial > hg > octave-nkf
changeset 6924:be176b7e110a
[project @ 2007-09-25 19:08:19 by dbateman]
author | dbateman |
---|---|
date | Tue, 25 Sep 2007 19:08:20 +0000 |
parents | 1fcee6e2c4d3 |
children | 1401a79af68c |
files | liboctave/CMatrix.cc liboctave/CSparse.cc liboctave/ChangeLog liboctave/SparseCmplxQR.cc liboctave/SparseQR.cc liboctave/dMatrix.cc liboctave/dSparse.cc liboctave/sparse-dmsolve.cc |
diffstat | 8 files changed, 229 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -1691,9 +1691,11 @@ octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { volatile int typ = mattype.type (); @@ -1798,9 +1800,11 @@ octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { volatile int typ = mattype.type (); @@ -1905,9 +1909,12 @@ octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) - ("matrix dimension mismatch in solution of linear equations"); + ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { volatile int typ = mattype.type (); @@ -2422,9 +2429,11 @@ octave_idx_type m = rows (); octave_idx_type n = cols (); - if (m == 0 || n == 0 || m != b.rows ()) + if (m != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (m== 0 || n == 0 || b.cols () == 0) + retval = ComplexMatrix (n, b.cols (), Complex (0.0, 0.0)); else { ComplexMatrix atmp = *this; @@ -2536,9 +2545,11 @@ octave_idx_type m = rows (); octave_idx_type n = cols (); - if (m == 0 || n == 0 || m != b.length ()) + if (m != b.length ()) (*current_liboctave_error_handler) - ("matrix dimension mismatch solution of least squares problem"); + ("matrix dimension mismatch solution of linear equations"); + else if (m == 0 || n == 0 || b.cols () == 0) + retval = ComplexColumnVector (n, Complex (0.0, 0.0)); else { ComplexMatrix atmp = *this;
--- a/liboctave/CSparse.cc +++ b/liboctave/CSparse.cc @@ -1212,9 +1212,11 @@ octave_idx_type nm = (nc < nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -1271,9 +1273,11 @@ octave_idx_type nm = (nc < nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -1360,9 +1364,11 @@ octave_idx_type nm = (nc < nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -1419,9 +1425,11 @@ octave_idx_type nm = (nc < nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -1508,9 +1516,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -1742,9 +1752,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -2027,9 +2039,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -2261,9 +2275,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -2547,9 +2563,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -2802,9 +2820,11 @@ err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -3107,9 +3127,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -3365,9 +3387,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -3669,9 +3693,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else if (calc_cond) (*current_liboctave_error_handler) ("calculation of condition number not implemented"); @@ -3824,9 +3850,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else if (calc_cond) (*current_liboctave_error_handler) ("calculation of condition number not implemented"); @@ -3982,9 +4010,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else if (calc_cond) (*current_liboctave_error_handler) ("calculation of condition number not implemented"); @@ -4145,9 +4175,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else if (calc_cond) (*current_liboctave_error_handler) ("calculation of condition number not implemented"); @@ -4314,9 +4346,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -4588,9 +4622,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -4939,9 +4975,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -5216,9 +5254,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -5692,9 +5732,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -5950,9 +5992,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -6259,9 +6303,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -6499,9 +6545,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,17 @@ +2007-09-25 David Bateman <dbateman@free.fr> + + * dMatrix.cc (utsolve, ltsolve, fsolve, lssolve): Allow + zero dimensioned matrices. + * CMatrix.cc (utsolve, ltsolve, fsolve, lssolve): ditto. + * dSparse.cc (dsolve, utsolve, ltsolve, bsolve, trisolve, fsolve): + ditto. + * CSparse.cc (dsolve, utsolve, ltsolve, bsolve, trisolve, fsolve): + ditto. + * SparseQR.cc (SparseQR::SparseQR_rep::C, qrsolve): ditto. + * SparseCmplxQR.cc (SparseComplexQR::SparseComplexQR_rep::C, + qrsolve): ditto. + * sparse-dmsolve.cc (dmsolve): ditto. + 2007-09-21 John W. Eaton <jwe@octave.org> * Array.cc (assign1 (Array<LT>&, const Array<RT>&, const LT&)):
--- a/liboctave/SparseCmplxQR.cc +++ b/liboctave/SparseCmplxQR.cc @@ -190,10 +190,12 @@ octave_idx_type nr = nrows; const cs_complex_t *bvec = reinterpret_cast<const cs_complex_t *>(b.fortran_vec()); - ComplexMatrix ret(b_nr,b_nc); + ComplexMatrix ret(b_nr, b_nc); Complex *vec = ret.fortran_vec(); - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch"); + else if (nr == 0 || nc == 0 || b_nc == 0) + ret = ComplexMatrix (nc, b_nc, Complex (0.0, 0.0)); else { OCTAVE_LOCAL_BUFFER (Complex, buf, S->m2); @@ -239,9 +241,11 @@ octave_idx_type b_nr = b.rows(); ComplexMatrix x; - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch in solution of minimum norm problem"); + else if (nr == 0 || nc == 0 || b_nc == 0) + x = ComplexMatrix (nc, b_nc, Complex (0.0, 0.0)); else if (nr >= nc) { SparseComplexQR q (a, 2); @@ -366,9 +370,11 @@ SparseComplexMatrix x; volatile octave_idx_type ii, x_nz; - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch in solution of minimum norm problem"); + else if (nr == 0 || nc == 0 || b_nc == 0) + x = SparseComplexMatrix (nc, b_nc); else if (nr >= nc) { SparseComplexQR q (a, 2); @@ -539,9 +545,11 @@ reinterpret_cast<const cs_complex_t *>(b.fortran_vec()); ComplexMatrix x; - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch in solution of minimum norm problem"); + else if (nr == 0 || nc == 0 || b_nc == 0) + x = ComplexMatrix (nc, b_nc, Complex (0.0, 0.0)); else if (nr >= nc) { SparseComplexQR q (a, 2); @@ -657,9 +665,11 @@ SparseComplexMatrix x; volatile octave_idx_type ii, x_nz; - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch in solution of minimum norm problem"); + else if (nr == 0 || nc == 0 || b_nc == 0) + x = SparseComplexMatrix (nc, b_nc); else if (nr >= nc) { SparseComplexQR q (a, 2);
--- a/liboctave/SparseQR.cc +++ b/liboctave/SparseQR.cc @@ -173,10 +173,12 @@ octave_idx_type nc = N->L->n; octave_idx_type nr = nrows; const double *bvec = b.fortran_vec(); - Matrix ret(b_nr,b_nc); + Matrix ret (b_nr, b_nc); double *vec = ret.fortran_vec(); - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch"); + else if (nr == 0 || nc == 0 || b_nc == 0) + ret = Matrix (nc, b_nc, 0.0); else { OCTAVE_LOCAL_BUFFER (double, buf, S->m2); @@ -223,9 +225,11 @@ const double *bvec = b.fortran_vec(); Matrix x; - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch in solution of minimum norm problem"); + else if (nr == 0 || nc == 0 || b_nc == 0) + x = Matrix (nc, b_nc, 0.0); else if (nr >= nc) { SparseQR q (a, 3); @@ -325,9 +329,11 @@ SparseMatrix x; volatile octave_idx_type ii, x_nz; - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch in solution of minimum norm problem"); + else if (nr == 0 || nc == 0 || b_nc == 0) + x = SparseMatrix (nc, b_nc); else if (nr >= nc) { SparseQR q (a, 3); @@ -473,9 +479,11 @@ octave_idx_type b_nr = b.rows(); ComplexMatrix x; - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch in solution of minimum norm problem"); + else if (nr == 0 || nc == 0 || b_nc == 0) + x = ComplexMatrix (nc, b_nc, Complex (0.0, 0.0)); else if (nr >= nc) { SparseQR q (a, 3); @@ -639,9 +647,11 @@ SparseComplexMatrix x; volatile octave_idx_type ii, x_nz; - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch in solution of minimum norm problem"); + else if (nr == 0 || nc == 0 || b_nc == 0) + x = SparseComplexMatrix (nc, b_nc); else if (nr >= nc) { SparseQR q (a, 3);
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -1353,9 +1353,11 @@ octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = Matrix (nc, b.cols (), 0.0); else { volatile int typ = mattype.type (); @@ -1459,9 +1461,11 @@ octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = Matrix (nc, b.cols (), 0.0); else { volatile int typ = mattype.type (); @@ -1565,9 +1569,11 @@ octave_idx_type nr = rows (); octave_idx_type nc = cols (); - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = Matrix (nc, b.cols (), 0.0); else { volatile int typ = mattype.type (); @@ -2046,9 +2052,12 @@ octave_idx_type m = rows (); octave_idx_type n = cols (); - if (m == 0 || n == 0 || m != b.rows ()) + + if (m != b.rows ()) (*current_liboctave_error_handler) - ("matrix dimension mismatch in solution of least squares problem"); + ("matrix dimension mismatch solution of linear equations"); + else if (m == 0 || n == 0 || b.cols () == 0) + retval = Matrix (n, b.cols (), 0.0); else { Matrix atmp = *this; @@ -2155,9 +2164,11 @@ octave_idx_type m = rows (); octave_idx_type n = cols (); - if (m == 0 || n == 0 || m != b.length ()) + if (m != b.length ()) (*current_liboctave_error_handler) - ("matrix dimension mismatch in solution of least squares problem"); + ("matrix dimension mismatch solution of linear equations"); + else if (m == 0 || n == 0) + retval = ColumnVector (n, 0.0); else { Matrix atmp = *this;
--- a/liboctave/dSparse.cc +++ b/liboctave/dSparse.cc @@ -1278,9 +1278,11 @@ octave_idx_type nm = (nc < nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = Matrix (nc, b.cols (), 0.0); else { // Print spparms("spumoni") info if requested @@ -1336,9 +1338,11 @@ octave_idx_type nm = (nc < nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -1424,9 +1428,11 @@ octave_idx_type nm = (nc < nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -1482,9 +1488,11 @@ octave_idx_type nm = (nc < nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -1571,9 +1579,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = Matrix (nc, b.cols (), 0.0); else { // Print spparms("spumoni") info if requested @@ -1804,9 +1814,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -2089,9 +2101,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -2325,9 +2339,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -2613,9 +2629,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = Matrix (nc, b.cols (), 0.0); else { // Print spparms("spumoni") info if requested @@ -2871,9 +2889,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -3176,9 +3196,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -3435,9 +3457,11 @@ octave_idx_type nm = (nc > nr ? nc : nr); err = 0; - if (nr == 0 || nc == 0 || nr != b.rows ()) + if (nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || nc == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -3741,9 +3765,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = Matrix (nc, b.cols (), 0.0); else if (calc_cond) (*current_liboctave_error_handler) ("calculation of condition number not implemented"); @@ -3896,9 +3922,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseMatrix (nc, b.cols ()); else if (calc_cond) (*current_liboctave_error_handler) ("calculation of condition number not implemented"); @@ -4054,9 +4082,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else if (calc_cond) (*current_liboctave_error_handler) ("calculation of condition number not implemented"); @@ -4216,9 +4246,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else if (calc_cond) (*current_liboctave_error_handler) ("calculation of condition number not implemented"); @@ -4413,9 +4445,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = Matrix (nc, b.cols (), 0.0); else { // Print spparms("spumoni") info if requested @@ -4688,9 +4722,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -5039,9 +5075,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -5386,9 +5424,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -5908,9 +5948,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = Matrix (nc, b.cols (), 0.0); else { // Print spparms("spumoni") info if requested @@ -6140,9 +6182,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested @@ -6420,9 +6464,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = ComplexMatrix (nc, b.cols (), Complex (0.0, 0.0)); else { // Print spparms("spumoni") info if requested @@ -6672,9 +6718,11 @@ octave_idx_type nc = cols (); err = 0; - if (nr == 0 || nc == 0 || nr != nc || nr != b.rows ()) + if (nr != nc || nr != b.rows ()) (*current_liboctave_error_handler) ("matrix dimension mismatch solution of linear equations"); + else if (nr == 0 || b.cols () == 0) + retval = SparseComplexMatrix (nc, b.cols ()); else { // Print spparms("spumoni") info if requested
--- a/liboctave/sparse-dmsolve.cc +++ b/liboctave/sparse-dmsolve.cc @@ -368,9 +368,11 @@ octave_idx_type b_nc = b.cols (); RT retval; - if (nr < 1 || nc < 1 || nr != b_nr) + if (nr < 0 || nc < 0 || nr != b_nr) (*current_liboctave_error_handler) ("matrix dimension mismatch in solution of minimum norm problem"); + else if (nr == 0 || nc == 0 || b_nc == 0) + retval = RT (nc, b_nc, 0.0); else { octave_idx_type nnz_remaining = a.nnz ();