Matrix  $Rev: 3071 $ at $LastChangedDate: 2015-03-26 15:35:47 +0100 (Thu, 26 Mar 2015) $
chm_common.h File Reference
#include "SuiteSparse_config/SuiteSparse_config.h"
#include "CHOLMOD/Include/cholmod.h"
#include "Mutils.h"
Include dependency graph for chm_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define AS_CHM_DN(x)   as_cholmod_dense ((CHM_DN)alloca(sizeof(cholmod_dense)), x )
 
#define AS_CHM_FR(x)   as_cholmod_factor ((CHM_FR)alloca(sizeof(cholmod_factor)), x )
 
#define AS_CHM_SP(x)   as_cholmod_sparse ((CHM_SP)alloca(sizeof(cholmod_sparse)), x, TRUE, FALSE)
 
#define AS_CHM_SP2(x, chk)   as_cholmod_sparse ((CHM_SP)alloca(sizeof(cholmod_sparse)), x, chk, FALSE)
 
#define AS_CHM_SP__(x)   as_cholmod_sparse ((CHM_SP)alloca(sizeof(cholmod_sparse)), x, FALSE, FALSE)
 
#define AS_CHM_TR(x)   as_cholmod_triplet((CHM_TR)alloca(sizeof(cholmod_triplet)),x, TRUE)
 
#define AS_CHM_TR__(x)   as_cholmod_triplet((CHM_TR)alloca(sizeof(cholmod_triplet)), x, FALSE)
 
#define AS_CHM_xDN(x)   as_cholmod_x_dense ((CHM_DN)alloca(sizeof(cholmod_dense)), x )
 
#define N_AS_CHM_DN(x, nr, nc)   M_numeric_as_chm_dense((CHM_DN)alloca(sizeof(cholmod_dense)), x , nr, nc )
 

Typedefs

typedef cholmod_common * CHM_CM
 
typedef cholmod_dense * CHM_DN
 
typedef cholmod_factor * CHM_FR
 
typedef cholmod_sparse * CHM_SP
 
typedef cholmod_triplet * CHM_TR
 
typedef const cholmod_dense * const_CHM_DN
 
typedef const cholmod_factor * const_CHM_FR
 
typedef const cholmod_sparse * const_CHM_SP
 
typedef const cholmod_triplet * const_CHM_TR
 

Functions

CHM_DN as_cholmod_dense (CHM_DN ans, SEXP x)
 Populate ans with the pointers from x and modify its scalar elements accordingly. More...
 
CHM_FR as_cholmod_factor (CHM_FR ans, SEXP x)
 Populate ans with the pointers from x and modify its scalar elements accordingly. More...
 
CHM_SP as_cholmod_sparse (CHM_SP ans, SEXP x, Rboolean check_Udiag, Rboolean sort_in_place)
 Populate ans with the pointers from x and modify its scalar elements accordingly. More...
 
CHM_TR as_cholmod_triplet (CHM_TR ans, SEXP x, Rboolean check_Udiag)
 Populate ans with the pointers from x and modify its scalar elements accordingly. More...
 
CHM_DN as_cholmod_x_dense (CHM_DN ans, SEXP x)
 
Rboolean check_sorted_chm (CHM_SP A)
 
SEXP chm_dense_to_matrix (CHM_DN a, int dofree, SEXP dn)
 Copy the contents of a to a matrix object and, optionally, free a or free both a and its pointer to its contents. More...
 
SEXP chm_dense_to_SEXP (CHM_DN a, int dofree, int Rkind, SEXP dn, Rboolean transp)
 Copy the contents of a to an appropriate denseMatrix object and, optionally, free a or free both a and its pointer to its contents. More...
 
SEXP chm_dense_to_vector (CHM_DN a, int dofree)
 Copy the contents of a to a numeric R object and, optionally, free a or free both a and its pointer to its contents. More...
 
void chm_diagN2U (CHM_SP chx, int uploT, Rboolean do_realloc)
 Drop the (unit) diagonal entries from a cholmod_sparse matrix. More...
 
static R_INLINE Rboolean chm_factor_ok (CHM_FR f)
 
SEXP chm_factor_to_SEXP (CHM_FR f, int dofree)
 Copy the contents of f to an appropriate CHMfactor object and, optionally, free f or free both f and its pointer to its contents. More...
 
Rboolean chm_MOD_xtype (int to_xtype, cholmod_sparse *A, CHM_CM Common)
 Change the "type" of a cholmod_sparse matrix, i.e. More...
 
