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

« back to all changes in this revision

Viewing changes to CXSparse_newfiles/MATLAB/Test/cs_pvec_mex.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2007-05-29 09:36:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529093629-zowquo0b7slkk6nc
Tags: 3.0.0-2
* suitesparse builds properly twice in a row
* Bug fix: "suitesparse - FTBFS: Broken build depens: libgfortran1-dev",
  thanks to Bastian Blank (Closes: #426349).
* Bug fix: "suitesparse_3.0.0-1: FTBFS: build-depends on
  libgfortran1-dev", thanks to Steve Langasek (Closes: #426354).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "cs_mex.h"
 
2
/* x = b(p) */
 
3
void mexFunction
 
4
(
 
5
    int nargout,
 
6
    mxArray *pargout [ ],
 
7
    int nargin,
 
8
    const mxArray *pargin [ ]
 
9
)
 
10
{
 
11
    CS_INT n, k, *p ;
 
12
    double *xx ;
 
13
    if (nargout > 1 || nargin != 2)
 
14
    {
 
15
        mexErrMsgTxt ("Usage: x = cs_pvec(b,p)") ;
 
16
    }
 
17
    n = mxGetNumberOfElements (pargin [0]) ;
 
18
    if (n != mxGetNumberOfElements (pargin [1]))
 
19
    {
 
20
        mexErrMsgTxt ("b or p wrong size") ;
 
21
    }
 
22
 
 
23
    xx = mxGetPr (pargin [1]) ;
 
24
    p = cs_dl_malloc (n, sizeof (CS_INT)) ;
 
25
    for (k = 0 ; k < n ; k++) p [k] = xx [k] - 1 ;
 
26
 
 
27
    if (mxIsComplex (pargin [0]))
 
28
    {
 
29
        cs_complex_t *x, *b ;
 
30
        b = cs_cl_mex_get_double (n, pargin [0]) ;
 
31
        x = cs_dl_malloc (n, sizeof (cs_complex_t)) ;
 
32
        cs_cl_pvec (p, b, x, n) ;
 
33
        pargout [0] = cs_cl_mex_put_double (n, x) ;
 
34
        cs_free (b) ;       /* free copy of complex values */
 
35
    }
 
36
    else
 
37
    {
 
38
        double *x, *b ;
 
39
        b = cs_dl_mex_get_double (n, pargin [0]) ;
 
40
        pargout [0] = mxCreateDoubleMatrix (n, 1, mxREAL) ;
 
41
        x = mxGetPr (pargout [0]) ;
 
42
        cs_dl_pvec (p, b, x, n) ;
 
43
    }
 
44
    cs_free (p) ;
 
45
}