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

Go to the source code of this file.

Macros

#define COPY_a_AND_b_j
 
#define do_ii_FILL(_i_, _j_)
 
#define DUP_MMATRIX_ddense_CASES
 
#define DUP_MMATRIX_NON_CLASS(transpose_if_vec)
 
#define DUP_MMATRIX_SET_1
 
#define END_packed_getDiag
 
#define END_packed_setDiag
 
#define FALSE_   ScalarLogical(0)
 
#define FULL_TO_PACKED(TYPE)
 
#define MAKE_SYMMETRIC_BODY(_TO_, _FROM_)
 
#define MAKE_TRIANGULAR_BODY(_TO_, _FROM_, _ZERO_, _ONE_)
 
#define Matrix_Error_Bufsiz   4096
 
#define NON_TRIVIAL_DN
 
#define PACKED_TO_FULL(TYPE)
 
#define SET_packed_setDiag
 
#define SPRINTF   buf = Alloca(Matrix_Error_Bufsiz, char); R_CheckStack(); sprintf
 
#define SYMM_DIMNAMES
 
#define tr_END_packed_setDiag
 
#define TRUE_   ScalarLogical(1)
 

Functions

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)
 
double get_double_by_name (SEXP obj, char *nm)
 
SEXP get_factors (SEXP obj, char *nm)
 
static double * install_diagonal (double *dest, SEXP A)
 Zero a square matrix of size nc then copy a vector to the diagonal. More...
 
static int * install_diagonal_int (int *dest, SEXP A)
 
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_i_matrix_symmetric(int *to
 
void make_d_matrix_triangular (double *to, SEXP from) void make_i_matrix_triangular(int *to
 
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)
 
SEXP new_dgeMatrix (int nrow, int ncol)
 
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...
 
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 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)
 

Macro Definition Documentation

#define COPY_a_AND_b_j
Value:
/* FIXME faster: use Memcpy() : */ \
for(int j=0; j < m; j++) { \
for(i=0; i < n1; i++) r[ii++] = ax[j*n1 + i]; \
for(i=0; i < n2; i++) r[ii++] = bx[j*n2 + i]; \
}
#define do_ii_FILL (   _i_,
  _j_ 
)
Value:
int i; \
if(check_bounds) { \
for(i=0; i < n; i++) { \
if(_i_[i] == NA_INTEGER || _j_[i] == NA_INTEGER) \
ii[i] = NA_INTEGER; \
else { \
register int i_i, j_i; \
if(one_ind) { i_i = _i_[i]-1; j_i = _j_[i]-1; } \
else { i_i = _i_[i] ; j_i = _j_[i] ; } \
if(i_i < 0 || i_i >= Di[0]) \
error(_("subscript 'i' out of bounds in M[ij]")); \
if(j_i < 0 || j_i >= Di[1]) \
error(_("subscript 'j' out of bounds in M[ij]")); \
ii[i] = i_i + j_i * nr; \
} \
} \
} else { \
for(i=0; i < n; i++) \
ii[i] = (_i_[i] == NA_INTEGER || _j_[i] == NA_INTEGER) \
? NA_INTEGER \
: (one_ind ? ((_i_[i]-1) + (_j_[i]-1)*nr) \
: _i_[i] + _j_[i] *nr); \
}
#define _(String)
Definition: Mutils.h:32

Referenced by m_encodeInd(), and m_encodeInd2().

#define DUP_MMATRIX_ddense_CASES
#define DUP_MMATRIX_NON_CLASS (   transpose_if_vec)
Value:
if (isMatrix(A)) { /* "matrix" */ \
ad = getAttrib(A, R_DimSymbol); \
an = getAttrib(A, R_DimNamesSymbol); \
} else {/* maybe "numeric" (incl integer,logical) --> (n x 1) */ \
int* dd = INTEGER(ad = PROTECT(allocVector(INTSXP, 2))); \
nprot++; \
if(transpose_if_vec) { \
dd[0] = 1; \
dd[1] = LENGTH(A); \
} else { \
dd[0] = LENGTH(A); \
dd[1] = 1; \
} \
SEXP nms = getAttrib(A, R_NamesSymbol); \
if(nms != R_NilValue) { \
an = PROTECT(allocVector(VECSXP, 2)); \
nprot++; \
SET_VECTOR_ELT(an, (transpose_if_vec)? 1 : 0, nms); \
/* not needed: SET_VECTOR_ELT(an, 1, R_NilValue); */ \
} /* else nms = NULL ==> an remains NULL */ \
} \
ctype = 0

Referenced by dup_mMatrix_as_dgeMatrix2(), and dup_mMatrix_as_geMatrix().

