Mercurial > hg > octave-nkf
changeset 5792:eb90c83b4f91
[project @ 2006-05-04 20:14:49 by dbateman]
author | dbateman |
---|---|
date | Thu, 04 May 2006 20:14:50 +0000 |
parents | 70215aff5ccf |
children | 395382df0d8a |
files | liboctave/ChangeLog liboctave/SparseCmplxQR.cc liboctave/SparseCmplxQR.h liboctave/SparseQR.cc liboctave/SparseQR.h liboctave/sparse-dmsolve.cc src/ChangeLog src/DLD-FUNCTIONS/spqr.cc |
diffstat | 8 files changed, 260 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,9 @@ +2006-05-04 David Bateman <dbateman@free.fr> + + * SparseQR.cc, SparseQR.h, SparseCmplxQR.cc, SparseCmplxQR.h, + sparse-dmsolve.cc : Allow compilation with versions v2.0.0 of + CXSparse or later + 2006-05-03 David Bateman <dbateman@free.fr> * CMatrix.cc (zpotrf, zpocon, zpotrs, ztrcon, ztrtrs):
--- a/liboctave/SparseCmplxQR.cc +++ b/liboctave/SparseCmplxQR.cc @@ -53,7 +53,11 @@ (a.data ())); A.nz = -1; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; - S = CXSPARSE_ZNAME (_sqr) (&A, order, 1); +#if defined(CS_VER) && (CS_VER >= 2) + S = CXSPARSE_ZNAME (_sqr) (order, &A, 1); +#else + S = CXSPARSE_ZNAME (_sqr) (&A, order - 1, 1); +#endif N = CXSPARSE_ZNAME (_qr) (&A, S); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; if (!N) @@ -110,7 +114,11 @@ #ifdef HAVE_CXSPARSE ColumnVector ret(N->L->m); for (octave_idx_type i = 0; i < N->L->m; i++) +#if defined(CS_VER) && (CS_VER >= 2) + ret.xelem(i) = S->pinv[i]; +#else ret.xelem(i) = S->Pinv[i]; +#endif return ret; #else return ColumnVector (); @@ -123,7 +131,11 @@ #ifdef HAVE_CXSPARSE ColumnVector ret(N->L->m); for (octave_idx_type i = 0; i < N->L->m; i++) +#if defined(CS_VER) && (CS_VER >= 2) + ret.xelem(S->pinv[i]) = i; +#else ret.xelem(S->Pinv[i]) = i; +#endif return ret; #else return ColumnVector (); @@ -182,8 +194,13 @@ OCTAVE_QUIT; volatile octave_idx_type nm = (nr < nc ? nr : nc); BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; - CXSPARSE_ZNAME (_ipvec) (b_nr, S->Pinv, bvec + idx, - reinterpret_cast<double _Complex *>(buf)); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_ipvec) + (S->pinv, bvec + idx, reinterpret_cast<double _Complex *>(buf), b_nr); +#else + CXSPARSE_ZNAME (_ipvec) + (b_nr, S->Pinv, bvec + idx, reinterpret_cast<double _Complex *>(buf)); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type i = 0; i < nm; i++) { @@ -238,8 +255,13 @@ for (octave_idx_type j = nr; j < q.S()->m2; j++) buf[j] = OCTAVE_C99_ZERO; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_ipvec) + (q.S()->pinv, reinterpret_cast<double _Complex *>(Xx), buf, nr); +#else CXSPARSE_ZNAME (_ipvec) (nr, q.S()->Pinv, reinterpret_cast<double _Complex *>(Xx), buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = 0; j < nc; j++) { @@ -250,7 +272,11 @@ } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; CXSPARSE_ZNAME (_usolve) (q.N()->U, buf); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_ipvec) (q.S()->q, buf, vec + idx, nc); +#else CXSPARSE_ZNAME (_ipvec) (nc, q.S()->Q, buf, vec + idx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } } @@ -280,8 +306,13 @@ for (octave_idx_type j = nr; j < nbuf; j++) buf[j] = OCTAVE_C99_ZERO; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_pvec) + (q.S()->q, reinterpret_cast<double _Complex *>(Xx), buf, nr); +#else CXSPARSE_ZNAME (_pvec) (nr, q.S()->Q, reinterpret_cast<double _Complex *>(Xx), buf); +#endif CXSPARSE_ZNAME (_utsolve) (q.N()->U, buf); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = nr-1; j >= 0; j--) @@ -294,7 +325,11 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_pvec) (q.S()->pinv, buf, vec + idx, nc); +#else CXSPARSE_ZNAME (_pvec) (nc, q.S()->Pinv, buf, vec + idx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } } @@ -342,8 +377,13 @@ for (octave_idx_type j = nr; j < q.S()->m2; j++) buf[j] = OCTAVE_C99_ZERO; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_ipvec) + (q.S()->pinv, reinterpret_cast<double _Complex *>(Xx), buf, nr); +#else CXSPARSE_ZNAME (_ipvec) (nr, q.S()->Pinv, reinterpret_cast<double _Complex *>(Xx), buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = 0; j < nc; j++) { @@ -354,8 +394,13 @@ } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; CXSPARSE_ZNAME (_usolve) (q.N()->U, buf); - CXSPARSE_ZNAME (_ipvec) (nc, q.S()->Q, buf, - reinterpret_cast<double _Complex *>(Xx)); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_ipvec) + (q.S()->q, buf, reinterpret_cast<double _Complex *>(Xx), nc); +#else + CXSPARSE_ZNAME (_ipvec) + (nc, q.S()->Q, buf, reinterpret_cast<double _Complex *>(Xx)); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = 0; j < nc; j++) @@ -405,8 +450,13 @@ for (octave_idx_type j = nr; j < nbuf; j++) buf[j] = OCTAVE_C99_ZERO; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_pvec) + (q.S()->q, reinterpret_cast<double _Complex *>(Xx), buf, nr); +#else CXSPARSE_ZNAME (_pvec) (nr, q.S()->Q, reinterpret_cast<double _Complex *>(Xx), buf); +#endif CXSPARSE_ZNAME (_utsolve) (q.N()->U, buf); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = nr-1; j >= 0; j--) @@ -418,8 +468,13 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; - CXSPARSE_ZNAME (_pvec) (nc, q.S()->Pinv, buf, - reinterpret_cast<double _Complex *>(Xx)); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_pvec) + (q.S()->pinv, buf, reinterpret_cast<double _Complex *>(Xx), nc); +#else + CXSPARSE_ZNAME (_pvec) + (nc, q.S()->Pinv, buf, reinterpret_cast<double _Complex *>(Xx)); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = 0; j < nc; j++) @@ -485,7 +540,11 @@ for (octave_idx_type j = nr; j < q.S()->m2; j++) buf[j] = OCTAVE_C99_ZERO; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_ipvec) (q.S()->pinv, bvec + bidx, buf, nr); +#else CXSPARSE_ZNAME (_ipvec) (nr, q.S()->Pinv, bvec + bidx, buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = 0; j < nc; j++) { @@ -496,7 +555,11 @@ } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; CXSPARSE_ZNAME (_usolve) (q.N()->U, buf); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_ipvec) (q.S()->q, buf, vec + idx, nc); +#else CXSPARSE_ZNAME (_ipvec) (nc, q.S()->Q, buf, vec + idx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } } @@ -524,7 +587,11 @@ for (octave_idx_type j = nr; j < nbuf; j++) buf[j] = OCTAVE_C99_ZERO; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_pvec) (q.S()->q, bvec + bidx, buf, nr); +#else CXSPARSE_ZNAME (_pvec) (nr, q.S()->Q, bvec + bidx, buf); +#endif CXSPARSE_ZNAME (_utsolve) (q.N()->U, buf); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = nr-1; j >= 0; j--) @@ -536,7 +603,11 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_pvec) (q.S()->pinv, buf, vec + idx, nc); +#else CXSPARSE_ZNAME (_pvec) (nc, q.S()->Pinv, buf, vec + idx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } } @@ -584,8 +655,13 @@ for (octave_idx_type j = nr; j < q.S()->m2; j++) buf[j] = OCTAVE_C99_ZERO; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_ipvec) + (q.S()->pinv, reinterpret_cast<double _Complex *>(Xx), buf, nr); +#else CXSPARSE_ZNAME (_ipvec) (nr, q.S()->Pinv, reinterpret_cast<double _Complex *>(Xx), buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = 0; j < nc; j++) { @@ -596,8 +672,13 @@ } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; CXSPARSE_ZNAME (_usolve) (q.N()->U, buf); - CXSPARSE_ZNAME (_ipvec) (nc, q.S()->Q, buf, - reinterpret_cast<double _Complex *>(Xx)); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_ipvec) + (q.S()->q, buf, reinterpret_cast<double _Complex *>(Xx), nc); +#else + CXSPARSE_ZNAME (_ipvec) + (nc, q.S()->Q, buf, reinterpret_cast<double _Complex *>(Xx)); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = 0; j < nc; j++) @@ -647,8 +728,13 @@ for (octave_idx_type j = nr; j < nbuf; j++) buf[j] = OCTAVE_C99_ZERO; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_pvec) + (q.S()->q, reinterpret_cast<double _Complex *>(Xx), buf, nr); +#else CXSPARSE_ZNAME (_pvec) (nr, q.S()->Q, reinterpret_cast<double _Complex *>(Xx), buf); +#endif CXSPARSE_ZNAME (_utsolve) (q.N()->U, buf); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = nr-1; j >= 0; j--) @@ -660,8 +746,13 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; - CXSPARSE_ZNAME (_pvec) (nc, q.S()->Pinv, buf, - reinterpret_cast<double _Complex *>(Xx)); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_ZNAME (_pvec) + (q.S()->pinv, buf, reinterpret_cast<double _Complex *>(Xx), nc); +#else + CXSPARSE_ZNAME (_pvec) + (nc, q.S()->Pinv, buf, reinterpret_cast<double _Complex *>(Xx)); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = 0; j < nc; j++)
--- a/liboctave/SparseCmplxQR.h +++ b/liboctave/SparseCmplxQR.h @@ -75,9 +75,9 @@ public: SparseComplexQR (void) : - rep (new SparseComplexQR_rep (SparseComplexMatrix(), -1)) { } + rep (new SparseComplexQR_rep (SparseComplexMatrix(), 0)) { } - SparseComplexQR (const SparseComplexMatrix& a, int order = -1) : + SparseComplexQR (const SparseComplexMatrix& a, int order = 0) : rep (new SparseComplexQR_rep (a, order)) { } SparseComplexQR (const SparseComplexQR& a) : rep (a.rep) { rep->count++; }
--- a/liboctave/SparseQR.cc +++ b/liboctave/SparseQR.cc @@ -42,7 +42,12 @@ A.x = const_cast<double *>(a.data ()); A.nz = -1; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; - S = CXSPARSE_DNAME (_sqr) (&A, order, 1); +#if defined(CS_VER) && (CS_VER >= 2) + S = CXSPARSE_DNAME (_sqr) (order, &A, 1); +#else + S = CXSPARSE_DNAME (_sqr) (&A, order - 1, 1); +#endif + N = CXSPARSE_DNAME (_qr) (&A, S); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; if (!N) @@ -99,7 +104,11 @@ #ifdef HAVE_CXSPARSE ColumnVector ret(N->L->m); for (octave_idx_type i = 0; i < N->L->m; i++) +#if defined(CS_VER) && (CS_VER >= 2) + ret.xelem(i) = S->pinv[i]; +#else ret.xelem(i) = S->Pinv[i]; +#endif return ret; #else return ColumnVector (); @@ -112,7 +121,11 @@ #ifdef HAVE_CXSPARSE ColumnVector ret(N->L->m); for (octave_idx_type i = 0; i < N->L->m; i++) +#if defined(CS_VER) && (CS_VER >= 2) + ret.xelem(S->pinv[i]) = i; +#else ret.xelem(S->Pinv[i]) = i; +#endif return ret; #else return ColumnVector (); @@ -174,7 +187,11 @@ buf[i] = 0.; volatile octave_idx_type nm = (nr < nc ? nr : nc); BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (S->pinv, bvec + idx, buf, b_nr); +#else CXSPARSE_DNAME (_ipvec) (b_nr, S->Pinv, bvec + idx, buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type i = 0; i < nm; i++) @@ -211,7 +228,7 @@ ("matrix dimension mismatch in solution of minimum norm problem"); else if (nr >= nc) { - SparseQR q (a, 2); + SparseQR q (a, 3); if (! q.ok ()) { info = -1; @@ -227,7 +244,11 @@ for (octave_idx_type j = nr; j < q.S()->m2; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->pinv, bvec + bidx, buf, nr); +#else CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, bvec + bidx, buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = 0; j < nc; j++) { @@ -238,14 +259,18 @@ } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; CXSPARSE_DNAME (_usolve) (q.N()->U, buf); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, vec + idx, nc); +#else CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, vec + idx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } } else { SparseMatrix at = a.hermitian(); - SparseQR q (at, 2); + SparseQR q (at, 3); if (! q.ok ()) { info = -1; @@ -262,7 +287,11 @@ for (octave_idx_type j = nr; j < nbuf; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->q, bvec + bidx, buf, nr); +#else CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, bvec + bidx, buf); +#endif CXSPARSE_DNAME (_utsolve) (q.N()->U, buf); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = nr-1; j >= 0; j--) @@ -273,7 +302,11 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, vec + idx, nc); +#else CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, vec + idx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } } @@ -301,7 +334,7 @@ ("matrix dimension mismatch in solution of minimum norm problem"); else if (nr >= nc) { - SparseQR q (a, 2); + SparseQR q (a, 3); if (! q.ok ()) { info = -1; @@ -321,7 +354,11 @@ for (octave_idx_type j = nr; j < q.S()->m2; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->pinv, Xx, buf, nr); +#else CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, Xx, buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = 0; j < nc; j++) { @@ -332,7 +369,11 @@ } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; CXSPARSE_DNAME (_usolve) (q.N()->U, buf); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, Xx, nc); +#else CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, Xx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = 0; j < nc; j++) @@ -358,7 +399,7 @@ else { SparseMatrix at = a.hermitian(); - SparseQR q (at, 2); + SparseQR q (at, 3); if (! q.ok ()) { info = -1; @@ -379,7 +420,11 @@ for (octave_idx_type j = nr; j < nbuf; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->q, Xx, buf, nr); +#else CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, Xx, buf); +#endif CXSPARSE_DNAME (_utsolve) (q.N()->U, buf); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = nr-1; j >= 0; j--) @@ -390,7 +435,11 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, Xx, nc); +#else CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, Xx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = 0; j < nc; j++) @@ -437,7 +486,7 @@ ("matrix dimension mismatch in solution of minimum norm problem"); else if (nr >= nc) { - SparseQR q (a, 2); + SparseQR q (a, 3); if (! q.ok ()) { info = -1; @@ -460,7 +509,11 @@ for (octave_idx_type j = nr; j < q.S()->m2; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->pinv, Xx, buf, nr); +#else CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, Xx, buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = 0; j < nc; j++) { @@ -471,11 +524,18 @@ } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; CXSPARSE_DNAME (_usolve) (q.N()->U, buf); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, Xx, nc); +#else CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, Xx); - +#endif for (octave_idx_type j = nr; j < q.S()->m2; j++) buf[j] = 0.; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->pinv, Xz, buf, nr); +#else CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, Xz, buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = 0; j < nc; j++) { @@ -486,7 +546,11 @@ } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; CXSPARSE_DNAME (_usolve) (q.N()->U, buf); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, Xz, nc); +#else CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, Xz); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = 0; j < nc; j++) vec[j+idx] = Complex (Xx[j], Xz[j]); @@ -495,7 +559,7 @@ else { SparseMatrix at = a.hermitian(); - SparseQR q (at, 2); + SparseQR q (at, 3); if (! q.ok ()) { info = -1; @@ -519,7 +583,11 @@ for (octave_idx_type j = nr; j < nbuf; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->q, Xx, buf, nr); +#else CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, Xx, buf); +#endif CXSPARSE_DNAME (_utsolve) (q.N()->U, buf); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = nr-1; j >= 0; j--) @@ -530,12 +598,20 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, Xx, nc); +#else CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, Xx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = nr; j < nbuf; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->q, Xz, buf, nr); +#else CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, Xz, buf); +#endif CXSPARSE_DNAME (_utsolve) (q.N()->U, buf); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = nr-1; j >= 0; j--) @@ -546,7 +622,11 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, Xz, nc); +#else CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, Xz); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = 0; j < nc; j++) vec[j+idx] = Complex (Xx[j], Xz[j]); @@ -576,7 +656,7 @@ ("matrix dimension mismatch in solution of minimum norm problem"); else if (nr >= nc) { - SparseQR q (a, 2); + SparseQR q (a, 3); if (! q.ok ()) { info = -1; @@ -601,7 +681,11 @@ for (octave_idx_type j = nr; j < q.S()->m2; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->pinv, Xx, buf, nr); +#else CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, Xx, buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = 0; j < nc; j++) { @@ -612,12 +696,20 @@ } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; CXSPARSE_DNAME (_usolve) (q.N()->U, buf); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, Xx, nc); +#else CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, Xx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = nr; j < q.S()->m2; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->pinv, Xz, buf, nr); +#else CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, Xz, buf); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = 0; j < nc; j++) { @@ -628,7 +720,11 @@ } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; CXSPARSE_DNAME (_usolve) (q.N()->U, buf); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, Xz, nc); +#else CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, Xz); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = 0; j < nc; j++) @@ -654,7 +750,7 @@ else { SparseMatrix at = a.hermitian(); - SparseQR q (at, 2); + SparseQR q (at, 3); if (! q.ok ()) { info = -1; @@ -680,7 +776,11 @@ for (octave_idx_type j = nr; j < nbuf; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->q, Xx, buf, nr); +#else CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, Xx, buf); +#endif CXSPARSE_DNAME (_utsolve) (q.N()->U, buf); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = nr-1; j >= 0; j--) @@ -691,12 +791,20 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, Xx, nc); +#else CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, Xx); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = nr; j < nbuf; j++) buf[j] = 0.; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->q, Xz, buf, nr); +#else CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, Xz, buf); +#endif CXSPARSE_DNAME (_utsolve) (q.N()->U, buf); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (volatile octave_idx_type j = nr-1; j >= 0; j--) @@ -707,7 +815,11 @@ END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, Xz, nc); +#else CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, Xz); +#endif END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; for (octave_idx_type j = 0; j < nc; j++)
--- a/liboctave/SparseQR.h +++ b/liboctave/SparseQR.h @@ -74,9 +74,9 @@ SparseQR_rep *rep; public: - SparseQR (void) : rep (new SparseQR_rep (SparseMatrix(), -1)) { } + SparseQR (void) : rep (new SparseQR_rep (SparseMatrix(), 0)) { } - SparseQR (const SparseMatrix& a, int order = -1) : + SparseQR (const SparseMatrix& a, int order = 0) : rep (new SparseQR_rep (a, order)) { } SparseQR (const SparseQR& a) : rep (a.rep) { rep->count++; }
--- a/liboctave/sparse-dmsolve.cc +++ b/liboctave/sparse-dmsolve.cc @@ -387,9 +387,15 @@ csm.p = const_cast<octave_idx_type *>(a.cidx ()); csm.i = const_cast<octave_idx_type *>(a.ridx ()); +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_DNAME (d) *dm = CXSPARSE_DNAME(_dmperm) (&csm, 0); + octave_idx_type *p = dm->p; + octave_idx_type *q = dm->q; +#else CXSPARSE_DNAME (d) *dm = CXSPARSE_DNAME(_dmperm) (&csm); octave_idx_type *p = dm->P; octave_idx_type *q = dm->Q; +#endif OCTAVE_LOCAL_BUFFER (octave_idx_type, pinv, nr); for (octave_idx_type i = 0; i < nr; i++) pinv [p [i]] = i;
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2006-05-04 David Bateman <dbateman@free.fr> + + * DLD-FUNCTIONS/sqqr (Fdmperm): Allow compilation with versions + v2.0.0 of CXSparse or later. + 2006-05-04 John W. Eaton <jwe@octave.org> * variables.cc (set_internal_variable): Move here from
--- a/src/DLD-FUNCTIONS/spqr.cc +++ b/src/DLD-FUNCTIONS/spqr.cc @@ -292,19 +292,34 @@ { if (nargout <= 1) { +#if defined(CS_VER) && (CS_VER >= 2) + octave_idx_type *jmatch = CXSPARSE_NAME (_maxtrans) (&csm, 0); +#else octave_idx_type *jmatch = CXSPARSE_NAME (_maxtrans) (&csm); +#endif retval(0) = put_int (jmatch + nr, nc); CXSPARSE_NAME (_free) (jmatch); } else { +#if defined(CS_VER) && (CS_VER >= 2) + CXSPARSE_NAME (d) *dm = CXSPARSE_NAME(_dmperm) (&csm, 0); +#else CXSPARSE_NAME (d) *dm = CXSPARSE_NAME(_dmperm) (&csm); +#endif //retval(5) = put_int (dm->rr, 5); //retval(4) = put_int (dm->cc, 5); +#if defined(CS_VER) && (CS_VER >= 2) + retval(3) = put_int (dm->s, dm->nb+1); + retval(2) = put_int (dm->r, dm->nb+1); + retval(1) = put_int (dm->q, nc); + retval(0) = put_int (dm->p, nr); +#else retval(3) = put_int (dm->S, dm->nb+1); retval(2) = put_int (dm->R, dm->nb+1); retval(1) = put_int (dm->Q, nc); retval(0) = put_int (dm->P, nr); +#endif CXSPARSE_NAME (_dfree) (dm); } }