File: spsym.c

package info (click to toggle)
suitesparse 1%3A5.12.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 176,720 kB
  • sloc: ansic: 1,193,914; cpp: 31,704; makefile: 6,638; fortran: 1,927; java: 1,826; csh: 765; ruby: 725; sh: 529; python: 333; perl: 225; sed: 164; awk: 35
file content (99 lines) | stat: -rw-r--r-- 3,179 bytes parent folder | download | duplicates (4)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* ========================================================================== */
/* === CHOLMOD/MATLAB/spsym mexFunction ===================================== */
/* ========================================================================== */

/* -----------------------------------------------------------------------------
 * CHOLMOD/MATLAB Module.  Copyright (C) 2005-2006, Timothy A. Davis
 * http://www.suitesparse.com
 * MATLAB(tm) is a Trademark of The MathWorks, Inc.
 * -------------------------------------------------------------------------- */

/* [result xmatched pmatched nzoffdiag nzdiag] = spsym (A, quick).
 * See the spsym.m file for a description of what it computes.
 */

#include "cholmod_matlab.h"

void mexFunction
(
    int	nargout,
    mxArray *pargout [ ],
    int	nargin,
    const mxArray *pargin [ ]
)
{
    double dummy = 0 ;
    cholmod_sparse Amatrix, *A ;
    cholmod_common Common, *cm ;
    Long result, quick, option, xmatched, pmatched, nzoffdiag, nzdiag ;

    /* ---------------------------------------------------------------------- */
    /* start CHOLMOD and set parameters */ 
    /* ---------------------------------------------------------------------- */

    cm = &Common ;
    cholmod_l_start (cm) ;
    sputil_config (SPUMONI, cm) ;

    /* ---------------------------------------------------------------------- */
    /* get inputs */
    /* ---------------------------------------------------------------------- */

    if (nargin > 2 || nargin < 1 || nargout > 5)
    {
	mexErrMsgTxt ("usage: [s xmatch pmatch nzoff nzd] = spsym (A,quick)") ;
    }
    if (!mxIsSparse (pargin [0]))
    {
    	mexErrMsgTxt ("A must be sparse and double") ;
    }

    /* get sparse matrix A */
    A = sputil_get_sparse (pargin [0], &Amatrix, &dummy, 0) ;

    /* get the "quick" parameter */
    quick = (nargin > 1) ? (mxGetScalar (pargin [1]) != 0) : FALSE ;

    if (nargout > 1)
    {
	option = 2 ;
    }
    else if (quick)
    {
	option = 0 ;
    }
    else
    {
	option = 1 ;
    }

    /* ---------------------------------------------------------------------- */
    /* determine symmetry */
    /* ---------------------------------------------------------------------- */

    xmatched = 0 ;
    pmatched = 0 ;
    nzoffdiag = 0 ;
    nzdiag = 0 ;

    result = cholmod_l_symmetry (A, option, &xmatched, &pmatched, &nzoffdiag,
	&nzdiag, cm) ;

    /* ---------------------------------------------------------------------- */
    /* return results to MATLAB */
    /* ---------------------------------------------------------------------- */

    pargout [0] = sputil_put_int (&result, 1, 0) ;

    if (nargout > 1) pargout [1] = sputil_put_int (&xmatched, 1, 0) ;
    if (nargout > 2) pargout [2] = sputil_put_int (&pmatched, 1, 0) ;
    if (nargout > 3) pargout [3] = sputil_put_int (&nzoffdiag, 1, 0) ;
    if (nargout > 4) pargout [4] = sputil_put_int (&nzdiag, 1, 0) ;

    /* ---------------------------------------------------------------------- */
    /* free workspace */
    /* ---------------------------------------------------------------------- */

    cholmod_l_finish (cm) ;
    cholmod_l_print_common (" ", cm) ;
}