# HG changeset patch # User Jason Riedy # Date 1236736474 14400 # Node ID 02034a30a13a1a962fff2ca9b7fc055657f57140 # Parent 43aec7c168ebb25b08ce5ae985f4d084822df435 Make the column permutation vector in sparse LU cols()-long. diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2009-03-10 Jason Riedy + + * sparse-base-lu.cc (Pc_vec): The column permutation should be + Ufact.cols ()-long, not Lfact.rows ()-long. + 2009-03-10 Jason Riedy * dSparse.cc (SparseMatrix::SparseMatrix (const PermMatrix&)): diff --git a/liboctave/sparse-base-lu.cc b/liboctave/sparse-base-lu.cc --- a/liboctave/sparse-base-lu.cc +++ b/liboctave/sparse-base-lu.cc @@ -121,11 +121,11 @@ sparse_base_lu :: Pc_vec (void) const { - octave_idx_type nr = Lfact.rows (); + octave_idx_type nc = Ufact.cols (); - ColumnVector Pout (nr); + ColumnVector Pout (nc); - for (octave_idx_type i = 0; i < nr; i++) + for (octave_idx_type i = 0; i < nc; i++) Pout.xelem (i) = static_cast (Q(i) + 1); return Pout; diff --git a/test/ChangeLog b/test/ChangeLog --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2009-03-10 Jason Riedy + + * build_sparse_tests.sh: Add LU tests to the rectangular tests. + 2009-03-10 Jason Riedy * test_diag_perm.m: Add a test for conversion to sparse form. diff --git a/test/build_sparse_tests.sh b/test/build_sparse_tests.sh --- a/test/build_sparse_tests.sh +++ b/test/build_sparse_tests.sh @@ -665,8 +665,8 @@ %! assert(j-i>=0); %!testif HAVE_UMFPACK ;# LU with vector permutations -%! [L,U,P] = lu(bs,'vector'); -%! assert(L(P,:)*U,bs,1e-10); +%! [L,U,P,Q] = lu(bs,'vector'); +%! assert(L(P,:)*U(:,Q),bs,1e-10); %! # triangularity %! [i,j,v]=find(L); %! assert(i-j>=0); @@ -745,6 +745,48 @@ # gen_divop_tests # Disable rectangular \ and / for now gen_matrixdiag_tests gen_matrixreshape_tests + cat >>$TESTS <=0); +%! [i,j,v]=find(U); +%! assert(j-i>=0); + +%!testif HAVE_UMFPACK ;# simple LU + row/col permutations +%! [L,U,P,Q] = lu(bs); +%! assert(P'*L*U*Q',bs,1e-10); +%! # triangularity +%! [i,j,v]=find(L); +%! assert(i-j>=0); +%! [i,j,v]=find(U); +%! assert(j-i>=0); + +%!testif HAVE_UMFPACK ;# LU with vector permutations +%! [L,U,P,Q] = lu(bs,'vector'); +%! assert(L(P,:)*U(:,Q),bs,1e-10); +%! # triangularity +%! [i,j,v]=find(L); +%! assert(i-j>=0); +%! [i,j,v]=find(U); +%! assert(j-i>=0); + +%!testif HAVE_UMFPACK ;# LU with scaling +%! [L,U,P,Q,R] = lu(bs); +%! assert(R*P'*L*U*Q',bs,1e-10); +%! # triangularity +%! [i,j,v]=find(L); +%! assert(i-j>=0); +%! [i,j,v]=find(U); +%! assert(j-i>=0); + +EOF }