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

« back to all changes in this revision

Viewing changes to CXSparse/MATLAB/CSparse/cs_ltsolve_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
/* cs_ltsolve: solve an upper triangular system L'*x=b */
 
3
void mexFunction
 
4
(
 
5
    int nargout,
 
6
    mxArray *pargout [ ],
 
7
    int nargin,
 
8
    const mxArray *pargin [ ]
 
9
)
 
10
{
 
11
    if (nargout > 1 || nargin != 2)
 
12
    {
 
13
        mexErrMsgTxt ("Usage: x = cs_ltsolve(L,b)") ;
 
14
    }
 
15
    if (mxIsComplex (pargin [0]) || mxIsComplex (pargin [1]))
 
16
    {
 
17
#ifndef NCOMPLEX
 
18
        cs_cl Lmatrix, *L ;
 
19
        cs_complex_t *x ;
 
20
        CS_INT n ;
 
21
        L = cs_cl_mex_get_sparse (&Lmatrix, 1, pargin [0]) ;    /* get L */
 
22
        x = cs_cl_mex_get_double (L->n, pargin [1]) ;           /* x = b */
 
23
        cs_cl_ltsolve (L, x) ;                                  /* x = L'\x */
 
24
        cs_free (L->x) ;
 
25
        pargout [0] = cs_cl_mex_put_double (L->n, x) ;          /* return x */
 
26
#else
 
27
        mexErrMsgTxt ("complex matrices not supported") ;
 
28
#endif
 
29
    }
 
30
    else
 
31
    {
 
32
        cs_dl Lmatrix, *L ;
 
33
        double *x, *b ;
 
34
        L = cs_dl_mex_get_sparse (&Lmatrix, 1, 1, pargin [0]) ; /* get L */
 
35
        b = cs_dl_mex_get_double (L->n, pargin [1]) ;           /* get b */
 
36
        x = cs_dl_mex_put_double (L->n, b, &(pargout [0])) ;    /* x = b */
 
37
        cs_dl_ltsolve (L, x) ;                                  /* x = L'\x */
 
38
    }
 
39
}