void CHM_restore_common ()
 
SEXP CHM_set_common_env (SEXP rho)
 
SEXP chm_sparse_to_SEXP (CHM_SP a, int dofree, int uploT, int Rkind, const char *diag, SEXP dn)
 Copy the contents of a to an appropriate CsparseMatrix object and, optionally, free a or free both a and its the pointers to its contents. More...
 
void CHM_store_common ()
 
void chm_transpose_dense (CHM_DN ans, CHM_DN x)
 Transpose a cholmod_dense matrix ("too trivial to be in CHOLMOD?") More...
 
SEXP chm_triplet_to_SEXP (CHM_TR a, int dofree, int uploT, int Rkind, const char *diag, SEXP dn)
 Copy the contents of a to an appropriate TsparseMatrix object and, optionally, free a or free both a and its the pointers to its contents. More...
 
SEXP CHMfactor_validate (SEXP obj)
 
SEXP CHMsimpl_validate (SEXP obj)
 
SEXP CHMsuper_validate (SEXP obj)
 
SEXP get_SuiteSparse_version ()
 
CHM_DN numeric_as_chm_dense (CHM_DN ans, double *v, int nr, int nc)
 
void R_cholmod_error (int status, const char *file, int line, const char *message)
 
int R_cholmod_l_start (CHM_CM Common)
 
int R_cholmod_start (CHM_CM Common)
 Initialize the CHOLMOD library and replace the print and error functions by R-specific versions. More...
 

Variables

cholmod_common c
 
cholmod_common cl
 

Macro Definition Documentation

#define AS_CHM_DN (   x)    as_cholmod_dense ((CHM_DN)alloca(sizeof(cholmod_dense)), x )

Definition at line 43 of file chm_common.h.

Referenced by CHMfactor_solve(), dgCMatrix_cholsol(), and dsCMatrix_matrix_solve().

#define AS_CHM_SP (   x)    as_cholmod_sparse ((CHM_SP)alloca(sizeof(cholmod_sparse)), x, TRUE, FALSE)
#define AS_CHM_SP2 (   x,
  chk 
)    as_cholmod_sparse ((CHM_SP)alloca(sizeof(cholmod_sparse)), x, chk, FALSE)

Definition at line 52 of file chm_common.h.

Referenced by Csparse_to_matrix().

#define AS_CHM_TR (   x)    as_cholmod_triplet((CHM_TR)alloca(sizeof(cholmod_triplet)),x, TRUE)

Definition at line 47 of file chm_common.h.

#define AS_CHM_TR__ (   x)    as_cholmod_triplet((CHM_TR)alloca(sizeof(cholmod_triplet)), x, FALSE)

Definition at line 50 of file chm_common.h.

Referenced by Tsparse_to_Csparse(), and Tsparse_to_tCsparse().

#define AS_CHM_xDN (   x)    as_cholmod_x_dense ((CHM_DN)alloca(sizeof(cholmod_dense)), x )

Definition at line 44 of file chm_common.h.

Referenced by dense_to_Csparse().

#define N_AS_CHM_DN (   x,
  nr,
  nc 
)    M_numeric_as_chm_dense((CHM_DN)alloca(sizeof(cholmod_dense)), x , nr, nc )

Definition at line 55 of file chm_common.h.

Typedef Documentation

typedef cholmod_common* CHM_CM

Definition at line 20 of file chm_common.h.

typedef cholmod_dense* CHM_DN

Definition at line 21 of file chm_common.h.

typedef cholmod_factor* CHM_FR

Definition at line 23 of file chm_common.h.

typedef cholmod_sparse* CHM_SP

Definition at line 25 of file chm_common.h.

typedef cholmod_triplet* CHM_TR

Definition at line 27 of file chm_common.h.

typedef const cholmod_dense* const_CHM_DN

Definition at line 22 of file chm_common.h.

typedef const cholmod_factor* const_CHM_FR

Definition at line 24 of file chm_common.h.

typedef const cholmod_sparse* const_CHM_SP

Definition at line 26 of file chm_common.h.

typedef const cholmod_triplet* const_CHM_TR

Definition at line 28 of file chm_common.h.

Function Documentation

CHM_DN as_cholmod_dense ( CHM_DN  ans,
SEXP  x 
)

Populate ans with the pointers from x and modify its scalar elements accordingly.

Note that later changes to the contents of ans will change the contents of the SEXP.

In most cases this function is called through the macro AS_CHM_DN. It is unusual to call it directly.

