Skip to content

Commit

Permalink
maint: Merge default to bytecode-interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
arungiridhar committed Dec 11, 2024
2 parents dc3a8dc + b2224b4 commit 10e9946
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 56 deletions.
3 changes: 3 additions & 0 deletions etc/NEWS.10.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ Summary of important user-visible changes for version 10 (yyyy-mm-dd):
"median" to allow the user to select which option to use. This property
should not be expected to function in code used outside of Octave.

- `symbfact`: outputs `count`, `parent`, and `post` are now row vectors rather
than column vectors.

### Alphabetical list of new functions added in Octave 10

* `clim`
Expand Down
49 changes: 27 additions & 22 deletions libinterp/corefcn/qr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -801,21 +801,26 @@ orthogonal basis of @code{span (A)}.
%! assert (qr (sparse (0, 1)), sparse (0, 1))
%!test <*66488>
%! ## Orientation of 'p' output
%! ## Orientation of 'p' output for dense matrices
%! [q, r, p] = qr (eye (3));
%! assert (size (p), [3, 3]);
%! [q, r, p] = qr (speye (3));
%! assert (size (p), [3, 3]);
%! [q, r, p] = qr (eye (3), 'vector');
%! assert (size (p), [1, 3]);
%! [q, r, p] = qr (speye (3), 'vector');
%! assert (size (p), [1, 3]);
%! [q, r, p] = qr (eye (3), 'econ');
%! assert (size (p), [3, 3]);
%! [q, r, p] = qr (speye (3), 'econ');
%! assert (size (p), [3, 3]);
%! [q, r, p] = qr (eye (3), 0);
%! assert (size (p), [1, 3]);
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE") <*66488>
%! ## Orientation of 'p' output for sparse matrices
%! [q, r, p] = qr (speye (3));
%! assert (size (p), [3, 3]);
%! [q, r, p] = qr (speye (3), 'vector');
%! assert (size (p), [1, 3]);
%!testif HAVE_SPQR, HAVE_CHOLMOD
%! [q, r, p] = qr (speye (3), 'econ');
%! assert (size (p), [3, 3]);
%! [q, r, p] = qr (speye (3), 0);
%! assert (size (p), [1, 3]);
Expand Down Expand Up @@ -1069,7 +1074,7 @@ orthogonal basis of @code{span (A)}.
%! rand ("state", 42);
%! randn ("state", 42);
%! a = sprandn (n,n,d) + speye (n,n);
%! [c,r] = qr (a, ones (n,1));
%! [c, r] = qr (a, ones (n,1));
%! assert (r\c, full (a)\ones (n,1), 10e-10);
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
Expand All @@ -1079,7 +1084,7 @@ orthogonal basis of @code{span (A)}.
%! randn ("state", 42);
%! a = sprandn (n,n,d) + speye (n,n);
%! b = randn (n,2);
%! [c,r] = qr (a, b);
%! [c, r] = qr (a, b);
%! assert (r\c, full (a)\b, 10e-10);
## Test under-determined systems!!
Expand All @@ -1090,7 +1095,7 @@ orthogonal basis of @code{span (A)}.
%! randn ("state", 42);
%! a = sprandn (n,n+1,d) + speye (n,n+1);
%! b = randn (n,2);
%! [c,r] = qr (a, b);
%! [c, r] = qr (a, b);
%! assert (r\c, full (a)\b, 10e-10);
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
Expand Down Expand Up @@ -1119,7 +1124,7 @@ orthogonal basis of @code{span (A)}.
%! rand ("state", 42);
%! randn ("state", 42);
%! a = 1i* sprandn (n,n,d) + speye (n,n);
%! [c,r] = qr (a, ones (n,1));
%! [c, r] = qr (a, ones (n,1));
%! assert (r\c, full (a)\ones (n,1), 10e-10);
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
Expand All @@ -1129,7 +1134,7 @@ orthogonal basis of @code{span (A)}.
%! randn ("state", 42);
%! a = 1i* sprandn (n,n,d) + speye (n,n);
%! b = randn (n,2);
%! [c,r] = qr (a, b);
%! [c, r] = qr (a, b);
%! assert (r\c, full (a)\b, 10e-10);
## Test under-determined systems!!
Expand All @@ -1143,7 +1148,7 @@ orthogonal basis of @code{span (A)}.
%! [c, r] = qr (a, b);
%! assert (r\c, full (a)\b, 10e-10);
%!testif HAVE_SPQR, HAVE_CHOLMOD
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
%! n = 12; m = 20; d = 0.2;
%! ## initialize generators to make behavior reproducible
%! rand ("state", 42);
Expand All @@ -1164,7 +1169,7 @@ orthogonal basis of @code{span (A)}.
%! [c2, r2] = qr (full (a), full (b), 0);
%! assert (r\c, r2\c2, 10e-10);
%!testif HAVE_SPQR, HAVE_CHOLMOD
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
%! n = 12; m = 20; d = 0.2;
%! ## initialize generators to make behavior reproducible
%! rand ("state", 42);
Expand All @@ -1177,7 +1182,7 @@ orthogonal basis of @code{span (A)}.
%! x2 = r2 \ c2;
%! assert (x, x2, 10e-10);
%!testif HAVE_SPQR, HAVE_CHOLMOD
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
%! n = 12; m = 20; d = 0.2;
%! ## initialize generators to make behavior reproducible
%! rand ("state", 42);
Expand All @@ -1186,7 +1191,7 @@ orthogonal basis of @code{span (A)}.
%! [q, r, p] = qr (a, "matrix");
%! assert (q * r, a * p, 10e-10);
%!testif HAVE_SPQR, HAVE_CHOLMOD
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
%! n = 12; m = 20; d = 0.2;
%! ## initialize generators to make behavior reproducible
%! rand ("state", 42);
Expand All @@ -1197,7 +1202,7 @@ orthogonal basis of @code{span (A)}.
%! [c2, r2] = qr (full (a), b);
%! assert (x, r2\c2, 10e-10);
%!testif HAVE_SPQR, HAVE_CHOLMOD
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
%! n = 12; m = 20; d = 0.2;
%! ## initialize generators to make behavior reproducible
%! rand ("state", 42);
Expand All @@ -1208,7 +1213,7 @@ orthogonal basis of @code{span (A)}.
%! [c2, r2] = qr (full (a), b);
%! assert (x, r2\c2, 10e-10);
%!#testif HAVE_SPQR, HAVE_CHOLMOD
%!#testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
%! n = 12; m = 20; d = 0.2;
%! ## initialize generators to make behavior reproducible
%! rand ("state", 42);
Expand All @@ -1219,7 +1224,7 @@ orthogonal basis of @code{span (A)}.
%! [c2, r2] = qr (full (a), b);
%! assert (r\c, r2\c2, 10e-10);
%!testif HAVE_SPQR, HAVE_CHOLMOD
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
%! n = 12; m = 20; d = 0.2;
%! ## initialize generators to make behavior reproducible
%! rand ("state", 42);
Expand All @@ -1243,7 +1248,7 @@ orthogonal basis of @code{span (A)}.
%! [c2, r2] = qr (full (a), full (b), 0);
%! assert (r\c, r2\c2, 10e-10);
%!testif HAVE_SPQR, HAVE_CHOLMOD
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
%! n = 12; m = 20; d = 0.2;
%! ## initialize generators to make behavior reproducible
%! rand ("state", 42);
Expand All @@ -1256,7 +1261,7 @@ orthogonal basis of @code{span (A)}.
%! x2 = r2 \ c2;
%! assert(x, x2, 10e-10);
%!testif HAVE_SPQR, HAVE_CHOLMOD
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
%! n = 12; m = 20; d = 0.2;
%! ## initialize generators to make behavior reproducible
%! rand ("state", 42);
Expand All @@ -1265,7 +1270,7 @@ orthogonal basis of @code{span (A)}.
%! [q, r, p] = qr (a, "matrix");
%! assert(q * r, a * p, 10e-10);
%!testif HAVE_SPQR, HAVE_CHOLMOD
%!testif ; (__have_feature__ ("SPQR") && __have_feature__ ("CHOLMOD")) || __have_feature__ ("CXSPARSE")
%! n = 12; m = 20; d = 0.2;
%! ## initialize generators to make behavior reproducible
%! rand ("state", 42);
Expand Down
11 changes: 5 additions & 6 deletions libinterp/corefcn/symbfact.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include "CSparse.h"
#include "boolSparse.h"
#include "dColVector.h"
#include "dRowVector.h"
#include "dSparse.h"
#include "oct-locbuf.h"
#include "oct-sparse.h"
Expand Down Expand Up @@ -249,7 +249,7 @@ Cholesky@tie{}factorization as determined by @var{typ}.

CHOLMOD_NAME(etree) (Aup, Parent, cm);

ColumnVector tmp (n); // Declaration must precede any goto cleanup.
RowVector tmp (n); // Declaration must precede any goto cleanup.
std::string err_msg;

if (cm->status < CHOLMOD_OK)
Expand Down Expand Up @@ -403,9 +403,9 @@ Cholesky@tie{}factorization as determined by @var{typ}.
%!testif HAVE_CHOLMOD
%! A = sparse (magic (3));
%! [count, h, parent, post, r] = symbfact (A);
%! assert (count, [3; 2; 1]);
%! assert (count, [3, 2, 1]);
%! assert (h, 3);
%! assert (parent, [2; 3; 0]);
%! assert (parent, [2, 3, 0]);
%! assert (r, sparse (triu (true (3))));
%!testif HAVE_CHOLMOD
Expand All @@ -427,8 +427,7 @@ Cholesky@tie{}factorization as determined by @var{typ}.
%! fail ("symbfact (sparse (1), {1})", "TYP must be a string");
%! fail ("symbfact (sparse (1), 'foobar')", 'unrecognized TYP "foobar"');
%! fail ("symbfact (sparse (1), 'sym', {'L'})", "MODE must be a string");
%! fail ('symbfact (sparse (1), "sym", "foobar")',
%! 'unrecognized MODE "foobar"');
%! fail ('symbfact (sparse (1), "sym", "foobar")','unrecognized MODE "foobar"');
%! fail ("symbfact (sparse ([1, 2; 3, 4; 5, 6]))", "S must be a square matrix");
*/
Expand Down
13 changes: 13 additions & 0 deletions liboctave/numeric/sparse-qr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,19 @@ sparse_qr<SPARSE_T>::sparse_qr_rep::E () const

return ret;

#elif defined (HAVE_CXSPARSE)

ColumnVector ret (ncols);

if (S->q)
for (octave_idx_type i = 0; i < ncols; i++)
ret(i) = from_suitesparse_long (S->q[i]) + 1;
else
for (octave_idx_type i = 0; i < ncols; i++)
ret(i) = i + 1;

return ret;

#else

return ColumnVector ();
Expand Down
3 changes: 3 additions & 0 deletions liboctave/numeric/sparse-qr.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class sparse_qr
#if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
// order = 7 selects SPQR default ordering
OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 7);
#elif defined (HAVE_CXSPARSE)
// order = 3 selects CXSparse default ordering
OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 3);
#else
OCTAVE_API sparse_qr (const SPARSE_T& a, int order = 0);
#endif
Expand Down
Loading

0 comments on commit 10e9946

Please sign in to comment.