Mercurial > hg > octave-lojdl
changeset 7560:0ef0f9802a37
modify QR updating methods to use 0-based indexing
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 05 Mar 2008 14:24:33 -0500 |
parents | 07522d7dcdf8 |
children | a938cd7869b2 |
files | liboctave/ChangeLog liboctave/CmplxQR.cc liboctave/dbleQR.cc src/ChangeLog src/DLD-FUNCTIONS/qr.cc |
diffstat | 5 files changed, 32 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,5 +1,10 @@ 2008-03-05 Jaroslav Hajek <highegg@gmail.com> + * dbleQR.cc (QR::insert_col, QR::insert_row, + QR::delete_col, QR::delete_row): Use 0-based indexing. + * CmplxQR.cc (ComplexQR::insert_col, ComplexQR::insert_row, + ComplexQR::delete_col, ComplexQR::delete_row): Likewise. + * dbleCHOL.cc: Small doc and declaration fixes. * CmplxHOL.cc: Small doc and declaration fixes. * CmplxQR.cc (ComplexQR::ComplexQR): Adjust code to match dbleQR.cc.
--- a/liboctave/CmplxQR.cc +++ b/liboctave/CmplxQR.cc @@ -190,14 +190,14 @@ if (u.length () != m) (*current_liboctave_error_handler) ("QR insert dimensions mismatch"); - else if (j < 1 || j > n+1) + else if (j < 0 || j > n) (*current_liboctave_error_handler) ("QR insert index out of range"); else { ComplexMatrix r1 (m,n+1); F77_XFCN (zqrinc, ZQRINC, (m, n, k, q.fortran_vec (), r.data (), - r1.fortran_vec (), j, u.data ())); + r1.fortran_vec (), j+1, u.data ())); r = r1; } @@ -212,14 +212,14 @@ if (k < m && k < n) (*current_liboctave_error_handler) ("QR delete dimensions mismatch"); - else if (j < 1 || j > n) + else if (j < 0 || j > n-1) (*current_liboctave_error_handler) ("QR delete index out of range"); else { ComplexMatrix r1 (k, n-1); F77_XFCN (zqrdec, ZQRDEC, (m, n, k, q.fortran_vec (), r.data (), - r1.fortran_vec (), j)); + r1.fortran_vec (), j+1)); r = r1; } @@ -233,7 +233,7 @@ if (! q.is_square () || u.length () != n) (*current_liboctave_error_handler) ("QR insert dimensions mismatch"); - else if (j < 1 || j > m+1) + else if (j < 0 || j > m) (*current_liboctave_error_handler) ("QR insert index out of range"); else { @@ -241,7 +241,7 @@ ComplexMatrix r1 (m+1, n); F77_XFCN (zqrinr, ZQRINR, (m, n, q.data (), q1.fortran_vec (), - r.data (), r1.fortran_vec (), j, u.data ())); + r.data (), r1.fortran_vec (), j+1, u.data ())); q = q1; r = r1; @@ -256,7 +256,7 @@ if (! q.is_square ()) (*current_liboctave_error_handler) ("QR insert dimensions mismatch"); - else if (j < 1 || j > m) + else if (j < 0 || j > m-1) (*current_liboctave_error_handler) ("QR delete index out of range"); else { @@ -264,7 +264,7 @@ ComplexMatrix r1 (m-1, n); F77_XFCN (zqrder, ZQRDER, (m, n, q.data (), q1.fortran_vec (), - r.data (), r1.fortran_vec (), j )); + r.data (), r1.fortran_vec (), j+1 )); q = q1; r = r1;
--- a/liboctave/dbleQR.cc +++ b/liboctave/dbleQR.cc @@ -179,14 +179,14 @@ if (u.length () != m) (*current_liboctave_error_handler) ("QR insert dimensions mismatch"); - else if (j < 1 || j > n+1) + else if (j < 0 || j > n) (*current_liboctave_error_handler) ("QR insert index out of range"); else { Matrix r1 (m, n+1); F77_XFCN (dqrinc, DQRINC, (m, n, k, q.fortran_vec (), r.data (), - r1.fortran_vec (), j, u.data ())); + r1.fortran_vec (), j+1, u.data ())); r = r1; } @@ -201,14 +201,14 @@ if (k < m && k < n) (*current_liboctave_error_handler) ("QR delete dimensions mismatch"); - else if (j < 1 || j > n) + else if (j < 0 || j > n-1) (*current_liboctave_error_handler) ("QR delete index out of range"); else { Matrix r1 (k, n-1); F77_XFCN (dqrdec, DQRDEC, (m, n, k, q.fortran_vec (), r.data (), - r1.fortran_vec (), j)); + r1.fortran_vec (), j+1)); r = r1; } @@ -222,7 +222,7 @@ if (! q.is_square () || u.length () != n) (*current_liboctave_error_handler) ("QR insert dimensions mismatch"); - else if (j < 1 || j > m+1) + else if (j < 0 || j > m) (*current_liboctave_error_handler) ("QR insert index out of range"); else { @@ -230,7 +230,7 @@ Matrix r1 (m+1, n); F77_XFCN (dqrinr, DQRINR, (m, n, q.data (), q1.fortran_vec (), - r.data (), r1.fortran_vec (), j, u.data ())); + r.data (), r1.fortran_vec (), j+1, u.data ())); q = q1; r = r1; @@ -245,7 +245,7 @@ if (! q.is_square ()) (*current_liboctave_error_handler) ("QR insert dimensions mismatch"); - else if (j < 1 || j > m) + else if (j < 0 || j > m-1) (*current_liboctave_error_handler) ("QR delete index out of range"); else { @@ -253,7 +253,7 @@ Matrix r1 (m-1, n); F77_XFCN (dqrder, DQRDER, (m, n, q.data (), q1.fortran_vec (), - r.data (), r1.fortran_vec (), j )); + r.data (), r1.fortran_vec (), j+1 )); q = q1; r = r1;
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -7,6 +7,9 @@ code to meet Octave's coding guidelines. * DLD-FUNCTIONS/qr.cc (Fqrdelete): Fix incorrect test. + * DLD-FUNCTIONS/qr.cc (Fqrinsert, Fqrdelete): Modify to use + 0-based indexing in liboctave's QR classes. + 2008-03-04 Jaroslav Hajek <highegg@gmail.com> * DLD-FUNCTIONS/chol.cc (Fcholupdate): New function.
--- a/src/DLD-FUNCTIONS/qr.cc +++ b/src/DLD-FUNCTIONS/qr.cc @@ -628,9 +628,9 @@ QR fact (Q, R); if (row) - fact.insert_row (x, j); + fact.insert_row (x, j-1); else - fact.insert_col (x, j); + fact.insert_col (x, j-1); retval(1) = fact.R (); retval(0) = fact.Q (); @@ -645,9 +645,9 @@ ComplexQR fact (Q, R); if (row) - fact.insert_row (x, j); + fact.insert_row (x, j-1); else - fact.insert_col (x, j); + fact.insert_col (x, j-1); retval(1) = fact.R (); retval(0) = fact.Q (); @@ -809,10 +809,10 @@ QR fact (Q, R); if (row) - fact.delete_row (j); + fact.delete_row (j-1); else { - fact.delete_col (j); + fact.delete_col (j-1); if (! colp && k < m) fact.economize (); @@ -830,10 +830,10 @@ ComplexQR fact (Q, R); if (row) - fact.delete_row (j); + fact.delete_row (j-1); else { - fact.delete_col (j); + fact.delete_col (j-1); if (! colp && k < m) fact.economize ();