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

« back to all changes in this revision

Viewing changes to CXSparse/MATLAB/CSparse/cs_droptol_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_droptol: remove small entries from A */
 
3
void mexFunction
 
4
(
 
5
    int nargout,
 
6
    mxArray *pargout [ ],
 
7
    int nargin,
 
8
    const mxArray *pargin [ ]
 
9
)
 
10
{
 
11
    CS_INT j, k ;
 
12
    double tol ;
 
13
    if (nargout > 1 || nargin != 2)
 
14
    {
 
15
        mexErrMsgTxt ("Usage: C = cs_droptol(A,tol)") ;
 
16
    }
 
17
    tol = mxGetScalar (pargin [1]) ;                        /* get tol */
 
18
 
 
19
    if (mxIsComplex (pargin [0]))
 
20
    {
 
21
#ifndef NCOMPLEX
 
22
        cs_cl Amatrix, *C, *A ;
 
23
        A = cs_cl_mex_get_sparse (&Amatrix, 0, pargin [0]) ;    /* get A */
 
24
        C = cs_cl_spalloc (A->m, A->n, A->nzmax, 1, 0) ;        /* C = A */
 
25
        for (j = 0 ; j <= A->n ; j++) C->p [j] = A->p [j] ;
 
26
        for (k = 0 ; k < A->nzmax ; k++) C->i [k] = A->i [k] ;
 
27
        for (k = 0 ; k < A->nzmax ; k++) C->x [k] = A->x [k] ;
 
28
        cs_cl_droptol (C, tol) ;                            /* drop from C */
 
29
        pargout [0] = cs_cl_mex_put_sparse (&C) ;           /* return C */
 
30
#else
 
31
        mexErrMsgTxt ("complex matrices not supported") ;
 
32
#endif
 
33
    }
 
34
    else
 
35
    {
 
36
        cs_dl Amatrix, *C, *A ;
 
37
        A = cs_dl_mex_get_sparse (&Amatrix, 0, 1, pargin [0]) ;    /* get A */
 
38
        C = cs_dl_spalloc (A->m, A->n, A->nzmax, 1, 0) ;        /* C = A */
 
39
        for (j = 0 ; j <= A->n ; j++) C->p [j] = A->p [j] ;
 
40
        for (k = 0 ; k < A->nzmax ; k++) C->i [k] = A->i [k] ;
 
41
        for (k = 0 ; k < A->nzmax ; k++) C->x [k] = A->x [k] ;
 
42
        cs_dl_droptol (C, tol) ;                            /* drop from C */
 
43
        pargout [0] = cs_dl_mex_put_sparse (&C) ;                   /* return C */
 
44
    }
 
45
}