Mercurial > hg > octave-terminal
changeset 15185:82d51d6e470c
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.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Tue, 14 Aug 2012 15:54:43 -0400 |
parents | 0b29c16a2645 |
children | 3a33f93c9e62 |
files | liboctave/sparse-base-chol.cc liboctave/sparse-base-chol.h liboctave/sparse-util.cc src/dldfcn/chol.cc |
diffstat | 4 files changed, 24 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/sparse-base-chol.cc +++ b/liboctave/sparse-base-chol.cc @@ -80,7 +80,7 @@ template <class chol_type, class chol_elt, class p_type> octave_idx_type sparse_base_chol<chol_type, chol_elt, p_type>::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);
--- 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!
--- a/liboctave/sparse-util.cc +++ b/liboctave/sparse-util.cc @@ -28,6 +28,7 @@ #include <stdio.h> #include <stdarg.h> #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
--- 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)