1
c=======================================================================
2
c=== RBio/RBtype_mex_64 ================================================
3
c=======================================================================
5
c RBio: a MATLAB toolbox for reading and writing sparse matrices in
6
c Rutherford/Boeing format.
7
c Copyright (c) 2007, Timothy A. Davis, Univ. of Florida
10
c-----------------------------------------------------------------------
12
c-----------------------------------------------------------------------
14
c [mtype mkind skind] = RBtype (A)
16
c A: a sparse matrix. Determines the Rutherford/Boeing type of the
17
c matrix. Very little memory is used (just size(A,2) integer
18
c workspace), so this can succeed where a test such as nnz(A-A')==0
21
c mkind: r: (0), A is real, and not binary
23
c c: (2), A is complex
24
c i: (3), A is integer
26
c skind: r: (-1), A is rectangular
27
c u: (0), A is unsymmetric (not S, H, Z, below)
28
c s: (1), A is symmetric (nnz(A-A.') is 0)
29
c h: (2), A is Hermitian (nnz(A-A') is 0)
30
c z: (3), A is skew symmetric (nnz(A+A.') is 0)
32
c mtype is a 3-character string, where mtype(1) is the mkind
33
c ('r', 'p', 'c', or 'i'). mtype(2) is the skind ('r', 'u', 's', 'h',
34
c or 'z'), and mtype(3) is always 'a'.
35
c-----------------------------------------------------------------------
37
subroutine mexfunction (nargout, pargout, nargin, pargin)
39
$ pargout (*), pargin (*)
40
integer*4 nargout, nargin
42
c ----------------------------------------------------------------
44
c ----------------------------------------------------------------
46
integer*4 mxClassIDFromClassName,
47
$ mxIsClass, mxIsSparse, mxIsComplex
50
$ mxGetM, mxGetN, mxGetJc, mxGetIr, mxGetPr, mxGetPi,
51
$ mxGetData, mxCreateNumericMatrix, mxCreateDoubleScalar,
54
c ----------------------------------------------------------------
56
c ----------------------------------------------------------------
59
$ nrow, ncol, nnz, mkind, cp, skind, cmplex, cpmat,
60
$ Ap, Ai, Ax, Az, kmin, kmax, one
61
integer*4 iclass, wcmplex
65
c ----------------------------------------------------------------
67
c ----------------------------------------------------------------
69
if (nargin .ne. 1 .or. nargout .gt. 3) then
70
call mexErrMsgTxt ('[mtype mkind skind] = RBtype (A)')
73
c ----------------------------------------------------------------
75
c ----------------------------------------------------------------
77
if (mxIsClass (pargin (1), 'double') .ne. 1 .or.
78
$ mxIsSparse (pargin (1)) .ne. 1) then
79
call mexErrMsgTxt ('A must be sparse and double')
81
cmplex = mxIsComplex (pargin (1))
82
Ap = mxGetJc (pargin (1))
83
Ai = mxGetIr (pargin (1))
84
Ax = mxGetPr (pargin (1))
85
Az = mxGetPi (pargin (1))
86
nrow = mxGetM (pargin (1))
87
ncol = mxGetN (pargin (1))
89
c ----------------------------------------------------------------
91
c ----------------------------------------------------------------
93
iclass = mxClassIDFromClassName ('int64')
96
cpmat = mxCreateNumericMatrix (ncol+1, one, iclass, wcmplex)
97
cp = mxGetData (cpmat)
99
c ----------------------------------------------------------------
100
c determine the mtype of A
101
c ----------------------------------------------------------------
103
call RBkind (nrow, ncol, %val(Ap), %val(Ai), %val(Ax),
104
$ %val(Az), cmplex, mkind, skind, mtype, nnz, %val(cp),
107
c ----------------------------------------------------------------
109
c ----------------------------------------------------------------
111
pargout (1) = mxCreateString (mtype)
112
if (nargout .ge. 2) then
114
pargout (2) = mxCreateDoubleScalar (t)
116
if (nargout .ge. 3) then
118
pargout (3) = mxCreateDoubleScalar (t)
121
c ----------------------------------------------------------------
123
c ----------------------------------------------------------------
125
call mxDestroyArray (%val (cpmat))