Parameters
ansa CHM_DN pointer.
xpointer to an object that inherits from (denseMatrix ^ generalMatrix)
Returns
ans containing pointers to the slots of x.

Definition at line 672 of file chm_common.c.

References _AS_cholmod_dense_1, _AS_cholmod_dense_2, Matrix_xSym, and RallocedREAL().

Referenced by R_init_Matrix().

Here is the call graph for this function:

Here is the caller graph for this function:

CHM_FR as_cholmod_factor ( CHM_FR  ans,
SEXP  x 
)

Populate ans with the pointers from x and modify its scalar elements accordingly.

Note that later changes to the contents of ans will change the contents of the SEXP.

In most cases this function is called through the macro AS_CHM_FR. It is unusual to call it directly.

Parameters
ansan CHM_FR object
xpointer to an object that inherits from CHMfactor
Returns
ans containing pointers to the slots of x.

Definition at line 1031 of file chm_common.c.

References _, c, Matrix_iSym, Matrix_permSym, Matrix_pSym, MATRIX_VALID_CHMfactor, and Matrix_xSym.

Referenced by R_init_Matrix().

Here is the caller graph for this function:

CHM_SP as_cholmod_sparse ( CHM_SP  ans,
SEXP  x,
Rboolean  check_Udiag,
Rboolean  sort_in_place 
)

Populate ans with the pointers from x and modify its scalar elements accordingly.

Note that later changes to the contents of ans will change the contents of the SEXP.

In most cases this function is called through the macros AS_CHM_SP() or AS_CHM_SP__(). It is unusual to call it directly.

Parameters
ansa CHM_SP pointer
xpointer to an object that inherits from CsparseMatrix
check_Udiagboolean - should a check for (and consequent expansion of) a unit diagonal be performed.
sort_in_placeboolean - if the i and x slots are to be sorted should they be sorted in place? If the i and x slots are pointers to an input SEXP they should not be modified.
Returns
ans containing pointers to the slots of x, unless check_Udiag and x is unitriangular.

Definition at line 245 of file chm_common.c.

References _, c, check_sorted_chm(), chm2Ralloc(), diag_P, isValid_Csparse(), Matrix_DimSym, Matrix_iSym, Matrix_pSym, MATRIX_VALID_Csparse, stype(), xpt(), and xtype().

Referenced by CSPARSE_VAL_FN_NAME(), and R_init_Matrix().

Here is the call graph for this function:

Here is the caller graph for this function:

CHM_TR as_cholmod_triplet ( CHM_TR  ans,
SEXP  x,
Rboolean  check_Udiag 
)

Populate ans with the pointers from x and modify its scalar elements accordingly.

Note that later changes to the contents of ans will change the contents of the SEXP.

In most cases this function is called through the macros AS_CHM_TR() or AS_CHM_TR__(). It is unusual to call it directly.

Parameters
ansa CHM_TR pointer
xpointer to an object that inherits from TsparseMatrix
check_Udiagboolean - should a check for (and consequent expansion of) a unit diagonal be performed.
Returns
ans containing pointers to the slots of x, unless check_Udiag and x is unitriangular.

Definition at line 480 of file chm_common.c.

References _, c, chTr2Ralloc(), diag_P, Matrix_DimSym, Matrix_iSym, Matrix_jSym, MATRIX_VALID_Tsparse, stype(), xpt(), and xtype().

Referenced by R_init_Matrix().

Here is the call graph for this function:

Here is the caller graph for this function:

CHM_DN as_cholmod_x_dense ( CHM_DN  ans,
SEXP  x 
)

Definition at line 731 of file chm_common.c.

References _AS_cholmod_dense_1, _AS_cholmod_dense_2, Matrix_xSym, and RallocedREAL().

Here is the call graph for this function:

Rboolean check_sorted_chm ( CHM_SP  A)

Definition at line 169 of file chm_common.c.

Referenced by as_cholmod_sparse().

Here is the caller graph for this function:

SEXP chm_dense_to_matrix ( CHM_DN  a,
int  dofree,
SEXP  dn 
)

Copy the contents of a to a matrix object and, optionally, free a or free both a and its pointer to its contents.

Parameters
acholmod_dense structure to be converted {already REAL for original l..CMatrix}
dofree0 - don't free a; > 0 cholmod_free a; < 0 Free a
dneither R_NilValue or an SEXP suitable for the Dimnames slot.
Returns
SEXP containing a copy of a as a matrix object

Definition at line 942 of file chm_common.c.

