SuiteSparse/SPQR/MATLAB/spqr_mx.cpp
double *spqr_mx_merge_if_complex
(
    // inputs, not modified
    const mxArray *A,
    int make_complex,       // if TRUE, return value is Complex
    // output
    Long *p_nz,             // number of entries in A

    // workspace and parameters
    cholmod_common *cc
)
{
    Long nz, m, n ;
    double *X, *Xx, *Xz ;

    if (cc == NULL) return (NULL) ;

    m = mxGetM (A) ;
    n = mxGetN (A) ;
    Xx = mxGetPr (A) ;
    Xz = mxGetPi (A) ;

    if (mxIsSparse (A))
    {
        Long *Ap = (Long *) mxGetJc (A) ;
        nz = Ap [n] ;
    }
    else
    {
        nz = m*n ;
    }
    if (make_complex)
    {
        // Note the typecast and sizeof (...) intentionally do not match
        X = (double *) cholmod_l_malloc (nz, sizeof (Complex), cc) ;
        for (Long k = 0 ; k < nz ; k++)
        {
            X [2*k  ] = Xx [k] ;
            X [2*k+1] = Xz ? (Xz [k]) : 0 ;
        }
    }
    else
    {
        X = Xx ;
    }
    *p_nz = nz ;
    return (X) ;
}
// Convert a real or MATLAB-style split-complex matrix into a merged-complex
// matrix usable by SuiteSparseQR and LAPACK.  Alternatively, just return
// a pointer to the real MATLAB matrix if make_complex is FALSE.  Note that
// the input matrix can actually be real, in which case an all-zero imaginary
// part is created.
Convert a real or MATLAB-style split-complex matrix into a merged-complex
matrix usable by SuiteSparseQR and LAPACK.  Alternatively, just return
a pointer to the real MATLAB matrix if make_complex is FALSE.  Note that
the input matrix can actually be real, in which case an all-zero imaginary
part is created.
Convert a real or MATLAB - style split - complex matrix into a merged - complex matrix usable by SuiteSparseQR and LAPACK . Alternatively just return a pointer to the real MATLAB matrix if make_complex is FALSE . Note that the input matrix can actually be real in which case an all - zero imaginary part is created .
double *spqr_mx_merge_if_complex
(
    const mxArray *A,
    int make_complex,       
    Long *p_nz,             
    cholmod_common *cc
)
{
    Long nz, m, n ;
    double *X, *Xx, *Xz ;
    if (cc == NULL) return (NULL) ;
    m = mxGetM (A) ;
    n = mxGetN (A) ;
    Xx = mxGetPr (A) ;
    Xz = mxGetPi (A) ;
    if (mxIsSparse (A))
    {
        Long *Ap = (Long *) mxGetJc (A) ;
        nz = Ap [n] ;
    }
    else
    {
        nz = m*n ;
    }
    if (make_complex)
    {
        X = (double *) cholmod_l_malloc (nz, sizeof (Complex), cc) ;
        for (Long k = 0 ; k < nz ; k++)
        {
            X [2*k  ] = Xx [k] ;
            X [2*k+1] = Xz ? (Xz [k]) : 0 ;
        }
    }
    else
    {
        X = Xx ;
    }
    *p_nz = nz ;
    return (X) ;
}
double * spqr_mx_merge_if_complex ( const mxArray * A , int make_complex , Long * p_nz , cholmod_common * cc ) { Long nz , m , n ; double * X , * Xx , * Xz ; if ( cc == NULL ) return ( NULL ) ; m = mxGetM ( A ) ; n = mxGetN ( A ) ; Xx = mxGetPr ( A ) ; Xz = mxGetPi ( A ) ; if ( mxIsSparse ( A ) ) { Long * Ap = ( Long * ) mxGetJc ( A ) ; nz = Ap [ n ] ; } else { nz = m * n ; } if ( make_complex ) { X = ( double * ) cholmod_l_malloc ( nz , sizeof ( Complex ) , cc ) ; for ( Long k = 0 ; k < nz ; k ++ ) { X [ 2 * k ] = Xx [ k ] ; X [ 2 * k + 1 ] = Xz ? ( Xz [ k ] ) : 0 ; } } else { X = Xx ; } * p_nz = nz ; return ( X ) ; }
Convert a real or MATLAB-style split-complex matrix into a merged-complex
matrix usable by SuiteSparseQR and LAPACK.
Convert a real or MATLAB - style split - complex matrix into a merged - complex matrix usable by SuiteSparseQR and LAPACK .
// inputs, not modified // if TRUE, return value is Complex // output // number of entries in A // workspace and parameters // Note the typecast and sizeof (...) intentionally do not match