Mercurial > hg > octave-lyh
changeset 12986:f217edac2c71 stable
fix dimension check for A'\B (bug #33997)
* xdiv.cc (mx_leftdiv_conform): New arg, blas_trans.
Change all callers.
* dMatrix.cc: New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 22 Aug 2011 21:20:42 -0400 |
parents | 7626f8934466 |
children | 4a39209844f4 dfab2a8ca545 |
files | liboctave/dMatrix.cc src/xdiv.cc |
diffstat | 2 files changed, 20 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -3112,14 +3112,19 @@ /* Test some simple identities %!shared M, cv, rv -%! M = randn(10,10); +%! M = randn(10,10)+100*eye(10,10); +%! Mt = M'; %! cv = randn(10,1); +%! cvt = cv'; %! rv = randn(1,10); +%! rvt = rv'; %!assert([M*cv,M*cv],M*[cv,cv],1e-14) %!assert([M'*cv,M'*cv],M'*[cv,cv],1e-14) %!assert([rv*M;rv*M],[rv;rv]*M,1e-14) %!assert([rv*M';rv*M'],[rv;rv]*M',1e-14) %!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-14) +%!assert(M'\cv,Mt\cv,1e-14) +%!assert(M'\rv',Mt\rvt,1e-14) */ static inline char
--- a/src/xdiv.cc +++ b/src/xdiv.cc @@ -64,14 +64,14 @@ template <class T1, class T2> bool -mx_leftdiv_conform (const T1& a, const T2& b) +mx_leftdiv_conform (const T1& a, const T2& b, blas_trans_type blas_trans) { - octave_idx_type a_nr = a.rows (); + octave_idx_type a_nr = blas_trans == blas_no_trans ? a.rows () : a.cols (); octave_idx_type b_nr = b.rows (); if (a_nr != b_nr) { - octave_idx_type a_nc = a.cols (); + octave_idx_type a_nc = blas_trans == blas_no_trans ? a.cols () : a.rows (); octave_idx_type b_nc = b.cols (); gripe_nonconformant ("operator \\", a_nr, a_nc, b_nr, b_nc); @@ -82,7 +82,7 @@ } #define INSTANTIATE_MX_LEFTDIV_CONFORM(T1, T2) \ - template bool mx_leftdiv_conform (const T1&, const T2&) + template bool mx_leftdiv_conform (const T1&, const T2&, blas_trans_type) INSTANTIATE_MX_LEFTDIV_CONFORM (Matrix, Matrix); INSTANTIATE_MX_LEFTDIV_CONFORM (Matrix, ComplexMatrix); @@ -352,7 +352,7 @@ Matrix xleftdiv (const Matrix& a, const Matrix& b, MatrixType &typ, blas_trans_type transt) { - if (! mx_leftdiv_conform (a, b)) + if (! mx_leftdiv_conform (a, b, transt)) return Matrix (); octave_idx_type info; @@ -364,7 +364,7 @@ ComplexMatrix xleftdiv (const Matrix& a, const ComplexMatrix& b, MatrixType &typ, blas_trans_type transt) { - if (! mx_leftdiv_conform (a, b)) + if (! mx_leftdiv_conform (a, b, transt)) return ComplexMatrix (); octave_idx_type info; @@ -377,7 +377,7 @@ ComplexMatrix xleftdiv (const ComplexMatrix& a, const Matrix& b, MatrixType &typ, blas_trans_type transt) { - if (! mx_leftdiv_conform (a, b)) + if (! mx_leftdiv_conform (a, b, transt)) return ComplexMatrix (); octave_idx_type info; @@ -389,7 +389,7 @@ ComplexMatrix xleftdiv (const ComplexMatrix& a, const ComplexMatrix& b, MatrixType &typ, blas_trans_type transt) { - if (! mx_leftdiv_conform (a, b)) + if (! mx_leftdiv_conform (a, b, transt)) return ComplexMatrix (); octave_idx_type info; @@ -650,7 +650,7 @@ FloatMatrix xleftdiv (const FloatMatrix& a, const FloatMatrix& b, MatrixType &typ, blas_trans_type transt) { - if (! mx_leftdiv_conform (a, b)) + if (! mx_leftdiv_conform (a, b, transt)) return FloatMatrix (); octave_idx_type info; @@ -662,7 +662,7 @@ FloatComplexMatrix xleftdiv (const FloatMatrix& a, const FloatComplexMatrix& b, MatrixType &typ, blas_trans_type transt) { - if (! mx_leftdiv_conform (a, b)) + if (! mx_leftdiv_conform (a, b, transt)) return FloatComplexMatrix (); octave_idx_type info; @@ -675,7 +675,7 @@ FloatComplexMatrix xleftdiv (const FloatComplexMatrix& a, const FloatMatrix& b, MatrixType &typ, blas_trans_type transt) { - if (! mx_leftdiv_conform (a, b)) + if (! mx_leftdiv_conform (a, b, transt)) return FloatComplexMatrix (); octave_idx_type info; @@ -687,7 +687,7 @@ FloatComplexMatrix xleftdiv (const FloatComplexMatrix& a, const FloatComplexMatrix& b, MatrixType &typ, blas_trans_type transt) { - if (! mx_leftdiv_conform (a, b)) + if (! mx_leftdiv_conform (a, b, transt)) return FloatComplexMatrix (); octave_idx_type info; @@ -782,7 +782,7 @@ MT dmm_leftdiv_impl (const DMT& d, const MT& a) { - if (! mx_leftdiv_conform (d, a)) + if (! mx_leftdiv_conform (d, a, blas_no_trans)) return MT (); octave_idx_type m = d.cols (), n = a.cols (), k = a.rows (), l = d.length (); @@ -931,7 +931,7 @@ MT dmdm_leftdiv_impl (const DMT& d, const MT& a) { - if (! mx_leftdiv_conform (d, a)) + if (! mx_leftdiv_conform (d, a, blas_no_trans)) return MT (); octave_idx_type m = d.cols (), n = a.cols (), k = d.rows ();