References CHM_DENSE_COPY_DATA, CHM_DENSE_TYPE, and DOFREE_de_MAYBE.

Referenced by Csparse_to_matrix().

Here is the caller graph for this function:

SEXP chm_dense_to_SEXP ( CHM_DN  a,
int  dofree,
int  Rkind,
SEXP  dn,
Rboolean  transp 
)

Copy the contents of a to an appropriate denseMatrix object and, optionally, free a or free both a and its pointer to its contents.

Parameters
amatrix to be converted
dofree0 - don't free a; > 0 cholmod_free a; < 0 Free a
Rkindtype of R matrix to be generated (special to this function)
dn– dimnames [list(.,.) or NULL; already transposed when transp is TRUE ]
transpRboolean, if TRUE, the result must be a copy of t(a), i.e., "a transposed"
Returns
SEXP containing a copy of a

Definition at line 835 of file chm_common.c.

References _, ALLOC_SLOT(), cl, DOFREE_de_MAYBE, Matrix_DimNamesSym, Matrix_DimSym, and Matrix_xSym.

Referenced by CHMfactor_solve(), Csparse_to_dense(), and dsCMatrix_matrix_solve().

Here is the call graph for this function:

Here is the caller graph for this function:

SEXP chm_dense_to_vector ( CHM_DN  a,
int  dofree 
)

Copy the contents of a to a numeric R object and, optionally, free a or free both a and its pointer to its contents.

Parameters
acholmod_dense structure to be converted
dofree0 - don't free a; > 0 cholmod_free a; < 0 Free a
Returns
SEXP containing a copy of a in the sense of as.vector(a)

Definition at line 996 of file chm_common.c.

References CHM_DENSE_COPY_DATA, CHM_DENSE_TYPE, and DOFREE_de_MAYBE.

Referenced by Csparse_to_vector().

Here is the caller graph for this function:

void chm_diagN2U ( CHM_SP  chx,
int  uploT,
Rboolean  do_realloc 
)

Drop the (unit) diagonal entries from a cholmod_sparse matrix.

Parameters
chxcholmod_sparse matrix. Note that the matrix "slots" are modified in place
uploTinteger code (= +/- 1) indicating if chx is upper (+1) or lower (-1) triangular
do_reallocRboolean indicating, if a cholmod_sprealloc() should finalize the procedure; not needed, e.g. when the result is converted to a SEXP immediately afterwards.

Definition at line 1191 of file chm_common.c.

References _, _i, _p, _x, and c.

Referenced by Csparse_Csparse_crossprod(), and Csparse_Csparse_prod().

Here is the caller graph for this function:

static R_INLINE Rboolean chm_factor_ok ( CHM_FR  f)
static

Definition at line 57 of file chm_common.h.

Referenced by chm_factor_to_SEXP(), dsCMatrix_Csparse_solve(), dsCMatrix_matrix_solve(), and internal_chm_factor().

Here is the caller graph for this function:

SEXP chm_factor_to_SEXP ( CHM_FR  f,
int  dofree 
)

Copy the contents of f to an appropriate CHMfactor object and, optionally, free f or free both f and its pointer to its contents.

Parameters
fcholmod_factor object to be converted
dofree0 - don't free a; > 0 cholmod_free a; < 0 Free a
Returns
SEXP containing a copy of a

Definition at line 1106 of file chm_common.c.

References _, ALLOC_SLOT(), chm_factor_ok(), DOFREE_MAYBE, Matrix_iSym, Matrix_pSym, Matrix_xSym, and xtype().

Referenced by CHMfactor_update(), CHMfactor_updown(), destructive_CHM_update(), dgCMatrix_cholsol(), dsCMatrix_Cholesky(), internal_chm_factor(), and R_init_Matrix().

Here is the call graph for this function:

Here is the caller graph for this function:

Rboolean chm_MOD_xtype ( int  to_xtype,
cholmod_sparse *  A,
CHM_CM  Common 
)

Change the "type" of a cholmod_sparse matrix, i.e.

modify it "in place"

Parameters
to_xtyperequested xtype (pattern, real, complex, zomplex)
Asparse matrix to change
Commoncholmod's common
Returns
TRUE/FALSE , TRUE iff success

Definition at line 438 of file chm_common.c.

SEXP chm_sparse_to_SEXP ( CHM_SP  a,
int  dofree,
int  uploT,
int  Rkind,
const char *  diag,
SEXP  dn 
)

Copy the contents of a to an appropriate CsparseMatrix object and, optionally, free a or free both a and its the pointers to its contents.

Parameters
a(cholmod_sparse) matrix to be converted
dofree0 - don't free a; > 0 cholmod_free a; < 0 Free a
uploT0 - not triangular; > 0 upper triangular; < 0 lower
Rkind- vector type to store for a->xtype == CHOLMOD_REAL, 0 - REAL; 1 - LOGICAL [unused for other a->xtype]
diagcharacter string suitable for the diag slot of a triangular matrix (not accessed if uploT == 0).
dneither R_NilValue or an SEXP suitable for the Dimnames slot.
Returns
SEXP containing a copy of a

Definition at line 335 of file chm_common.c.

References _, ALLOC_SLOT(), c, cl, DOFREE_MAYBE, Matrix_diagSym, Matrix_DimNamesSym, Matrix_DimSym, Matrix_iSym, Matrix_pSym, Matrix_uploSym, and Matrix_xSym.

Referenced by CHMfactor_spsolve(), CHMfactor_to_sparse(), Csparse2nz(), Csparse_Csparse_crossprod(), Csparse_Csparse_prod(), Csparse_general_to_symmetric(), Csparse_symmetric_to_general(), Csparse_to_tCsparse(), Csparse_transpose(), dense_to_Csparse(), dsCMatrix_chol(), dsCMatrix_Csparse_solve(), R_init_Matrix(), Tsparse_to_Csparse(), and Tsparse_to_tCsparse().

Here is the call graph for this function:

Here is the caller graph for this function:

void chm_transpose_dense ( CHM_DN  ans,
CHM_DN  x 
)

Transpose a cholmod_dense matrix ("too trivial to be in CHOLMOD?")

Parameters
ans(pointer to) already allocated result of correct dimension
x(pointer to) cholmod_dense matrix to be transposed

Definition at line 754 of file chm_common.c.

References _.

SEXP chm_triplet_to_SEXP ( CHM_TR  a,
int  dofree,
int  uploT,
int  Rkind,
const char *  diag,
SEXP  dn 
)

Copy the contents of a to an appropriate TsparseMatrix object and, optionally, free a or free both a and its the pointers to its contents.

Parameters
amatrix to be converted
dofree0 - don't free a; > 0 cholmod_free a; < 0 Free a
uploT0 - not triangular; > 0 upper triangular; < 0 lower
Rkind- vector type to store for a->xtype == CHOLMOD_REAL, 0 - REAL; 1 - LOGICAL
diagcharacter string suitable for the diag slot of a triangular matrix (not accessed if uploT == 0).
dneither R_NilValue or an SEXP suitable for the Dimnames slot.
Returns
SEXP containing a copy of a

Definition at line 573 of file chm_common.c.

References _, ALLOC_SLOT(), cl, DOFREE_MAYBE, Matrix_diagSym, Matrix_DimNamesSym, Matrix_DimSym, Matrix_iSym, Matrix_jSym, Matrix_uploSym, and Matrix_xSym.

Referenced by Csparse_to_Tsparse(), Csparse_to_tTsparse(), dsCMatrix_to_dgTMatrix(), and R_init_Matrix().

Here is the call graph for this function:

Here is the caller graph for this function:

SEXP CHMfactor_validate ( SEXP  obj)

Definition at line 1259 of file chm_common.c.

SEXP CHMsimpl_validate ( SEXP  obj)

Definition at line 1264 of file chm_common.c.

SEXP CHMsuper_validate ( SEXP  obj)

Definition at line 1269 of file chm_common.c.

SEXP get_SuiteSparse_version ( )

Definition at line 8 of file chm_common.c.

CHM_DN numeric_as_chm_dense ( CHM_DN  ans,
double *  v,
int  nr,
int  nc 
)

Definition at line 1007 of file chm_common.c.

Referenced by R_init_Matrix().

Here is the caller graph for this function:

void R_cholmod_error ( int  status,
const char *  file,
int  line,
const char *  message 
)

Definition at line 769 of file chm_common.c.

References _, and CHM_restore_common().

Referenced by R_cholmod_start().

Here is the call graph for this function:

Here is the caller graph for this function:

int R_cholmod_l_start ( CHM_CM  Common)
int R_cholmod_start ( CHM_CM  c)

Initialize the CHOLMOD library and replace the print and error functions by R-specific versions.

Parameters
cpointer to a cholmod_common structure to be initialized
Returns
TRUE if successful

Definition at line 810 of file chm_common.c.

References _, R_cholmod_error(), and R_cholmod_printf().

Referenced by R_init_Matrix().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation