Matrix  $Rev: 3071 $ at $LastChangedDate: 2015-03-26 15:35:47 +0100 (Thu, 26 Mar 2015) $
Mutils.h File Reference
#include <stdint.h>
#include <ctype.h>
#include <R.h>
#include <Rversion.h>
#include <Rdefines.h>
#include "Syms.h"
#include "t_sparseVector.c"
Include dependency graph for Mutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _(String)   (String)
 
#define _dspV_
 These are the ones "everyone" should use – is() versions, also looking at super classes: More...
 
#define _ispV_
 
#define _lspV_
 
#define _nspV_
 
#define _zspV_
 
#define Alloca(n, t)    (t *) alloca( (size_t) ( (n) * sizeof(t) ) )
 
#define AZERO(x, n)   {int _I_, _SZ_ = (n); for(_I_ = 0; _I_ < _SZ_; _I_++) (x)[_I_] = 0;}
 
#define C_or_Alloca_TO(_VAR_, _N_, _TYPE_)
 
#define class_P(_x_)   CHAR(asChar(getAttrib(_x_, R_ClassSymbol)))
 
#define CMJ   CblasColMajor
 
#define CTR   CblasConjTrans
 
#define DECLARE_AND_GET_X_SLOT(__C_TYPE, __SEXP)   __C_TYPE *xx = __SEXP(GET_SLOT(x, Matrix_xSym))
 
#define diag_P(_x_)   CHAR(STRING_ELT(GET_SLOT(_x_, Matrix_diagSym), 0))
 
#define Diag_P(_x_)
 
#define dngettext(pkg, String, StringP, N)   (N > 1 ? StringP : String)
 
#define FULL_TO_PACKED(TYPE)
 
#define LFT   CblasLeft
 
#define LOW   CblasLower
 
#define MATRIX_VALID_CHMfactor   "dCHMsuper", "dCHMsimpl", "nCHMsuper", "nCHMsimpl"
 
#define MATRIX_VALID_Csparse
 
#define MATRIX_VALID_dCsparse   "dgCMatrix", "dsCMatrix", "dtCMatrix"
 
#define MATRIX_VALID_ddense
 
#define MATRIX_VALID_ge_dense
 
#define MATRIX_VALID_ldense
 
#define MATRIX_VALID_nCsparse   "ngCMatrix", "nsCMatrix", "ntCMatrix"
 
#define MATRIX_VALID_ndense
 
#define MATRIX_VALID_Rsparse
 
#define MATRIX_VALID_tri_Csparse   "dtCMatrix", "ltCMatrix", "ntCMatrix", "ztCMatrix"
 
#define MATRIX_VALID_Tsparse
 
#define Memzero(p, n)   memset(p, 0, (size_t)(n) * sizeof(*p))
 
#define NTR   CblasNoTrans
 
#define NUN   CblasNonUnit
 
#define PACKED_LENGTH(n)    ((n) * ((n) + 1))/2
 
#define PACKED_TO_FULL(TYPE)
 
#define Real_KIND(_x_)
 
#define Real_kind(_x_)
 
#define Real_KIND2(_x_)
 
#define RGT   CblasRight
 
#define RMJ   CblasRowMajor
 
#define slot_dup(dest, src, sym)   SET_SLOT(dest, sym, duplicate(GET_SLOT(src, sym)))
 
#define slot_dup_if_has(dest, src, sym)
 
#define slot_nonNull_dup(dest, src, sym)
 
#define SMALL_4_Alloca   10000
 
#define TRN   CblasTrans
 
#define UNT   CblasUnit
 
#define uplo_P(_x_)   CHAR(STRING_ELT(GET_SLOT(_x_, Matrix_uploSym), 0))
 
#define UPP   CblasUpper
 
#define XLENGTH(x)   LENGTH(x)
 

Enumerations

enum  CBLAS_DIAG { CblasNonUnit =131, CblasUnit =132 }
 
enum  CBLAS_ORDER { CblasRowMajor =101, CblasColMajor =102 }
 
enum  CBLAS_SIDE { CblasLeft =141, CblasRight =142 }
 
enum  CBLAS_TRANSPOSE { CblasNoTrans =111, CblasTrans =112, CblasConjTrans =113 }
 
enum  CBLAS_UPLO { CblasUpper =121, CblasLower =122 }
 
enum  dense_enum { ddense, ldense, ndense }
 
enum  x_slot_kind { x_pattern =-1, x_double =0, x_logical =1, x_integer =2, x_complex =3 }
 

Functions

static R_INLINE SEXP ALLOC_SLOT (SEXP obj, SEXP nm, SEXPTYPE type, int length)
 Allocate an SEXP of given type and length, assign it as slot nm in the object, and return the SEXP. More...
 
static R_INLINE Rboolean any_NA_in_x (SEXP obj)
 Check if slot(obj, "x") contains any NA (or NaN). More...
 
SEXP as_det_obj (double val, int log, int sign)
 
SEXP check_scalar_string (SEXP sP, char *vals, char *nm)
 Check validity of 1-letter string from a set of possible values (typically used in S4 validity method) More...
 
SEXP d_packed_addDiag (double *diag, int l_d, SEXP x, int n)
 
void d_packed_getDiag (double *dest, SEXP x, int n)
 Copy the diagonal elements of the packed denseMatrix x to dest. More...
 
SEXP d_packed_setDiag (double *diag, int l_d, SEXP x, int n)
 
SEXP dense_nonpacked_validate (SEXP obj)
 
SEXP dim_validate (SEXP Dim, const char *name)
 
SEXP Dim_validate (SEXP obj, SEXP name)
 
SEXP dimNames_validate (SEXP obj)
 
SEXP dup_mMatrix_as_dgeMatrix (SEXP A)
 
SEXP dup_mMatrix_as_dgeMatrix2 (SEXP A, Rboolean tr_if_vec)
 
SEXP dup_mMatrix_as_geMatrix (SEXP A)
 Duplicate a [dln]denseMatrix or a numeric matrix or even a vector as a [dln]geMatrix. More...
 
Rboolean equal_string_vectors (SEXP s1, SEXP s2)
 
static R_INLINE int * expand_cmprPt (int ncol, const int mp[], int mj[])
 Expand compressed pointers in the array mp into a full set of indices in the array mj. More...
 
 FULL_TO_PACKED (double)
 
 FULL_TO_PACKED (int)
 
double get_double_by_name (SEXP obj, char *nm)
 
SEXP get_factors (SEXP obj, char *nm)
 
static R_INLINE SEXP inv_permutation (SEXP p_, SEXP zero_p, SEXP zero_res)
 Inverse Permutation C version of .inv.perm.R <- function(p) { p[p] <- seq_along(p) ; p }. More...
 
void l_packed_getDiag (int *dest, SEXP x, int n)
 
SEXP l_packed_setDiag (int *diag, int l_d, SEXP x, int n)
 
char La_norm_type (const char *typstr)
 
char La_rcond_type (const char *typstr)
 
SEXP m_encodeInd (SEXP ij, SEXP di, SEXP orig_1, SEXP chk_bnds)
 Encode Matrix index (i,j) |–> i + j * nrow {i,j : 0-origin}. More...
 
SEXP m_encodeInd2 (SEXP i, SEXP j, SEXP di, SEXP orig_1, SEXP chk_bnds)
 Encode Matrix index (i,j) |–> i + j * nrow {i,j : 0-origin}. More...
 
void make_d_matrix_symmetric (double *to, SEXP from)
 
void make_d_matrix_triangular (double *x, SEXP from)
 
void make_i_matrix_symmetric (int *to, SEXP from)
 
void make_i_matrix_triangular (int *x, SEXP from)
 
static R_INLINE int Matrix_check_class (char *class, const char **valid)
 Return the 0-based index of a string match in a vector of strings terminated by an empty string. More...
 
SEXP Matrix_expand_pointers (SEXP pP)
 
SEXP Matrix_getElement (SEXP list, char *nm)
 Return the element of a given name from a named list. More...
 
SEXP Mmatrix (SEXP args)
 
static R_INLINE SEXP mMatrix_as_dgeMatrix (SEXP A)
 
static R_INLINE SEXP mMatrix_as_dgeMatrix2 (SEXP A, Rboolean tr_if_vec)
 
static R_INLINE SEXP mMatrix_as_geMatrix (SEXP A)
 
SEXP new_dgeMatrix (int nrow, int ncol)
 
static R_INLINE int packed_ncol (int len)
 Check for valid length of a packed triangular array and return the corresponding number of columns. More...
 
 PACKED_TO_FULL (double)
 
 PACKED_TO_FULL (int)
 
SEXP R_all0 (SEXP x)
 
SEXP R_any0 (SEXP x)
 
SEXP R_rbind2_vector (SEXP a, SEXP b)
 From the two 'x' slots of two dense matrices a and b, compute the 'x' slot of rbind(a, b) More...
 
SEXP R_set_factors (SEXP obj, SEXP val, SEXP name, SEXP warn)
 
SEXP R_symmetric_Dimnames (SEXP x)
 Even if the Dimnames slot is list(NULL, <names>) etc, return symmetric dimnames: Get . More...
 
static R_INLINE void SET_DimNames (SEXP dest, SEXP src)
 
void SET_DimNames_symm (SEXP dest, SEXP src)
 Set 'Dimnames' slot of 'dest' from the one of 'src' when 'src' is a "symmetricMatrix" with possibly asymmetric dimnames, and 'dest' must contain corresponding symmetric dimnames. More...
 
SEXP set_double_by_name (SEXP obj, double val, char *nm)
 
SEXP set_factors (SEXP obj, SEXP val, char *nm)
 Caches 'val' in the 'factors' slot of obj, i.e. More...
 
SEXP symmetric_DimNames (SEXP dn)
 Produce symmetric 'Dimnames' from possibly asymmetric ones. More...
 
SEXP symmetricMatrix_validate (SEXP obj)
 
SEXP tr_d_packed_addDiag (double *diag, int l_d, SEXP x, int n)
 
void tr_d_packed_getDiag (double *dest, SEXP x, int n)
 
SEXP tr_d_packed_setDiag (double *diag, int l_d, SEXP x, int n)
 
void tr_l_packed_getDiag (int *dest, SEXP x, int n)
 
SEXP tr_l_packed_setDiag (int *diag, int l_d, SEXP x, int n)
 
SEXP triangularMatrix_validate (SEXP obj)
 

Macro Definition Documentation

#define _ (   String)    (String)

Definition at line 32 of file Mutils.h.

Referenced by as_cholmod_factor(), as_cholmod_sparse(), as_cholmod_triplet(), check_scalar_string(), checkGivens(), chm_dense_to_SEXP(), chm_diagN2U(), chm_factor_ldetL2(), chm_factor_name(), chm_factor_to_SEXP(), chm_factor_update(), CHM_set_common_env(), chm_sparse_to_SEXP(), chm_transpose_dense(), chm_triplet_to_SEXP(), CHMfactor_solve(), CHMfactor_spsolve(), CHMfactor_to_sparse(), CHMfactor_updown(), compressed_to_TMatrix(), csp_eye(), Csparse_general_to_symmetric(), Csparse_sort(), Csparse_subassign(), Csparse_symmetric_to_general(), Csparse_to_nz_pattern(), d_insert_triplets_in_array(), ddense_skewpart(), ddense_symmpart(), dense_band(), dense_nonpacked_validate(), dense_to_symmetric(), dgCMatrix_cholsol(), dgCMatrix_LU(), dgCMatrix_matrix_solve(), dgCMatrix_QR(), dgCMatrix_qrsol(), dgeMatrix_addDiag(), dgeMatrix_determinant(), dgeMatrix_dtpMatrix_mm(), dgeMatrix_exp(), dgeMatrix_LU_(), dgeMatrix_matrix_solve(), dgeMatrix_rcond(), dgeMatrix_Schur(), dgeMatrix_solve(), dgeMatrix_validate(), dim_validate(), dimNames_validate(), dMatrix_validate(), dpoMatrix_chol(), dpoMatrix_dgeMatrix_solve(), dpoMatrix_matrix_solve(), dpoMatrix_validate(), dppMatrix_chol(), dppMatrix_matrix_solve(), dsCMatrix_to_dgTMatrix(), dspMatrix_matrix_mm(), dspMatrix_matrix_solve(), dspMatrix_trf(), dspMatrix_validate(), dsyMatrix_matrix_mm(), dsyMatrix_matrix_solve(), dsyMatrix_trf(), dtCMatrix_matrix_solve(), dtCMatrix_sparse_solve(), dtpMatrix_matrix_mm(), dtpMatrix_matrix_solve(), dtpMatrix_validate(), dtrMatrix_addDiag(), dtrMatrix_dtrMatrix_mm(), dtrMatrix_matrix_mm(), dtrMatrix_matrix_solve(), dup_mMatrix_as_dgeMatrix2(), dup_mMatrix_as_geMatrix(), equal_string_vectors(), get_double_by_name(), get_factors(), getGivens(), install_lu(), internal_chm_factor(), l_insert_triplets_in_array(), La_norm_type(), La_rcond_type(), lapack_qr(), left_cyclic(), lsq_dense_Chol(), lsq_dense_QR(), LU_validate(), m_encodeInd(), m_encodeInd2(), Matrix_as_cs(), Matrix_cs_to_SEXP(), Mmatrix(), nz2Csparse(), packed_ncol(), R_all0(), R_any0(), R_cholmod_error(), R_cholmod_start(), R_init_Matrix(), R_set_factors(), R_to_CMatrix(), Rsparse_validate(), set_double_by_name(), set_factors(), sparseQR_coef(), sparseQR_Qmult(), sparseQR_qty(), sparseQR_resid_fitted(), sparseQR_validate(), symmetricMatrix_validate(), tCMatrix_validate(), triangularMatrix_validate(), tRMatrix_validate(), Tsparse_validate(), tTMatrix_validate(), xCMatrix_validate(), xRMatrix_validate(), and xTMatrix_validate().

#define _dspV_

These are the ones "everyone" should use – is() versions, also looking at super classes:

They now use R(semi_API) from Rinternals.h : int R_check_class_and_super(SEXP x, const char **valid, SEXP rho); int R_check_class_etc (SEXP x, const char **valid);

R_check_class_etc (x, v) basically does rho <- .classEnv(x) and then calls R_check_class_and_super(x, v, rho) Accessing *sparseVectors : fast (and recycling) v[i] for v = ?sparseVector: -> ./sparseVector.c -> ./t_sparseVector.c :

Definition at line 471 of file Mutils.h.

#define _ispV_

Definition at line 474 of file Mutils.h.

#define _lspV_

Definition at line 477 of file Mutils.h.

#define _nspV_

Definition at line 480 of file Mutils.h.

#define _zspV_

Definition at line 483 of file Mutils.h.

#define Alloca (   n,
 
)    (t *) alloca( (size_t) ( (n) * sizeof(t) ) )

Definition at line 45 of file Mutils.h.

#define AZERO (   x,
 
)    {int _I_, _SZ_ = (n); for(_I_ = 0; _I_ < _SZ_; _I_++) (x)[_I_] = 0;}
#define C_or_Alloca_TO (   _VAR_,
  _N_,
  _TYPE_ 
)
Value:
if(_N_ < SMALL_4_Alloca) { \
_VAR_ = Alloca(_N_, _TYPE_); R_CheckStack(); \
} else { \
_VAR_ = Calloc(_N_, _TYPE_); \
}
#define SMALL_4_Alloca
Definition: Mutils.h:47
#define Alloca(n, t)
Definition: Mutils.h:45

Definition at line 50 of file Mutils.h.

Referenced by dgCMatrix_matrix_solve(), dgeMatrix_colsums(), dgeMatrix_Schur(), dgeMatrix_svd(), dspMatrix_matrix_mm(), dsyMatrix_matrix_mm(), dsyMatrix_trf(), gematrix_real_x(), LU_expand(), sparseQR_coef(), and sparseQR_Qmult().

#define CMJ   CblasColMajor

Definition at line 77 of file Mutils.h.

#define CTR   CblasConjTrans

Definition at line 80 of file Mutils.h.

#define DECLARE_AND_GET_X_SLOT (   __C_TYPE,
  __SEXP 
)    __C_TYPE *xx = __SEXP(GET_SLOT(x, Matrix_xSym))

Definition at line 198 of file Mutils.h.

#define Diag_P (   _x_)
Value:
(R_has_slot(x, Matrix_diagSym) ? \
CHAR(STRING_ELT(GET_SLOT(_x_, Matrix_diagSym), 0)) : " ")
SEXP Matrix_diagSym
Definition: Syms.h:2

Definition at line 176 of file Mutils.h.

#define dngettext (   pkg,
  String,
  StringP,
 
)    (N > 1 ? StringP : String)

Definition at line 34 of file Mutils.h.

Referenced by dim_validate().

#define FULL_TO_PACKED (   TYPE)
Value:
TYPE *full_to_packed_ ## TYPE(TYPE *dest, const TYPE *src, int n, \
enum CBLAS_UPLO uplo, enum CBLAS_DIAG diag)
CBLAS_DIAG
Definition: Mutils.h:74
CBLAS_UPLO
Definition: Mutils.h:73

Definition at line 128 of file Mutils.h.

#define LFT   CblasLeft

Definition at line 85 of file Mutils.h.

#define MATRIX_VALID_CHMfactor   "dCHMsuper", "dCHMsimpl", "nCHMsuper", "nCHMsimpl"

Definition at line 419 of file Mutils.h.

Referenced by as_cholmod_factor().

#define MATRIX_VALID_Csparse
Value:
"lgCMatrix", "lsCMatrix", "ltCMatrix", \
MATRIX_VALID_nCsparse, \
"zgCMatrix", "zsCMatrix", "ztCMatrix"
#define MATRIX_VALID_dCsparse
Definition: Mutils.h:379

Definition at line 384 of file Mutils.h.

Referenced by as_cholmod_sparse(), compressed_to_TMatrix(), Csparse_to_dense(), and Csparse_to_matrix().

#define MATRIX_VALID_dCsparse   "dgCMatrix", "dsCMatrix", "dtCMatrix"

Definition at line 379 of file Mutils.h.

#define MATRIX_VALID_ddense
Value:
"dgeMatrix", "dtrMatrix", \
"dsyMatrix", "dpoMatrix", "ddiMatrix", \
"dtpMatrix", "dspMatrix", "dppMatrix", \
/* sub classes of those above:*/ \
/* dtr */ "Cholesky", "LDL", "BunchKaufman",\
/* dtp */ "pCholesky", "pBunchKaufman", \
/* dpo */ "corMatrix"

Definition at line 360 of file Mutils.h.

Referenced by dup_mMatrix_as_dgeMatrix2(), and dup_mMatrix_as_geMatrix().

#define MATRIX_VALID_ge_dense
Value:
"dmatrix", "dgeMatrix", \
"lmatrix", "lgeMatrix", \
"nmatrix", "ngeMatrix", \
"zmatrix", "zgeMatrix"

Definition at line 349 of file Mutils.h.

#define MATRIX_VALID_ldense
Value:
"lgeMatrix", "ltrMatrix", \
"lsyMatrix", "ldiMatrix", \
"ltpMatrix", "lspMatrix"

Definition at line 369 of file Mutils.h.

Referenced by dup_mMatrix_as_geMatrix().

#define MATRIX_VALID_nCsparse   "ngCMatrix", "nsCMatrix", "ntCMatrix"

Definition at line 381 of file Mutils.h.

Referenced by nz2Csparse().

#define MATRIX_VALID_ndense
Value:
"ngeMatrix", "ntrMatrix", \
"nsyMatrix", \
"ntpMatrix", "nspMatrix"

Definition at line 374 of file Mutils.h.

Referenced by dup_mMatrix_as_geMatrix().

#define MATRIX_VALID_Rsparse
Value:
"dgRMatrix", "dsRMatrix", "dtRMatrix", \
"lgRMatrix", "lsRMatrix", "ltRMatrix", \
"ngRMatrix", "nsRMatrix", "ntRMatrix", \
"zgRMatrix", "zsRMatrix", "ztRMatrix"

Definition at line 396 of file Mutils.h.

Referenced by compressed_to_TMatrix(), and R_to_CMatrix().

#define MATRIX_VALID_tri_Csparse   "dtCMatrix", "ltCMatrix", "ntCMatrix", "ztCMatrix"

Definition at line 402 of file Mutils.h.

Referenced by Csparse_Csparse_crossprod(), and Csparse_Csparse_prod().

#define MATRIX_VALID_Tsparse
Value:
"dgTMatrix", "dsTMatrix", "dtTMatrix", \
"lgTMatrix", "lsTMatrix", "ltTMatrix", \
"ngTMatrix", "nsTMatrix", "ntTMatrix", \
"zgTMatrix", "zsTMatrix", "ztTMatrix"

Definition at line 390 of file Mutils.h.

Referenced by as_cholmod_triplet().

#define Memzero (   p,
 
)    memset(p, 0, (size_t)(n) * sizeof(*p))

Definition at line 142 of file Mutils.h.

#define NTR   CblasNoTrans

Definition at line 78 of file Mutils.h.

#define PACKED_LENGTH (   n)    ((n) * ((n) + 1))/2

Definition at line 145 of file Mutils.h.

#define PACKED_TO_FULL (   TYPE)
Value:
TYPE *packed_to_full_ ## TYPE(TYPE *dest, const TYPE *src, \
int n, enum CBLAS_UPLO uplo)
CBLAS_UPLO
Definition: Mutils.h:73

Definition at line 121 of file Mutils.h.

#define Real_KIND (   _x_)
Value:
(IS_S4_OBJECT(_x_) ? Real_kind(_x_) : \
(isReal(_x_) ? x_double : (isLogical(_x_) ? x_logical : -1)))
#define Real_kind(_x_)
Definition: Mutils.h:195

Definition at line 188 of file Mutils.h.

#define Real_kind (   _x_)
Value:
(isReal(GET_SLOT(_x_, Matrix_xSym)) ? 0 : \
(isLogical(GET_SLOT(_x_, Matrix_xSym)) ? 1 : -1))
SEXP Matrix_xSym
Definition: Syms.h:2

Definition at line 195 of file Mutils.h.

Referenced by Csparse_general_to_symmetric(), Csparse_symmetric_to_general(), Csparse_to_dense(), Csparse_to_tCsparse(), Csparse_to_Tsparse(), Csparse_to_tTsparse(), Csparse_transpose(), Tsparse_to_Csparse(), and Tsparse_to_tCsparse().

