Matrix  $Rev: 3071 $ at $LastChangedDate: 2015-03-26 15:35:47 +0100 (Thu, 26 Mar 2015) $
cs_utils.c File Reference
#include "cs_utils.h"
Include dependency graph for cs_utils.c:

Go to the source code of this file.

Functions

static CSP csp_eye (int n)
 Create an identity matrix of size n as a cs struct. More...
 
static int is_sym (cs *A)
 
csMatrix_as_cs (cs *ans, SEXP x, Rboolean check_Udiag)
 Create a cs object with the contents of x. More...
 
SEXP Matrix_cs_to_SEXP (cs *a, char *cl, int dofree, SEXP dn)
 Copy the contents of a to an appropriate CsparseMatrix object and, optionally, free a or free both a and the pointers to its contents. More...
 

Function Documentation

static CSP csp_eye ( int  n)
static

Create an identity matrix of size n as a cs struct.

The structure must be freed with cs_free by the caller.

Parameters
nsize of identity matrix to construct.
Returns
pointer to a cs object that contains the identity matrix.

Definition at line 31 of file cs_utils.c.

References _, cs_spalloc(), cs_sparse::i, cs_sparse::nz, cs_sparse::nzmax, cs_sparse::p, and cs_sparse::x.

Referenced by Matrix_as_cs().

Here is the call graph for this function:

Here is the caller graph for this function:

static int is_sym ( cs A)
static

Definition at line 5 of file cs_utils.c.

References cs_sparse::i, cs_sparse::m, cs_sparse::n, and cs_sparse::p.

Referenced by Csparse_to_dense(), Csparse_to_matrix(), and Matrix_cs_to_SEXP().

Here is the caller graph for this function:

cs* Matrix_as_cs ( cs ans,
SEXP  x,
Rboolean  check_Udiag 
)

Create a cs object with the contents of x.

Typically called via AS_CSP()

Parameters
anspointer to a cs struct. This is allocated in the caller so it is easier to keep track of where it should be freed - in many applications the memory can be allocated with alloca and automatically freed on exit from the caller.
xpointer to an object that inherits from CsparseMatrix
check_Udiagboolean - should a check for (and consequent expansion of) a unit diagonal be performed.
Returns
pointer to a cs object that contains pointers to the slots of x.

Definition at line 61 of file cs_utils.c.

References _, cs_add(), cs_spfree(), cs_transpose(), csp_eye(), diag_P, cs_sparse::i, cs_sparse::m, Matrix_DimSym, Matrix_iSym, Matrix_pSym, Matrix_xSym, cs_sparse::n, cs_sparse::nz, cs_sparse::nzmax, cs_sparse::p, and cs_sparse::x.

Here is the call graph for this function:

SEXP Matrix_cs_to_SEXP ( cs a,
char *  cl,
int  dofree,
SEXP  dn 
)

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

Parameters
amatrix to be converted
clthe name of the S4 class of the object to be generated
dofree0 - don't free a; > 0 cs_free a; < 0 Free a
dneither R_NilValue or an SEXP suitable for the Dimnames slot.
Returns
SEXP containing a copy of a

Definition at line 121 of file cs_utils.c.

References _, ALLOC_SLOT(), cs_spfree(), cs_sparse::i, is_sym(), cs_sparse::m, Matrix_check_class(), Matrix_diagSym, Matrix_DimNamesSym, Matrix_DimSym, Matrix_iSym, Matrix_pSym, Matrix_uploSym, Matrix_xSym, cs_sparse::n, cs_sparse::p, and cs_sparse::x.

Referenced by dgCMatrix_QR(), and install_lu().

Here is the call graph for this function:

Here is the caller graph for this function: