File: spqr_mx_error.c

package info (click to toggle)
suitesparse 1%3A4.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 74,020 kB
  • ctags: 12,092
  • sloc: ansic: 146,148; cpp: 17,776; makefile: 5,777; fortran: 1,927; java: 1,846; csh: 749; ruby: 725; perl: 225; sed: 164; awk: 27; sh: 18
file content (68 lines) | stat: -rw-r--r-- 2,521 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* ========================================================================== */
/* === spqr_mx_error ======================================================== */
/* ========================================================================== */

/* Compile with gcc, not g++.  This is called by the CHOLMOD error handler,
 * which is itself in C.  A global variable is used for spumoni because the
 * parameter signature of this function cannot be changed; it is passed as
 * a function pointer to the CHOLMOD error handler.
 *
 *  errors:
 *
 *      CHOLMOD_TOO_LARGE       MATLAB:pmaxsize     problem too large
 *      CHOLMOD_OUT_OF_MEMORY   MATLAB:nomem        out of memory
 *      CHOLMOD_INVALID         MATLAB:internal     invalid option
 *      CHOLMOD_NOT_INSTALLED   MATLAB:internal     internal error
 *
 *  warnings:  these are not used by SuiteSparseQR.  They can only come from
 *  CHOLMOD, but they do not apply to SuiteSparseQR.
 *
 *      CHOLMOD_NOT_POSDEF      matrix not positive definite (for chol)
 *      CHOLMOD_DSMALL          diagonal too small (for LDL')
 */

#include "mex.h"
#include "cholmod.h"

int spqr_spumoni = 0 ;

void spqr_mx_error (int status, const char *file, int line, const char *msg)
{

    if (spqr_spumoni > 0 ||
        !(status == CHOLMOD_OUT_OF_MEMORY || status == CHOLMOD_TOO_LARGE))
    {
        mexPrintf ("ERROR: %s line %d, status %d: %s\n",
            file, line, status, msg) ;
    }

    if (status < CHOLMOD_OK)
    {
        switch (status)
        {
            case CHOLMOD_OUT_OF_MEMORY:
	        mexErrMsgIdAndTxt ("MATLAB:nomem",
                "Out of memory. Type HELP MEMORY for your options.") ;

            case CHOLMOD_TOO_LARGE:
	        mexErrMsgIdAndTxt ("MATLAB:pmaxsize", 
                "Maximum variable size allowed by the program is exceeded.") ;
                break ;

            default:
                /* CHOLMOD_NOT_INSTALLED and CHOLMOD_INVALID:
                   These errors should be caught by the mexFunction interface
                   to SuiteSparseQR, not by the CHOLMOD or SuiteSparseQR
                   internal code itself */
	        mexErrMsgIdAndTxt ("MATLAB:internal", "Internal error") ;
                break ;
        }            
    }
    else
    {
        /* A CHOMOD warning is not used by SuiteSparseQR at all.  Thus, it is
           reported here as an internal error rather than as a warning. */
	/* mexWarnMsgTxt (msg) ; */
        mexErrMsgIdAndTxt ("MATLAB:internal", "Internal error") ;
    }
}