#define Real_KIND2 (   _x_)
Value:
(IS_S4_OBJECT(_x_) ? Real_kind(_x_) : \
(isLogical(_x_) ? x_logical : 0))
#define Real_kind(_x_)
Definition: Mutils.h:195

Definition at line 191 of file Mutils.h.

Referenced by dense_to_Csparse().

#define RGT   CblasRight

Definition at line 86 of file Mutils.h.

#define RMJ   CblasRowMajor

Definition at line 76 of file Mutils.h.

#define slot_dup_if_has (   dest,
  src,
  sym 
)
Value:
if(R_has_slot(src, sym)) \
SET_SLOT(dest, sym, duplicate(GET_SLOT(src, sym)))

Definition at line 156 of file Mutils.h.

Referenced by nz2Csparse().

#define slot_nonNull_dup (   dest,
  src,
  sym 
)
Value:
if(GET_SLOT(src, sym) != R_NilValue) \
SET_SLOT(dest, sym, duplicate(GET_SLOT(src, sym)))

Definition at line 152 of file Mutils.h.

#define TRN   CblasTrans

Definition at line 79 of file Mutils.h.

#define UNT   CblasUnit

Definition at line 84 of file Mutils.h.

Referenced by dtrMatrix_as_dtpMatrix(), and ltrMatrix_as_ltpMatrix().

#define XLENGTH (   x)    LENGTH(x)

Definition at line 39 of file Mutils.h.

Referenced by dense_nonpacked_validate(), LU_validate(), Mmatrix(), R_all0(), and R_any0().

Enumeration Type Documentation

enum CBLAS_DIAG
Enumerator
CblasNonUnit 
CblasUnit 

Definition at line 74 of file Mutils.h.

Enumerator
CblasRowMajor 
CblasColMajor 

Definition at line 71 of file Mutils.h.

enum CBLAS_SIDE
Enumerator
CblasLeft 
CblasRight 

Definition at line 75 of file Mutils.h.

Enumerator
CblasNoTrans 
CblasTrans 
CblasConjTrans 

Definition at line 72 of file Mutils.h.

enum CBLAS_UPLO
Enumerator
CblasUpper 
CblasLower 

Definition at line 73 of file Mutils.h.

enum dense_enum
Enumerator
ddense 
ldense 
ndense 

Definition at line 181 of file Mutils.h.

Enumerator
x_pattern 
x_double 
x_logical 
x_integer 
x_complex 

Definition at line 184 of file Mutils.h.

Function Documentation

static R_INLINE SEXP ALLOC_SLOT ( SEXP  obj,
SEXP  nm,
SEXPTYPE  type,
int  length 
)
static

Allocate an SEXP of given type and length, assign it as slot nm in the object, and return the SEXP.

The validity of this function depends on SET_SLOT not duplicating val when NAMED(val) == 0. If this behavior changes then ALLOC_SLOT must use SET_SLOT followed by GET_SLOT to ensure that the value returned is indeed the SEXP in the slot. NOTE: GET_SLOT(x, what) :== R_do_slot (x, what) -— SET_SLOT(x, what, value) :== R_do_slot_assign(x, what, value) and the R_do_slot* are in src/main/attrib.c

Parameters
objobject in which to assign the slot
nmname of the slot, as an R name object
typetype of SEXP to allocate
lengthlength of SEXP to allocate
Returns
SEXP of given type and length assigned as slot nm in obj

Definition at line 240 of file Mutils.h.

Referenced by chm_dense_to_SEXP(), chm_factor_to_SEXP(), chm_sparse_to_SEXP(), chm_triplet_to_SEXP(), compressed_to_TMatrix(), Csparse_subassign(), dgCMatrix_QR(), dgeMatrix_LU_(), dpoMatrix_chol(), dspMatrix_as_dsyMatrix(), dspMatrix_trf(), dsyMatrix_as_dspMatrix(), dsyMatrix_trf(), dtCMatrix_matrix_solve(), dtCMatrix_sparse_solve(), dtpMatrix_as_dtrMatrix(), dtrMatrix_as_dtpMatrix(), dtrMatrix_dtrMatrix_mm(), dup_mMatrix_as_geMatrix(), gCMatrix_colSums(), install_lu(), lspMatrix_as_lsyMatrix(), lsyMatrix_as_lspMatrix(), ltpMatrix_as_ltrMatrix(), ltrMatrix_as_ltpMatrix(), LU_expand(), Matrix_cs_to_SEXP(), new_dgeMatrix(), nz2Csparse(), R_to_CMatrix(), and Tsparse_diagU2N().

Here is the caller graph for this function:

static R_INLINE Rboolean any_NA_in_x ( SEXP  obj)
static

Check if slot(obj, "x") contains any NA (or NaN).