#define DUP_MMATRIX_SET_1
Value:
SET_SLOT(ans, Matrix_DimSym, duplicate(ad)); \
SET_SLOT(ans, Matrix_DimNamesSym, (LENGTH(an) == 2) ? \
duplicate(an): allocVector(VECSXP, 2)); \
sz = INTEGER(ad)[0] * INTEGER(ad)[1]
SEXP Matrix_DimSym
Definition: Syms.h:2
SEXP Matrix_DimNamesSym
Definition: Syms.h:2

Referenced by dup_mMatrix_as_dgeMatrix2(), and dup_mMatrix_as_geMatrix().

#define END_packed_getDiag
Value:
int j, pos = 0; \
\
if (*uplo_P(x) == 'U') { \
for(pos= 0, j=0; j < n; pos += 1+(++j)) dest[j] = xx[pos]; \
} else { \
for(pos= 0, j=0; j < n; pos += (n - j), j++) dest[j] = xx[pos]; \
} \
return
#define uplo_P(_x_)
Definition: Mutils.h:174

Referenced by d_packed_getDiag(), and l_packed_getDiag().

#define END_packed_setDiag
Value:
int j, pos = 0; \
\
if (*uplo_P(x) == 'U') { \
if(d_full) \
for(pos= 0, j=0; j < n; pos += 1+(++j)) xx[pos] = diag[j]; \
else /* l_d == 1 */ \
for(pos= 0, j=0; j < n; pos += 1+(++j)) xx[pos] = *diag; \
} else { \
if(d_full) \
for(pos= 0, j=0; j < n; pos += (n - j), j++) xx[pos] = diag[j]; \
else /* l_d == 1 */ \
for(pos= 0, j=0; j < n; pos += (n - j), j++) xx[pos] = *diag; \
} \
UNPROTECT(1); \
return ret
#define uplo_P(_x_)
Definition: Mutils.h:174

Referenced by d_packed_setDiag(), and l_packed_setDiag().

#define FALSE_   ScalarLogical(0)

Definition at line 1175 of file Mutils.c.

Referenced by R_all0(), and R_any0().

#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) \
{ \
int i, j, pos = 0; \
\
for (j = 0; j < n; j++) { \
switch(uplo) { \
case UPP: \
for (i = 0; i <= j; i++) \
dest[pos++] = (i == j && diag== UNT) ? 1 : src[i + j*n]; \
break; \
case LOW: \
for (i = j; i < n; i++) \
dest[pos++] = (i == j && diag== UNT) ? 1 : src[i + j*n]; \
break; \
default: \
error(_("'uplo' must be UPP or LOW")); \
} \
} \
return dest; \
}
#define UPP
Definition: Mutils.h:81
CBLAS_DIAG
Definition: Mutils.h:74
#define _(String)
Definition: Mutils.h:32
#define LOW
Definition: Mutils.h:82
#define UNT
Definition: Mutils.h:84
CBLAS_UPLO
Definition: Mutils.h:73

Definition at line 396 of file Mutils.c.

#define MAKE_SYMMETRIC_BODY (   _TO_,
  _FROM_ 
)
Value:
{ \
int i, j, n = INTEGER(GET_SLOT(_FROM_, Matrix_DimSym))[0]; \
\
if (*uplo_P(_FROM_) == 'U') { \
for (j = 0; j < n; j++) \
for (i = j+1; i < n; i++) \
_TO_[i + j*n] = _TO_[j + i*n]; \
} else { \
for (j = 1; j < n; j++) \
for (i = 0; i < j && i < n; i++) \
_TO_[i + j*n] = _TO_[j + i*n]; \
} \
}
SEXP Matrix_DimSym
Definition: Syms.h:2
#define uplo_P(_x_)
Definition: Mutils.h:174

Definition at line 220 of file Mutils.c.

#define MAKE_TRIANGULAR_BODY (   _TO_,
  _FROM_,
  _ZERO_,
  _ONE_ 
)
Value:
{ \
int i, j, *dims = INTEGER(GET_SLOT(_FROM_, Matrix_DimSym)); \
int n = dims[0], m = dims[1]; \
\
if (*uplo_P(_FROM_) == 'U') { \
for (j = 0; j < n; j++) \
for (i = j+1; i < m; i++) \
_TO_[i + j*m] = _ZERO_; \
} else { \
for (j = 1; j < n; j++) \
for (i = 0; i < j && i < m; i++) \
_TO_[i + j*m] = _ZERO_; \
} \
if (*diag_P(_FROM_) == 'U') { \
j = (n < m) ? n : m; \
for (i = 0; i < j; i++) \
_TO_[i * (m + 1)] = _ONE_; \
} \
}
SEXP Matrix_DimSym
Definition: Syms.h:2
#define uplo_P(_x_)
Definition: Mutils.h:174
#define diag_P(_x_)
Definition: Mutils.h:175

Definition at line 192 of file Mutils.c.

#define Matrix_Error_Bufsiz   4096

Definition at line 242 of file Mutils.c.

#define NON_TRIVIAL_DN
Value:
!isNull(VECTOR_ELT(dn, 0)) || \
!isNull(VECTOR_ELT(dn, 1)) || \
(do_nm = !isNull(getAttrib(dn, R_NamesSymbol)))

Referenced by SET_DimNames_symm(), and symmetric_DimNames().

#define PACKED_TO_FULL (   TYPE)
Value:
TYPE *packed_to_full_ ## TYPE(TYPE *dest, const TYPE *src, \
int n, enum CBLAS_UPLO uplo) \
{ \
int i, j, pos = 0; \
AZERO(dest, n*n); \
for (j = 0; j < n; j++) { \
switch(uplo) { \
case UPP: \
for (i = 0; i <= j; i++) dest[i + j * n] = src[pos++]; \
break; \
case LOW: \
for (i = j; i < n; i++) dest[i + j * n] = src[pos++]; \
break; \
default: \
error(_("'uplo' must be UPP or LOW")); \
} \
} \
return dest; \
}
#define UPP
Definition: Mutils.h:81
#define AZERO(x, n)
Definition: Mutils.h:140
#define _(String)
Definition: Mutils.h:32
#define LOW
Definition: Mutils.h:82
CBLAS_UPLO
Definition: Mutils.h:73

Definition at line 371 of file Mutils.c.

#define SET_packed_setDiag
Value:
SEXP ret = PROTECT(duplicate(x)), \
r_x = GET_SLOT(ret, Matrix_xSym); \
Rboolean d_full = (l_d == n); \
if (!d_full && l_d != 1) \
error(_("replacement diagonal has wrong length"))
SEXP Matrix_xSym
Definition: Syms.h:2
#define _(String)
Definition: Mutils.h:32

Referenced by d_packed_setDiag(), l_packed_setDiag(), tr_d_packed_setDiag(), and tr_l_packed_setDiag().

#define SPRINTF   buf = Alloca(Matrix_Error_Bufsiz, char); R_CheckStack(); sprintf

Referenced by check_scalar_string().

#define SYMM_DIMNAMES
Value:
/* Fixup dimnames to be symmetric <==> \
symmetricDimnames() in ../R/symmetricMatrix.R */ \
PROTECT(dn = duplicate(dn)); \
if (isNull(VECTOR_ELT(dn,0))) \
SET_VECTOR_ELT(dn, 0, VECTOR_ELT(dn, 1)); \
if (isNull(VECTOR_ELT(dn,1))) \
SET_VECTOR_ELT(dn, 1, VECTOR_ELT(dn, 0)); \
if(do_nm) { /* names(dimnames(.)): */ \
SEXP nms_dn = getAttrib(dn, R_NamesSymbol); \
if(!R_compute_identical(STRING_ELT(nms_dn, 0), \
STRING_ELT(nms_dn, 1), 16)) { \
PROTECT(nms_dn); \
int J = LENGTH(STRING_ELT(nms_dn, 0)) == 0; /* 0/1 */ \
SET_STRING_ELT(nms_dn, !J, STRING_ELT(nms_dn, J)); \
setAttrib(dn, R_NamesSymbol, nms_dn); \
UNPROTECT(1); \
} \
} \
UNPROTECT(1)

Referenced by SET_DimNames_symm(), and symmetric_DimNames().

#define tr_END_packed_setDiag
Value:
if (*diag_P(x) == 'U') { /* uni-triangular */ \
/* after setting, typically is not uni-triangular anymore: */ \
SET_STRING_ELT(GET_SLOT(ret, Matrix_diagSym), 0, mkChar("N")); \
} \
END_packed_setDiag
#define diag_P(_x_)
Definition: Mutils.h:175
SEXP Matrix_diagSym
Definition: Syms.h:2

Definition at line 497 of file Mutils.c.

Referenced by tr_d_packed_setDiag(), and tr_l_packed_setDiag().

#define TRUE_   ScalarLogical(1)

Definition at line 1174 of file Mutils.c.

Referenced by R_all0(), and R_any0().

Function Documentation

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:

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 double* install_diagonal ( double *  dest,
SEXP  A 
)
static

Zero a square matrix of size nc then copy a vector to the diagonal.

Parameters
destdestination array of length nc * nc
Apointer to a square Matrix object
Returns
dest

Definition at line 611 of file Mutils.c.

References AZERO, diag_P, Matrix_DimSym, and Matrix_xSym.

static int* install_diagonal_int ( int *  dest,
SEXP  A 
)
static

Definition at line 624 of file Mutils.c.

References AZERO, diag_P, Matrix_DimSym, and Matrix_xSym.

Referenced by dup_mMatrix_as_geMatrix().

Here is the caller graph for this function:

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 *  to,
SEXP  from 
)

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

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.

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:

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:

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 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: