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

« back to all changes in this revision

Viewing changes to CXSparse_newfiles/MATLAB/CSparse/cs_multiply_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_multiply: sparse matrix multiply */
 
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: C = cs_multiply(A,B)") ;
 
14
    }
 
15
    if (mxIsComplex (pargin [0]) || mxIsComplex (pargin [1]))
 
16
    {
 
17
#ifndef NCOMPLEX
 
18
        cs_cl Amatrix, Bmatrix, A1matrix, B1matrix, *A, *B, *C, *D, *A1, *B1 ;
 
19
        A1 = cs_cl_mex_get_sparse (&A1matrix, 0, pargin [0]) ;
 
20
        A = cs_cl_transpose (A1, 1) ;
 
21
        cs_cl_free (A1->x) ;            /* complex copy no longer needed */
 
22
        B1 = cs_cl_mex_get_sparse (&B1matrix, 0, pargin [1]) ;
 
23
        B = cs_cl_transpose (B1, 1) ;
 
24
        cs_cl_free (B1->x) ;            /* complex copy no longer needed */
 
25
        D = cs_cl_multiply (B,A) ;              /* D = B'*A' */
 
26
        cs_cl_spfree (A) ;
 
27
        cs_cl_spfree (B) ;
 
28
        cs_cl_dropzeros (D) ;                   /* drop zeros from D */
 
29
        C = cs_cl_transpose (D, 1) ;            /* C = D', so C is sorted */
 
30
        cs_cl_spfree (D) ;
 
31
        pargout [0] = cs_cl_mex_put_sparse (&C) ;       /* return C */
 
32
#else
 
33
        mexErrMsgTxt ("complex matrices not supported") ;
 
34
#endif
 
35
    }
 
36
    else
 
37
    {
 
38
        cs_dl Amatrix, Bmatrix, *A, *B, *C, *D ;
 
39
        A = cs_dl_transpose (cs_dl_mex_get_sparse (&Amatrix, 0,1, pargin[0]),1);
 
40
        B = cs_dl_transpose (cs_dl_mex_get_sparse (&Bmatrix, 0,1, pargin[1]),1);
 
41
        D = cs_dl_multiply (B,A) ;              /* D = B'*A' */
 
42
        cs_dl_spfree (A) ;
 
43
        cs_dl_spfree (B) ;
 
44
        cs_dl_dropzeros (D) ;                   /* drop zeros from D */
 
45
        C = cs_dl_transpose (D, 1) ;            /* C = D', so C is sorted */
 
46
        cs_dl_spfree (D) ;
 
47
        pargout [0] = cs_dl_mex_put_sparse (&C) ;       /* return C */
 
48
    }
 
49
}