Parameters
obja 'Matrix' object with a (double precision) 'x' slot.
Returns
Rboolean :== any(is.na(slot(obj, "x") )

Definition at line 277 of file Mutils.h.

References Matrix_xSym.

Referenced by get_norm().

Here is the caller graph for this function:

SEXP as_det_obj ( double  val,
int  log,
int  sign 
)

Definition at line 89 of file Mutils.c.

Referenced by dgeMatrix_determinant().

Here is the caller graph for this function:

SEXP check_scalar_string ( SEXP  sP,
char *  vals,
char *  nm 
)

Check validity of 1-letter string from a set of possible values (typically used in S4 validity method)

Parameters
sP
valsa string containing the possible valid letters
nmthe name of the slot being checked
Returns
a SEXP, either NULL (= success) or an error message

Definition at line 254 of file Mutils.c.

References _, and SPRINTF.

Referenced by symmetricMatrix_validate(), and triangularMatrix_validate().

Here is the caller graph for this function:

SEXP d_packed_addDiag ( double *  diag,
int  l_d,
SEXP  x,
int  n 
)

Definition at line 523 of file Mutils.c.

References Matrix_xSym, and uplo_P.

Referenced by tr_d_packed_addDiag().

Here is the caller graph for this function:

void d_packed_getDiag ( double *  dest,
SEXP  x,
int  n 
)

Copy the diagonal elements of the packed denseMatrix x to dest.

Parameters
destvector of length ncol(x)
x(pointer to) a "d?pMatrix" object
nnumber of columns in the matrix represented by x
Returns
dest

Definition at line 433 of file Mutils.c.

References END_packed_getDiag, and Matrix_xSym.

Referenced by dspMatrix_getDiag(), and tr_d_packed_getDiag().

Here is the caller graph for this function:

SEXP d_packed_setDiag ( double *  diag,
int  l_d,
SEXP  x,
int  n 
)

Definition at line 461 of file Mutils.c.

References END_packed_setDiag, and SET_packed_setDiag.

Referenced by dspMatrix_setDiag().

Here is the caller graph for this function:

SEXP dense_nonpacked_validate ( SEXP  obj)

Definition at line 310 of file Mutils.c.

References _, Matrix_DimSym, Matrix_xSym, and XLENGTH.

Referenced by dgeMatrix_validate(), and dpoMatrix_validate().

Here is the caller graph for this function:

SEXP dim_validate ( SEXP  Dim,
const char *  name 
)

Definition at line 318 of file Mutils.c.

References _, and dngettext.

Referenced by dgeMatrix_validate(), Dim_validate(), dMatrix_validate(), and MatrixFactorization_validate().

Here is the caller graph for this function:

SEXP Dim_validate ( SEXP  obj,
SEXP  name 
)

Definition at line 337 of file Mutils.c.

References dim_validate(), and Matrix_DimSym.

Here is the call graph for this function:

SEXP dimNames_validate ( SEXP  obj)

Definition at line 343 of file Mutils.c.

References _, Matrix_DimNamesSym, and Matrix_DimSym.

Referenced by LU_validate().

Here is the caller graph for this function:

SEXP dup_mMatrix_as_dgeMatrix2 ( SEXP  A,
Rboolean  tr_if_vec 
)

Definition at line 821 of file Mutils.c.

References _, class_P, DUP_MMATRIX_ddense_CASES, DUP_MMATRIX_NON_CLASS, DUP_MMATRIX_SET_1, Matrix_DimNamesSym, Matrix_DimSym, and MATRIX_VALID_ddense.

Referenced by dup_mMatrix_as_dgeMatrix(), and mMatrix_as_dgeMatrix2().

Here is the caller graph for this function:

SEXP dup_mMatrix_as_geMatrix ( SEXP  A)

Duplicate a [dln]denseMatrix or a numeric matrix or even a vector as a [dln]geMatrix.

This is for the many "*_matrix_{prod,crossprod,tcrossprod, etc.}" functions that work with both classed and unclassed matrices.

Used generally for Generalized – "geMatrix" – dispatch where needed.

Parameters
Aeither a denseMatrix, a diagonalMatrix or a traditional matrix object

Definition at line 648 of file Mutils.c.

References _, ALLOC_SLOT(), class_P, ddense, DUP_MMATRIX_ddense_CASES, DUP_MMATRIX_NON_CLASS, DUP_MMATRIX_SET_1, install_diagonal_int(), ldense, LOW, make_i_matrix_symmetric(), make_i_matrix_triangular(), Matrix_DimNamesSym, Matrix_DimSym, MATRIX_VALID_ddense, MATRIX_VALID_ldense, MATRIX_VALID_ndense, Matrix_xSym, ndense, uplo_P, and UPP.

Referenced by dense_band(), dense_to_symmetric(), geMatrix_crossprod(), geMatrix_geMatrix_crossprod(), geMatrix_matrix_crossprod(), geMatrix_matrix_mm(), and mMatrix_as_geMatrix().

Here is the call graph for this function:

Here is the caller graph for this function:

Rboolean equal_string_vectors ( SEXP  s1,
SEXP  s2 
)

Definition at line 286 of file Mutils.c.

References _.

Referenced by Csparse_general_to_symmetric(), and dense_to_symmetric().

Here is the caller graph for this function:

static R_INLINE int* expand_cmprPt ( int  ncol,
const int  mp[],
int  mj[] 
)
static

Expand compressed pointers in the array mp into a full set of indices in the array mj.

Parameters
ncolnumber of columns (or rows)
mpcolumn pointer vector of length ncol + 1
mjvector of length mp[ncol] to hold the result
Returns
mj

Definition at line 259 of file Mutils.h.

Referenced by compressed_non_0_ij(), compressed_to_TMatrix(), Matrix_expand_pointers(), tCMatrix_validate(), and tRMatrix_validate().

Here is the caller graph for this function:

FULL_TO_PACKED ( double  )
FULL_TO_PACKED ( int  )
double get_double_by_name ( SEXP  obj,
char *  nm 
)

Definition at line 44 of file Mutils.c.

References _.

SEXP get_factors ( SEXP  obj,
char *  nm 
)

Definition at line 106 of file Mutils.c.

References _, and Matrix_factorSym.

Referenced by dgCMatrix_LU(), dgCMatrix_matrix_solve(), dgeMatrix_LU_(), dpoMatrix_chol(), dppMatrix_chol(), dspMatrix_trf(), and dsyMatrix_trf().

Here is the caller graph for this function:

static R_INLINE SEXP inv_permutation ( SEXP  p_,
SEXP  zero_p,
SEXP  zero_res 
)
static

Inverse Permutation C version of .inv.perm.R <- function(p) { p[p] <- seq_along(p) ; p }.

Definition at line 293 of file Mutils.h.

void l_packed_getDiag ( int *  dest,
SEXP  x,
int  n 
)

Definition at line 450 of file Mutils.c.

References END_packed_getDiag, and Matrix_xSym.

Referenced by lspMatrix_getDiag(), and tr_l_packed_getDiag().

Here is the caller graph for this function:

SEXP l_packed_setDiag ( int *  diag,
int  l_d,
SEXP  x,
int  n 
)

Definition at line 491 of file Mutils.c.

References END_packed_setDiag, and SET_packed_setDiag.

Referenced by lspMatrix_setDiag().

Here is the caller graph for this function:

char La_norm_type ( const char *  typstr)

Definition at line 8 of file Mutils.c.

References _.

Referenced by get_norm(), get_norm_sp(), and get_norm_sy().

Here is the caller graph for this function:

char La_rcond_type ( const char *  typstr)

Definition at line 27 of file Mutils.c.

References _.

Referenced by dgeMatrix_rcond(), dtpMatrix_rcond(), and dtrMatrix_rcond().

Here is the caller graph for this function:

SEXP m_encodeInd ( SEXP  ij,
SEXP  di,
SEXP  orig_1,
SEXP  chk_bnds 
)

Encode Matrix index (i,j) |–> i + j * nrow {i,j : 0-origin}.

Parameters
ij2-column integer matrix
didim(.), i.e. length 2 integer vector
chk_bndslogical indicating 0 <= ij[,k] < di[k] need to be checked.
Returns
encoded index; integer if prod(dim) is small; double otherwise

Definition at line 880 of file Mutils.c.

References _, and do_ii_FILL.

SEXP m_encodeInd2 ( SEXP  i,
SEXP  j,
SEXP  di,
SEXP  orig_1,
SEXP  chk_bnds 
)

Encode Matrix index (i,j) |–> i + j * nrow {i,j : 0-origin}.

Parameters
iinteger vector
jinteger vector of same length as 'i'
orig_1logical: if TRUE, "1-origin" otherwise "0-origin"
didim(.), i.e. length 2 integer vector
chk_bndslogical indicating 0 <= ij[,k] < di[k] need to be checked.
Returns
encoded index; integer if prod(dim) is small; double otherwise

Definition at line 945 of file Mutils.c.

References _, and do_ii_FILL.

void make_d_matrix_symmetric ( double *  to,
SEXP  from 
)

Referenced by dsyMatrix_as_matrix().

Here is the caller graph for this function:

void make_d_matrix_triangular ( double *  x,
SEXP  from 
)

Referenced by dtrMatrix_as_matrix(), dtrMatrix_dtrMatrix_mm(), and LU_expand().

Here is the caller graph for this function:

void make_i_matrix_symmetric ( int *  to,
SEXP  from 
)

Referenced by dup_mMatrix_as_geMatrix(), and lsyMatrix_as_lgeMatrix().

Here is the caller graph for this function:

void make_i_matrix_triangular ( int *  x,
SEXP  from 
)

Referenced by dup_mMatrix_as_geMatrix(), and ltrMatrix_as_lgeMatrix().

Here is the caller graph for this function:

static R_INLINE int Matrix_check_class ( char *  class,
const char **  valid 
)
static

Return the 0-based index of a string match in a vector of strings terminated by an empty string.

Returns -1 for no match. Is cheap : not looking at superclasses –> better use R_check_class_etc(obj, *)

Parameters
classstring to match
validvector of possible matches terminated by an empty string
Returns
index of match or -1 for no match

Definition at line 432 of file Mutils.h.

Referenced by Matrix_cs_to_SEXP().

Here is the caller graph for this function:

SEXP Matrix_expand_pointers ( SEXP  pP)

Definition at line 571 of file Mutils.c.

References expand_cmprPt().

Here is the call graph for this function:

SEXP Matrix_getElement ( SEXP  list,
char *  nm 
)

Return the element of a given name from a named list.

Parameters
list
nmname of desired element
Returns
element of list with name nm

Definition at line 592 of file Mutils.c.

SEXP Mmatrix ( SEXP  args)

Definition at line 980 of file Mutils.c.

References _, and XLENGTH.

static R_INLINE SEXP mMatrix_as_dgeMatrix ( SEXP  A)
static

Definition at line 334 of file Mutils.h.

References class_P, and dup_mMatrix_as_dgeMatrix().

Referenced by dgeMatrix_matrix_mm(), and dsCMatrix_matrix_solve().

Here is the call graph for this function:

Here is the caller graph for this function:

static R_INLINE SEXP mMatrix_as_dgeMatrix2 ( SEXP  A,
Rboolean  tr_if_vec 
)
static

Definition at line 338 of file Mutils.h.

References class_P, and dup_mMatrix_as_dgeMatrix2().

Here is the call graph for this function:

static R_INLINE SEXP mMatrix_as_geMatrix ( SEXP  A)
static

Definition at line 343 of file Mutils.h.

References class_P, and dup_mMatrix_as_geMatrix().

Referenced by dense_to_Csparse().

Here is the call graph for this function:

Here is the caller graph for this function:

SEXP new_dgeMatrix ( int  nrow,
int  ncol 
)

Definition at line 856 of file Mutils.c.

References ALLOC_SLOT(), Matrix_DimNamesSym, Matrix_DimSym, and Matrix_xSym.

Here is the call graph for this function:

static R_INLINE int packed_ncol ( int  len)
static

Check for valid length of a packed triangular array and return the corresponding number of columns.

Parameters
lenlength of a packed triangular array
Returns
number of columns

Definition at line 211 of file Mutils.h.

References _.

PACKED_TO_FULL ( double  )
PACKED_TO_FULL ( int  )
SEXP R_all0 ( SEXP  x)

Definition at line 1180 of file Mutils.c.

References _, FALSE_, TRUE_, and XLENGTH.

SEXP R_any0 ( SEXP  x)

Definition at line 1222 of file Mutils.c.

References _, FALSE_, TRUE_, and XLENGTH.

SEXP R_rbind2_vector ( SEXP  a,
SEXP  b 
)

From the two 'x' slots of two dense matrices a and b, compute the 'x' slot of rbind(a, b)

Currently, an auxiliary only for setMethod rbind2(<denseMatrix>, <denseMatrix>) in ../R/bind2.R

Parameters
a
b
Returns

Definition at line 1120 of file Mutils.c.

SEXP R_set_factors ( SEXP  obj,
SEXP  val,
SEXP  name,
SEXP  warn 
)

Definition at line 166 of file Mutils.c.

References _, Matrix_factorSym, and set_factors().

Here is the call graph for this function:

SEXP R_symmetric_Dimnames ( SEXP  x)

Even if the Dimnames slot is list(NULL, <names>) etc, return symmetric dimnames: Get .

and modify when needed.

Called e.g., from symmetricDimnames() in ../R/symmetricMatrix.R

Parameters
froma symmetricMatrix
Returns
symmetric dimnames: length-2 list twice the same, NULL or character vector (of correct length)

Definition at line 1315 of file Mutils.c.

References Matrix_DimNamesSym, and symmetric_DimNames().

Referenced by dsyMatrix_as_matrix().

Here is the call graph for this function:

Here is the caller graph for this function:

static R_INLINE void SET_DimNames ( SEXP  dest,
SEXP  src 
)
static

Definition at line 161 of file Mutils.h.

References Matrix_DimNamesSym.

Referenced by compressed_to_TMatrix(), dtrMatrix_dtrMatrix_mm(), R_to_CMatrix(), and Tsparse_diagU2N().

Here is the caller graph for this function:

void SET_DimNames_symm ( SEXP  dest,
SEXP  src 
)

Set 'Dimnames' slot of 'dest' from the one of 'src' when 'src' is a "symmetricMatrix" with possibly asymmetric dimnames, and 'dest' must contain corresponding symmetric dimnames.

Parameters
destMatrix, typically not symmetric
srcsymmetricMatrix

Definition at line 1328 of file Mutils.c.

References Matrix_DimNamesSym, NON_TRIVIAL_DN, and SYMM_DIMNAMES.

SEXP set_double_by_name ( SEXP  obj,
double  val,
char *  nm 
)

Definition at line 60 of file Mutils.c.

References _.

SEXP set_factors ( SEXP  obj,
SEXP  val,
char *  nm 
)

Caches 'val' in the 'factors' slot of obj, i.e.

modifies obj, and returns val. In the past this function installed a duplicate of factors slot for obj then returned the (typically unprotected) val. This is now changed to return the duplicate, which will be protected if obj is protected.

Definition at line 130 of file Mutils.c.

References _, and Matrix_factorSym.

Referenced by dgeMatrix_LU_(), dpoMatrix_chol(), dppMatrix_chol(), dspMatrix_trf(), dsyMatrix_trf(), install_lu(), internal_chm_factor(), and R_set_factors().

Here is the caller graph for this function:

SEXP symmetric_DimNames ( SEXP  dn)

Produce symmetric 'Dimnames' from possibly asymmetric ones.

Parameters
dnlist of length 2; typically 'Dimnames' slot of "symmetricMatrix"

Definition at line 1269 of file Mutils.c.

References NON_TRIVIAL_DN, and SYMM_DIMNAMES.

Referenced by Csparse_general_to_symmetric(), Csparse_symmetric_to_general(), Csparse_to_matrix(), and R_symmetric_Dimnames().

Here is the caller graph for this function:

SEXP symmetricMatrix_validate ( SEXP  obj)

Definition at line 3 of file dsyMatrix.c.

References _, check_scalar_string(), Matrix_DimSym, and Matrix_uploSym.

Referenced by dspMatrix_validate().

Here is the call graph for this function:

Here is the caller graph for this function:

SEXP tr_d_packed_addDiag ( double *  diag,
int  l_d,
SEXP  x,
int  n 
)

Definition at line 539 of file Mutils.c.

References d_packed_addDiag(), diag_P, and Matrix_diagSym.

Referenced by dtpMatrix_addDiag().

Here is the call graph for this function:

Here is the caller graph for this function:

void tr_d_packed_getDiag ( double *  dest,
SEXP  x,
int  n 
)

Definition at line 551 of file Mutils.c.

References d_packed_getDiag(), and diag_P.

Referenced by dtpMatrix_getDiag().

Here is the call graph for this function:

Here is the caller graph for this function:

SEXP tr_d_packed_setDiag ( double *  diag,
int  l_d,
SEXP  x,
int  n 
)

Definition at line 505 of file Mutils.c.

References SET_packed_setDiag, and tr_END_packed_setDiag.

Referenced by dtpMatrix_setDiag().

Here is the caller graph for this function:

void tr_l_packed_getDiag ( int *  dest,
SEXP  x,
int  n 
)

Definition at line 561 of file Mutils.c.

References diag_P, and l_packed_getDiag().

Referenced by ltpMatrix_getDiag().

Here is the call graph for this function:

Here is the caller graph for this function:

SEXP tr_l_packed_setDiag ( int *  diag,
int  l_d,
SEXP  x,
int  n 
)

Definition at line 511 of file Mutils.c.

References SET_packed_setDiag, and tr_END_packed_setDiag.

Referenced by ltpMatrix_setDiag().

Here is the caller graph for this function:

SEXP triangularMatrix_validate ( SEXP  obj)

Definition at line 5 of file dtrMatrix.c.

References _, check_scalar_string(), Matrix_diagSym, Matrix_DimSym, and Matrix_uploSym.

Referenced by dtpMatrix_validate().

Here is the call graph for this function:

Here is the caller graph for this function: