SuiteSparse/SPQR/Tcov/qrtest.cpp
int sparse_merge
(
    cholmod_sparse *A,          // input/output
    cholmod_sparse *A_imag,     // input only
    cholmod_common *cc
)
{
    if (A == NULL || A_imag == NULL)
    {
        return (FALSE) ;
    }
    Long nz1 = cholmod_l_nnz (A, cc) ;
    Long nz2 = cholmod_l_nnz (A_imag, cc) ;
    if (A->xtype != CHOLMOD_REAL || A_imag->xtype != CHOLMOD_REAL || nz1 != nz2)
    {
        return (FALSE) ;
    }

    // change A from real to complex
    cholmod_l_sparse_xtype (CHOLMOD_COMPLEX, A, cc) ;

    double *Ax = (double *) A->x ;
    double *Az = (double *) A_imag->x ;

    // merge in the imaginary part from A_imag into A
    for (Long k = 0 ; k < nz1 ; k++)
    {
        Ax [2*k+1] = Az [k] ;
    }
    return (TRUE) ;
}
// Add the real and imaginary parts of a matrix (both stored in real form)
// into a single matrix.  The two parts must have the same nonzero pattern.
// A is CHOLMOD_REAL on input and holds the real part, it is CHOLMOD_COMPLEX
// on output.  A_imag is CHOLMOD_REAL on input; it holds the imaginary part
// of A as a real matrix.
Add the real and imaginary parts of a matrix (both stored in real form)
into a single matrix.  The two parts must have the same nonzero pattern.
A is CHOLMOD_REAL on input and holds the real part, it is CHOLMOD_COMPLEX
on output.  A_imag is CHOLMOD_REAL on input; it holds the imaginary part
of A as a real matrix.
Add the real and imaginary parts of a matrix ( both stored in real form ) into a single matrix . The two parts must have the same nonzero pattern . A is CHOLMOD_REAL on input and holds the real part it is CHOLMOD_COMPLEX on output . A_imag is CHOLMOD_REAL on input ; it holds the imaginary part of A as a real matrix .
int sparse_merge
(
    cholmod_sparse *A,          
    cholmod_sparse *A_imag,     
    cholmod_common *cc
)
{
    if (A == NULL || A_imag == NULL)
    {
        return (FALSE) ;
    }
    Long nz1 = cholmod_l_nnz (A, cc) ;
    Long nz2 = cholmod_l_nnz (A_imag, cc) ;
    if (A->xtype != CHOLMOD_REAL || A_imag->xtype != CHOLMOD_REAL || nz1 != nz2)
    {
        return (FALSE) ;
    }
    cholmod_l_sparse_xtype (CHOLMOD_COMPLEX, A, cc) ;
    double *Ax = (double *) A->x ;
    double *Az = (double *) A_imag->x ;
    for (Long k = 0 ; k < nz1 ; k++)
    {
        Ax [2*k+1] = Az [k] ;
    }
    return (TRUE) ;
}
int sparse_merge ( cholmod_sparse * A , cholmod_sparse * A_imag , cholmod_common * cc ) { if ( A == NULL || A_imag == NULL ) { return ( FALSE ) ; } Long nz1 = cholmod_l_nnz ( A , cc ) ; Long nz2 = cholmod_l_nnz ( A_imag , cc ) ; if ( A -> xtype != CHOLMOD_REAL || A_imag -> xtype != CHOLMOD_REAL || nz1 != nz2 ) { return ( FALSE ) ; } cholmod_l_sparse_xtype ( CHOLMOD_COMPLEX , A , cc ) ; double * Ax = ( double * ) A -> x ; double * Az = ( double * ) A_imag -> x ; for ( Long k = 0 ; k < nz1 ; k ++ ) { Ax [ 2 * k + 1 ] = Az [ k ] ; } return ( TRUE ) ; }
Add the real and imaginary parts of a matrix (both stored in real form)
into a single matrix.
Add the real and imaginary parts of a matrix ( both stored in real form ) into a single matrix .
// input/output // input only // change A from real to complex // merge in the imaginary part from A_imag into A