SuiteSparse/SPQR/MATLAB/spqr_mx.cpp
cholmod_sparse *spqr_mx_get_sparse
(
    const mxArray *Amatlab, // MATLAB version of the matrix
    cholmod_sparse *A,	    // CHOLMOD version of the matrix
    double *dummy 	    // a pointer to a valid scalar double
)
{
    Long *Ap ;
    A->nrow = mxGetM (Amatlab) ;
    A->ncol = mxGetN (Amatlab) ;
    A->p = (Long *) mxGetJc (Amatlab) ;
    A->i = (Long *) mxGetIr (Amatlab) ;
    Ap = (Long *) A->p ;
    A->nzmax = Ap [A->ncol] ;
    A->packed = TRUE ;
    A->sorted = TRUE ;
    A->nz = NULL ;
    A->itype = CHOLMOD_LONG ;
    A->dtype = CHOLMOD_DOUBLE ;     // FUTURE: support single
    A->stype = 0 ;

    if (mxIsEmpty (Amatlab))
    {
	// this is not dereferenced, but the existence (non-NULL) of these
	// pointers is checked in CHOLMOD
	A->x = dummy ;
	A->z = dummy ;
	A->xtype = mxIsComplex (Amatlab) ? CHOLMOD_ZOMPLEX : CHOLMOD_REAL ;
    }
    else if (mxIsDouble (Amatlab))
    {
	A->x = mxGetPr (Amatlab) ;
	A->z = mxGetPi (Amatlab) ;
	A->xtype = mxIsComplex (Amatlab) ? CHOLMOD_ZOMPLEX : CHOLMOD_REAL ;
    }
    else
    {
	// only sparse complex/real double matrices are supported
        mexErrMsgIdAndTxt ("QR:invalidInput", "matrix type not supported") ;
    }

    return (A) ;
}
// Create a shallow CHOLMOD copy of a MATLAB sparse matrix.  No memory is
// allocated.  The resulting matrix A must not be modified.
Create a shallow CHOLMOD copy of a MATLAB sparse matrix.  No memory is
allocated.  The resulting matrix A must not be modified.
Create a shallow CHOLMOD copy of a MATLAB sparse matrix . No memory is allocated . The resulting matrix A must not be modified .
cholmod_sparse *spqr_mx_get_sparse
(
    const mxArray *Amatlab, 
    cholmod_sparse *A,	    
    double *dummy 	    
)
{
    Long *Ap ;
    A->nrow = mxGetM (Amatlab) ;
    A->ncol = mxGetN (Amatlab) ;
    A->p = (Long *) mxGetJc (Amatlab) ;
    A->i = (Long *) mxGetIr (Amatlab) ;
    Ap = (Long *) A->p ;
    A->nzmax = Ap [A->ncol] ;
    A->packed = TRUE ;
    A->sorted = TRUE ;
    A->nz = NULL ;
    A->itype = CHOLMOD_LONG ;
    A->dtype = CHOLMOD_DOUBLE ;     
    A->stype = 0 ;
    if (mxIsEmpty (Amatlab))
    {
	A->x = dummy ;
	A->z = dummy ;
	A->xtype = mxIsComplex (Amatlab) ? CHOLMOD_ZOMPLEX : CHOLMOD_REAL ;
    }
    else if (mxIsDouble (Amatlab))
    {
	A->x = mxGetPr (Amatlab) ;
	A->z = mxGetPi (Amatlab) ;
	A->xtype = mxIsComplex (Amatlab) ? CHOLMOD_ZOMPLEX : CHOLMOD_REAL ;
    }
    else
    {
        mexErrMsgIdAndTxt ("QR:invalidInput", "matrix type not supported") ;
    }
    return (A) ;
}
cholmod_sparse * spqr_mx_get_sparse ( const mxArray * Amatlab , cholmod_sparse * A , double * dummy ) { Long * Ap ; A -> nrow = mxGetM ( Amatlab ) ; A -> ncol = mxGetN ( Amatlab ) ; A -> p = ( Long * ) mxGetJc ( Amatlab ) ; A -> i = ( Long * ) mxGetIr ( Amatlab ) ; Ap = ( Long * ) A -> p ; A -> nzmax = Ap [ A -> ncol ] ; A -> packed = TRUE ; A -> sorted = TRUE ; A -> nz = NULL ; A -> itype = CHOLMOD_LONG ; A -> dtype = CHOLMOD_DOUBLE ; A -> stype = 0 ; if ( mxIsEmpty ( Amatlab ) ) { A -> x = dummy ; A -> z = dummy ; A -> xtype = mxIsComplex ( Amatlab ) ? CHOLMOD_ZOMPLEX : CHOLMOD_REAL ; } else if ( mxIsDouble ( Amatlab ) ) { A -> x = mxGetPr ( Amatlab ) ; A -> z = mxGetPi ( Amatlab ) ; A -> xtype = mxIsComplex ( Amatlab ) ? CHOLMOD_ZOMPLEX : CHOLMOD_REAL ; } else { mexErrMsgIdAndTxt ( " " , " " ) ; } return ( A ) ; }
Create a shallow CHOLMOD copy of a MATLAB sparse matrix.
Create a shallow CHOLMOD copy of a MATLAB sparse matrix .
// MATLAB version of the matrix // CHOLMOD version of the matrix // a pointer to a valid scalar double // FUTURE: support single // this is not dereferenced, but the existence (non-NULL) of these // pointers is checked in CHOLMOD // only sparse complex/real double matrices are supported