# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1344974083 14400 # Node ID 82d51d6e470c23c748a53a6fd8b82c3d5e7e1614 # Parent 0b29c16a264553cb88ed2ae001d21c57b1928e5f Proceed with the sparse Choleski computation when requested (bug #37095) * chol.cc (Fchol): Pass nargout in the info paramter to the sparse Choleski objects. * sparse-base-chol.h (sparse_base_chol_rep::sparse_base_chol_rep): Pass the info (=nargout) paramter to the init function. (sparse_base_chol_rep::init): New nargout parameter * sparse-base-chol.cc (sparse_base_chol_rep::init): Also check for nargout to decide if should proceed with the cholmod computations or not. * sparse-util.cc (SparseCholError): Don't warn about CHOLMOD_NOT_POSDEF. diff --git a/liboctave/sparse-base-chol.cc b/liboctave/sparse-base-chol.cc --- a/liboctave/sparse-base-chol.cc +++ b/liboctave/sparse-base-chol.cc @@ -80,7 +80,7 @@ template octave_idx_type sparse_base_chol::sparse_base_chol_rep::init - (const chol_type& a, bool natural) + (const chol_type& a, bool natural, octave_idx_type nargout) { volatile octave_idx_type info = 0; #ifdef HAVE_CHOLMOD @@ -170,7 +170,7 @@ is_pd = cm->status == CHOLMOD_OK; info = (is_pd ? 0 : cm->status); - if (is_pd) + if (is_pd || nargout > 1) { BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; cond = CHOLMOD_NAME(rcond) (Lfactor, cm); diff --git a/liboctave/sparse-base-chol.h b/liboctave/sparse-base-chol.h --- a/liboctave/sparse-base-chol.h +++ b/liboctave/sparse-base-chol.h @@ -53,7 +53,7 @@ : count (1), Lsparse (0), Common (), is_pd (false), minor_p (0), perms (), cond (0) { - info = init (a, natural); + info = init (a, natural, info); } ~sparse_base_chol_rep (void) @@ -93,7 +93,8 @@ double cond; - octave_idx_type init (const chol_type& a, bool natural = true); + octave_idx_type init (const chol_type& a, bool natural = true, + octave_idx_type nargout = 1); void drop_zeros (const cholmod_sparse* S); @@ -113,12 +114,16 @@ sparse_base_chol_rep (const chol_type& a, const bool natural) : count (1), is_pd (false), minor_p (0), perms (), cond (0) - { init (a, natural); } + { + init (a, natural); + } sparse_base_chol_rep (const chol_type& a, octave_idx_type& info, const bool natural) : count (1), is_pd (false), minor_p (0), perms (), cond (0) - { info = init (a, natural); } + { + info = init (a, natural, info); + } ~sparse_base_chol_rep (void) { } @@ -143,7 +148,8 @@ double cond; - octave_idx_type init (const chol_type& a, bool natural = true); + octave_idx_type init (const chol_type& a, bool natural = true, + octave_idx_type nargout = 0); // No copying! diff --git a/liboctave/sparse-util.cc b/liboctave/sparse-util.cc --- a/liboctave/sparse-util.cc +++ b/liboctave/sparse-util.cc @@ -28,6 +28,7 @@ #include #include #include "lo-error.h" +#include "oct-sparse.h" #include "sparse-util.h" // FIXME this overload is here due to API change in SuiteSparse (3.1 -> 3.2) @@ -40,10 +41,15 @@ void SparseCholError (int status, const char *file, int line, const char *message) { - (*current_liboctave_warning_handler)("warning %i, at line %i in file %s", - status, line, file); + // Ignore CHOLMOD_NOT_POSDEF, since we handle that in Fchol as an + // error or exit status. + if (status != CHOLMOD_NOT_POSDEF) + { + (*current_liboctave_warning_handler)("warning %i, at line %i in file %s", + status, line, file); - (*current_liboctave_warning_handler)(message); + (*current_liboctave_warning_handler)(message); + } } int diff --git a/src/dldfcn/chol.cc b/src/dldfcn/chol.cc --- a/src/dldfcn/chol.cc +++ b/src/dldfcn/chol.cc @@ -197,7 +197,7 @@ if (! error_state) { - octave_idx_type info; + octave_idx_type info = nargout; SparseCHOL fact (m, info, natural); if (nargout == 3) { @@ -225,7 +225,7 @@ if (! error_state) { - octave_idx_type info; + octave_idx_type info = nargout; SparseComplexCHOL fact (m, info, natural); if (nargout == 3)