Matrix $Rev: 2718 $ at $LastChangedDate: 2011-10-06 11:45:17 +0200 (Thu, 06 Oct 2011) $
chm_common.h File Reference
#include "UFconfig/UFconfig.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.

Defines

#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_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 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.
CHM_FR as_cholmod_factor (CHM_FR ans, SEXP x)
 Populate ans with the pointers from x and modify its scalar elements accordingly.
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.
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.
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.
SEXP chm_dense_to_SEXP (CHM_DN a, int dofree, int Rkind, SEXP dn)
 Copy the contents of a to an appropriate denseMatrix object and, optionally, free a or free both a and its pointer to its contents.
void chm_diagN2U (CHM_SP chx, int uploT, Rboolean do_realloc)
 Drop the (unit) diagonal entries from a cholmod_sparse matrix.
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.
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.
void CHM_store_common ()
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.
SEXP CHMfactor_validate (SEXP obj)
SEXP CHMsimpl_validate (SEXP obj)
SEXP CHMsuper_validate (SEXP obj)
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.

Variables

cholmod_common c
cholmod_common cl

Define Documentation

#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_TR (   x)    as_cholmod_triplet((CHM_TR)alloca(sizeof(cholmod_triplet)),x, TRUE)

Definition at line 44 of file chm_common.h.

Referenced by Csparse_crossprod().

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

Definition at line 47 of file chm_common.h.

Referenced by Csparse_crossprod(), Tsparse_to_Csparse(), and Tsparse_to_tCsparse().

#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 50 of file chm_common.h.


Typedef Documentation

typedef cholmod_common* CHM_CM

Definition at line 18 of file chm_common.h.

typedef cholmod_dense* CHM_DN

Definition at line 19 of file chm_common.h.

typedef cholmod_factor* CHM_FR

Definition at line 21 of file chm_common.h.

typedef cholmod_sparse* CHM_SP

Definition at line 23 of file chm_common.h.

typedef cholmod_triplet* CHM_TR

Definition at line 25 of file chm_common.h.

typedef const cholmod_dense* const_CHM_DN

Definition at line 20 of file chm_common.h.

typedef const cholmod_factor* const_CHM_FR

Definition at line 22 of file chm_common.h.

typedef const cholmod_sparse* const_CHM_SP

Definition at line 24 of file chm_common.h.

typedef const cholmod_triplet* const_CHM_TR

Definition at line 26 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 593 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 865 of file chm_common.c.

References _, c, Matrix_check_class_etc(), Matrix_iSym, Matrix_permSym, Matrix_pSym, MATRIX_VALID_CHMfactor, and Matrix_xSym.

Referenced by R_init_Matrix().

Here is the call graph for this function:

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 217 of file chm_common.c.

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

Referenced by Csparse_validate_(), 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 410 of file chm_common.c.

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

Here is the call graph for this function:

CHM_DN as_cholmod_x_dense ( CHM_DN  ans,
SEXP  x 
)

Definition at line 652 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 141 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
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 809 of file chm_common.c.

References _, and c.

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 
)

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]
Returns:
SEXP containing a copy of a

Definition at line 736 of file chm_common.c.

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

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

Here is the call graph for this function:

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 1019 of file chm_common.c.

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

Referenced by Csparse_Csparse_crossprod(), Csparse_Csparse_prod(), and Csparse_diagN2U().

Here is the caller graph for this function:

static R_INLINE Rboolean chm_factor_ok ( CHM_FR  f) [static]

Definition at line 52 of file chm_common.h.

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

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 940 of file chm_common.c.

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

Referenced by CHMfactor_update(), 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:

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
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 311 of file chm_common.c.

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

Referenced by CHMfactor_spsolve(), CHMfactor_to_sparse(), Csparse_band(), Csparse_crossprod(), Csparse_Csparse_crossprod(), Csparse_Csparse_prod(), Csparse_diagN2U(), Csparse_diagU2N(), Csparse_drop(), Csparse_general_to_symmetric(), Csparse_horzcat(), Csparse_submatrix(), Csparse_symmetric_to_general(), Csparse_to_nz_pattern(), Csparse_transpose(), Csparse_vertcat(), 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:

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 503 of file chm_common.c.

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

Referenced by Csparse_to_Tsparse(), 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 1087 of file chm_common.c.

SEXP CHMsimpl_validate ( SEXP  obj)

Definition at line 1092 of file chm_common.c.

SEXP CHMsuper_validate ( SEXP  obj)

Definition at line 1097 of file chm_common.c.

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

Definition at line 841 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 668 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 709 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