~logan/ubuntu/trusty/suitesparse/4.2.1-3ubuntu1

« back to all changes in this revision

Viewing changes to SPQR/MATLAB/spqr_mx_error.c

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2009-02-24 11:08:12 UTC
  • mfrom: (7.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090224110812-hawvr3dh5kjbvlae
debian/control: Add an epoch to the version number of
libsuitesparse-3.0.2 in replaces/conflicts for libcolamd-3.2.0
(really, closes: #516725)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ========================================================================== */
 
2
/* === spqr_mx_error ======================================================== */
 
3
/* ========================================================================== */
 
4
 
 
5
/* Compile with gcc, not g++.  This is called by the CHOLMOD error handler,
 
6
 * which is itself in C.  A global variable is used for spumoni because the
 
7
 * parameter signature of this function cannot be changed; it is passed as
 
8
 * a function pointer to the CHOLMOD error handler.
 
9
 *
 
10
 *  errors:
 
11
 *
 
12
 *      CHOLMOD_TOO_LARGE       MATLAB:pmaxsize     problem too large
 
13
 *      CHOLMOD_OUT_OF_MEMORY   MATLAB:nomem        out of memory
 
14
 *      CHOLMOD_INVALID         MATLAB:internal     invalid option
 
15
 *      CHOLMOD_NOT_INSTALLED   MATLAB:internal     internal error
 
16
 *
 
17
 *  warnings:  these are not used by SuiteSparseQR.  They can only come from
 
18
 *  CHOLMOD, but they do not apply to SuiteSparseQR.
 
19
 *
 
20
 *      CHOLMOD_NOT_POSDEF      matrix not positive definite (for chol)
 
21
 *      CHOLMOD_DSMALL          diagonal too small (for LDL')
 
22
 */
 
23
 
 
24
#include "mex.h"
 
25
#include "cholmod.h"
 
26
 
 
27
int spqr_spumoni = 0 ;
 
28
 
 
29
void spqr_mx_error (int status, const char *file, int line, const char *msg)
 
30
{
 
31
 
 
32
    if (spqr_spumoni > 0 ||
 
33
        !(status == CHOLMOD_OUT_OF_MEMORY || status == CHOLMOD_TOO_LARGE))
 
34
    {
 
35
        mexPrintf ("ERROR: %s line %d, status %d: %s\n",
 
36
            file, line, status, msg) ;
 
37
    }
 
38
 
 
39
    if (status < CHOLMOD_OK)
 
40
    {
 
41
        switch (status)
 
42
        {
 
43
            case CHOLMOD_OUT_OF_MEMORY:
 
44
                mexErrMsgIdAndTxt ("MATLAB:nomem",
 
45
                "Out of memory. Type HELP MEMORY for your options.") ;
 
46
 
 
47
            case CHOLMOD_TOO_LARGE:
 
48
                mexErrMsgIdAndTxt ("MATLAB:pmaxsize", 
 
49
                "Maximum variable size allowed by the program is exceeded.") ;
 
50
                break ;
 
51
 
 
52
            default:
 
53
                /* CHOLMOD_NOT_INSTALLED and CHOLMOD_INVALID:
 
54
                   These errors should be caught by the mexFunction interface
 
55
                   to SuiteSparseQR, not by the CHOLMOD or SuiteSparseQR
 
56
                   internal code itself */
 
57
                mexErrMsgIdAndTxt ("MATLAB:internal", "Internal error") ;
 
58
                break ;
 
59
        }            
 
60
    }
 
61
    else
 
62
    {
 
63
        /* A CHOMOD warning is not used by SuiteSparseQR at all.  Thus, it is
 
64
           reported here as an internal error rather than as a warning. */
 
65
        /* mexWarnMsgTxt (msg) ; */
 
66
        mexErrMsgIdAndTxt ("MATLAB:internal", "Internal error") ;
 
67
    }
 
68
}