Matrix r4655
Loading...
Searching...
No Matches
Macros | Functions
coerce.c File Reference
#include <math.h>
#include "Mdefines.h"
#include "idz.h"
#include "coerce.h"

Go to the source code of this file.

Macros

#define VAD_SUBCASES(_PREFIX_, _CTYPE_, _PTR_, _NA_)
 
#define SAD_CASES
 
#define SAD_SUBCASES(_CTYPE_, _PTR_, _MASK_, _REPLACE_, _INCREMENT_, _ONE_)
 
#define SAD_SUBSUBCASES(_LOOP_C_, _LOOP_R_, _LOOP_T_, _MASK_, _REPLACE_, _INCREMENT_)
 
#define SAD_LOOP_C2NP(_MASK_, _REPLACE_, _INCREMENT_)
 
#define SAD_LOOP_C2UP(_MASK_, _REPLACE_, _INCREMENT_)
 
#define SAD_LOOP_C2LP(_MASK_, _REPLACE_, _INCREMENT_)
 
#define SAD_LOOP_R2NP(_MASK_, _REPLACE_, _INCREMENT_)
 
#define SAD_LOOP_R2UP(_MASK_, _REPLACE_, _INCREMENT_)
 
#define SAD_LOOP_R2LP(_MASK_, _REPLACE_, _INCREMENT_)
 
#define SAD_LOOP_T2NP(_MASK_, _REPLACE_, _INCREMENT_)
 
#define SAD_LOOP_T2UP(_MASK_, _REPLACE_, _INCREMENT_)
 
#define SAD_LOOP_T2LP(_MASK_, _REPLACE_, _INCREMENT_)
 
#define DAD_SUBCASES(_PREFIX_, _CTYPE_, _PTR_)
 
#define IAD_SUBCASES(_CTYPE_, _PTR_, _ONE_)
 
#define VAS_SUBCASES(...)
 
#define VAS_SUBSUBCASES()
 
#define VAS_SUBSUBCASES(_MASK0_, _MASK1_, _REPLACE_, _CTYPE_, _PTR_, _ONE_, _NA_)
 
#define DAS_CASES(_MASK_)
 
#define DAS_SUBCASES(_CTYPE_, _PTR_, _MASK_, _ISNZ_)
 
#define DAS_SUBSUBCASES(_LOOP_C_, _LOOP_R_, _LOOP_T_, _MASK_, _ISNZ_)
 
#define DAS_LOOP_GEN2C(_ISNZ_, _DO_INNER_, _DO_OUTER_)
 
#define DAS_LOOP_GEN2R(_ISNZ_, _DO_INNER_, _DO_OUTER_)
 
#define DAS_LOOP_TRN2C(_ISNZ_, _DO_INNER_, _DO_OUTER_)
 
#define DAS_LOOP_TRN2R(_ISNZ_, _DO_INNER_, _DO_OUTER_)
 
#define DAS_LOOP_TRU2C(_ISNZ_, _DO_INNER_, _DO_OUTER_)
 
#define DAS_LOOP_TRU2R(_ISNZ_, _DO_INNER_, _DO_OUTER_)
 
#define DAS_LOOP_TPN2C(_ISNZ_, _DO_INNER_, _DO_OUTER_)
 
#define DAS_LOOP_TPN2R(_ISNZ_, _DO_INNER_, _DO_OUTER_)
 
#define DAS_LOOP_TPU2C(_ISNZ_, _DO_INNER_, _DO_OUTER_)
 
#define DAS_LOOP_TPU2R(_ISNZ_, _DO_INNER_, _DO_OUTER_)
 
#define DAS_VALID2T
 
#define DAS_VALID2C    do { DAS_VALID2T; else *(pp++) = (int) nnz; } while (0)
 
#define DAS_VALID2R   DAS_VALID2C
 
#define DAS_SUBSUBCASES(_LOOP_C_, _LOOP_R_, _LOOP_T_, _MASK_, _ISNZ_)
 
#define DAS_CASES(_MASK_)
 
#define DAS_LOOP(_CTYPE_, _PTR_, _MASK_, _ISNZ_, _ONE_)
 
#define DAS_LOOP(_CTYPE_, _PTR_, _MASK_, _ISNZ_, _ONE_)
 
#define DAS_LOOP(_CTYPE_, _PTR_, _MASK_, _ISNZ_, _ONE_)
 
#define IAS_SUBCASES(_CTYPE_, _PTR_, _ONE_)
 
#define DAG_SUBCASES(_PREFIX_, _CTYPE_, _PTR_)
 
#define ASSIGN_COMPLEX_JJ(_X_, _Y_)    do { _X_.r = _Y_.r; _X_.i = 0.0; } while (0)
 
#define ASSIGN_COMPLEX_JI(_X_, _Y_)    do { _X_.r = _Y_.r; _X_.i = -_Y_.i; } while (0)
 
#define SAG_CASES
 
#define SAG_SUBCASES(_CTYPE_, _PTR_, _MASK_, _ONE_, _ASSIGN_JJ_, _ASSIGN_JI_)
 
#define SAG_SUBCASES(_CTYPE_, _PTR_, _MASK_, _ONE_, _ASSIGN_JJ_, _ASSIGN_JI_)
 
#define UNPACK(_PREFIX_, _CTYPE_, _PTR_)
 
#define PACK(_PREFIX_, _CTYPE_, _PTR_)
 
#define TRANS_LOOP(_CTYPE_, _PTR_, _MASK_)
 
#define TSORT_LOOP(_CTYPE_, _PTR_, _MASK_, _INCREMENT_)
 
#define TAGGR_LOOP(_CTYPE_, _PTR_, _MASK_, _INCREMENT_)
 

Functions

SEXP vector_as_dense (SEXP from, const char *zzz, char ul, char di, int m, int n, int byrow, SEXP dimnames)
 
SEXP R_vector_as_dense (SEXP from, SEXP zzz, SEXP uplo, SEXP diag, SEXP m, SEXP n, SEXP byrow, SEXP dimnames)
 
SEXP matrix_as_dense (SEXP from, const char *zzz, char ul, char di, int trans, int new)
 
SEXP R_matrix_as_dense (SEXP from, SEXP zzz, SEXP uplo, SEXP diag, SEXP trans)
 
SEXP sparse_as_dense (SEXP from, const char *class, int packed)
 
SEXP R_sparse_as_dense (SEXP from, SEXP packed)
 
SEXP diagonal_as_dense (SEXP from, const char *class, char kind, char shape, int packed, char ul)
 
SEXP R_diagonal_as_dense (SEXP from, SEXP kind, SEXP shape, SEXP packed, SEXP uplo)
 
SEXP index_as_dense (SEXP from, const char *class, char kind)
 
SEXP R_index_as_dense (SEXP from, SEXP kind)
 
SEXP vector_as_sparse (SEXP from, const char *zzz, char ul, char di, int m, int n, int byrow, SEXP dimnames)
 
SEXP R_vector_as_sparse (SEXP from, SEXP zzz, SEXP uplo, SEXP diag, SEXP m, SEXP n, SEXP byrow, SEXP dimnames)
 
SEXP matrix_as_sparse (SEXP from, const char *zzz, char ul, char di, int trans)
 
SEXP R_matrix_as_sparse (SEXP from, SEXP zzz, SEXP uplo, SEXP diag, SEXP trans)
 
SEXP dense_as_sparse (SEXP from, const char *class, char repr)
 
SEXP R_dense_as_sparse (SEXP from, SEXP repr)
 
SEXP diagonal_as_sparse (SEXP from, const char *class, char kind, char shape, char repr, char ul)
 
SEXP R_diagonal_as_sparse (SEXP from, SEXP kind, SEXP shape, SEXP repr, SEXP uplo)
 
SEXP index_as_sparse (SEXP from, const char *class, char kind, char repr)
 
SEXP R_index_as_sparse (SEXP from, SEXP kind, SEXP repr)
 
SEXP dense_as_kind (SEXP from, const char *class, char kind, int new)
 
SEXP R_dense_as_kind (SEXP from, SEXP kind)
 
SEXP sparse_as_kind (SEXP from, const char *class, char kind)
 
SEXP R_sparse_as_kind (SEXP from, SEXP kind)
 
SEXP diagonal_as_kind (SEXP from, const char *class, char kind)
 
SEXP R_diagonal_as_kind (SEXP from, SEXP kind)
 
SEXP index_as_kind (SEXP from, const char *class, char kind)
 
SEXP R_index_as_kind (SEXP from, SEXP kind)
 
SEXP dense_as_general (SEXP from, const char *class, int new)
 
SEXP R_dense_as_general (SEXP from)
 
SEXP sparse_as_general (SEXP from, const char *class)
 
SEXP R_sparse_as_general (SEXP from)
 
SEXP dense_as_unpacked (SEXP from, const char *class)
 
SEXP R_dense_as_unpacked (SEXP from)
 
SEXP dense_as_packed (SEXP from, const char *class, char ul, char di)
 
SEXP R_dense_as_packed (SEXP from, SEXP uplo, SEXP diag)
 
void trans (SEXP p0, SEXP i0, SEXP x0, SEXP p1, SEXP i1, SEXP x1, int m, int n)
 
void tsort (SEXP i0, SEXP j0, SEXP x0, SEXP *p1, SEXP *i1, SEXP *x1, int m, int n)
 
void taggr (SEXP i0, SEXP j0, SEXP x0, SEXP *i1, SEXP *j1, SEXP *x1, int m, int n)
 
SEXP sparse_as_Csparse (SEXP from, const char *class)
 
SEXP R_sparse_as_Csparse (SEXP from)
 
SEXP sparse_as_Rsparse (SEXP from, const char *class)
 
SEXP R_sparse_as_Rsparse (SEXP from)
 
SEXP sparse_as_Tsparse (SEXP from, const char *class)
 
SEXP R_sparse_as_Tsparse (SEXP from)
 
SEXP R_Matrix_as_vector (SEXP from)
 
SEXP R_Matrix_as_matrix (SEXP from)
 
SEXP R_Matrix_as_unpacked (SEXP from)
 
SEXP R_Matrix_as_packed (SEXP from)
 
SEXP R_Matrix_as_Csparse (SEXP from)
 
SEXP R_Matrix_as_Rsparse (SEXP from)
 
SEXP R_Matrix_as_Tsparse (SEXP from)
 
SEXP R_Matrix_as_kind (SEXP from, SEXP kind, SEXP sparse)
 
SEXP R_Matrix_as_general (SEXP from, SEXP kind)
 

Macro Definition Documentation

◆ ASSIGN_COMPLEX_JI

#define ASSIGN_COMPLEX_JI (   _X_,
  _Y_ 
)     do { _X_.r = _Y_.r; _X_.i = -_Y_.i; } while (0)

◆ ASSIGN_COMPLEX_JJ

#define ASSIGN_COMPLEX_JJ (   _X_,
  _Y_ 
)     do { _X_.r = _Y_.r; _X_.i = 0.0; } while (0)

◆ DAD_SUBCASES

#define DAD_SUBCASES (   _PREFIX_,
  _CTYPE_,
  _PTR_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
Matrix_memset(px1, 0, (R_xlen_t) len, sizeof(_CTYPE_)); \
if (di == 'N' || cl[1] != 't') { \
if (cl[2] != 'p') \
_PREFIX_ ## dcpy2(px1, px0, n, n, ul, di); \
else \
_PREFIX_ ## dcpy1(px1, px0, n, n, ul, ul, di); \
} \
} while (0)
cholmod_common cl
Definition cholmod-etc.c:6

◆ DAG_SUBCASES

#define DAG_SUBCASES (   _PREFIX_,
  _CTYPE_,
  _PTR_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
if (class[2] == 'p') \
_PREFIX_ ## unpack1(px1, px0, n, ul, di); \
else if (new) \
Matrix_memcpy(px1, px0, (R_xlen_t) n * n, sizeof(_CTYPE_)); \
if (class[1] == 's') \
_PREFIX_ ## syforce2(px1, n, ul); \
else \
_PREFIX_ ## trforce2(px1, n, n, ul, di); \
} while (0)

◆ DAS_CASES [1/2]

#define DAS_CASES (   _MASK_)
Value:
do { \
switch (class[0]) { \
case 'l': \
DAS_SUBCASES(int, LOGICAL, _MASK_, ISNZ_LOGICAL); \
break; \
case 'i': \
DAS_SUBCASES(int, INTEGER, _MASK_, ISNZ_INTEGER); \
break; \
case 'd': \
DAS_SUBCASES(double, REAL, _MASK_, ISNZ_REAL); \
break; \
case 'z': \
DAS_SUBCASES(Rcomplex, COMPLEX, _MASK_, ISNZ_COMPLEX); \
break; \
default: \
break; \
} \
} while (0)
#define ISNZ_REAL(_X_)
Definition Mdefines.h:111
#define ISNZ_LOGICAL(_X_)
Definition Mdefines.h:109
#define ISNZ_INTEGER(_X_)
Definition Mdefines.h:110
#define ISNZ_COMPLEX(_X_)
Definition Mdefines.h:112

◆ DAS_CASES [2/2]

#define DAS_CASES (   _MASK_)
Value:
do { \
switch (cl[0]) { \
case 'l': \
DAS_LOOP(int, LOGICAL, _MASK_, ISNZ_LOGICAL, 1); \
break; \
case 'i': \
DAS_LOOP(int, INTEGER, _MASK_, ISNZ_INTEGER, 1); \
break; \
case 'd': \
DAS_LOOP(double, REAL, _MASK_, ISNZ_REAL, 1.0); \
break; \
case 'z': \
DAS_LOOP(Rcomplex, COMPLEX, _MASK_, ISNZ_COMPLEX, Matrix_zone); \
break; \
default: \
break; \
} \
} while (0)
Rcomplex Matrix_zone
Definition init.c:26

◆ DAS_LOOP [1/3]

#define DAS_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ISNZ_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0); \
for (d = 0; d < n; ++d) { \
if (_ISNZ_(*px0)) \
++nnz; \
*(pp++) = nnz; \
++px0; \
} \
} while (0)

◆ DAS_LOOP [2/3]

#define DAS_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ISNZ_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0); \
for (d = 0; d < n; ++d) { \
if (_ISNZ_(*px0)) \
++nnz; \
++px0; \
} \
} while (0)

◆ DAS_LOOP [3/3]

#define DAS_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ISNZ_,
  _ONE_ 
)
Value:
do { \
_MASK_(_CTYPE_ *px1 = _PTR_(x1)); \
if (di == 'N') { \
_CTYPE_ *px0 = _PTR_(x0); \
for (d = 0; d < n; ++d) { \
if (_ISNZ_(*px0)) { \
*(pi1++) = d; \
_MASK_(*(px1++) = *px0); \
} \
++px0; \
} \
} else { \
for (d = 0; d < n; ++d) { \
*(pi1++) = d; \
_MASK_(*(px1++) = _ONE_); \
} \
} \
} while (0)

◆ DAS_LOOP_GEN2C

#define DAS_LOOP_GEN2C (   _ISNZ_,
  _DO_INNER_,
  _DO_OUTER_ 
)
Value:
do { \
for (j = 0; j < n; ++j) { \
for (i = 0; i < m; ++i, ++px0) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} while (0)

◆ DAS_LOOP_GEN2R

#define DAS_LOOP_GEN2R (   _ISNZ_,
  _DO_INNER_,
  _DO_OUTER_ 
)
Value:
do { \
R_xlen_t mn1s = (R_xlen_t) m * n - 1; \
for (i = 0; i < m; ++i, px0 -= mn1s) { \
for (j = 0; j < n; ++j, px0 += m) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} while (0)

◆ DAS_LOOP_TPN2C

#define DAS_LOOP_TPN2C (   _ISNZ_,
  _DO_INNER_,
  _DO_OUTER_ 
)
Value:
do { \
if (ul == 'U') { \
for (j = 0; j < n; ++j) { \
for (i = 0; i <= j; ++i, ++px0) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} else { \
for (j = 0; j < n; ++j) { \
for (i = j; i < n; ++i, ++px0) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} \
} while (0)

◆ DAS_LOOP_TPN2R

#define DAS_LOOP_TPN2R (   _ISNZ_,
  _DO_INNER_,
  _DO_OUTER_ 
)
Value:
do { \
R_xlen_t d; \
if (ul == 'U') { \
d = PACKED_LENGTH(n) - 1; \
for (i = 0; i < n; px0 -= (d -= (++i))) { \
for (j = i; j < n; px0 += (++j)) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} else { \
d = -1; \
for (i = 0; i < n; px0 -= (d += n - (++i))) { \
for (j = 0; j <= i; px0 += n - (++j)) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} \
} while (0)
#define PACKED_LENGTH(m)
Definition Mdefines.h:198

◆ DAS_LOOP_TPU2C

#define DAS_LOOP_TPU2C (   _ISNZ_,
  _DO_INNER_,
  _DO_OUTER_ 
)
Value:
do { \
if (ul == 'U') { \
for (j = 1; j < n; ++j) { \
++px0; \
for (i = 0; i < j; ++i, ++px0) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} else { \
for (j = 0; j < n; ++j) { \
++px0; \
for (i = j + 1; i < n; ++i, ++px0) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} \
} while (0)

◆ DAS_LOOP_TPU2R

#define DAS_LOOP_TPU2R (   _ISNZ_,
  _DO_INNER_,
  _DO_OUTER_ 
)
Value:
do { \
R_xlen_t d; \
if (ul == 'U') { \
d = PACKED_LENGTH(n - 1) - 1; \
for (i = 0; i < n; ++i) { \
for (j = i + 1; j < n; ++j) { \
px0 += j; \
if (_ISNZ_(*px0)) _DO_INNER_; \
} \
_DO_OUTER_; \
px0 -= (d -= i + 1); \
} \
} else { \
++px0; \
d = -1; \
for (i = 1; i < n; ++i) { \
for (j = 0; j < i; ++j) { \
if (_ISNZ_(*px0)) _DO_INNER_; \
px0 += n - j - 1; \
} \
_DO_OUTER_; \
px0 -= (d += n - i); \
} \
} \
} while (0)

◆ DAS_LOOP_TRN2C

#define DAS_LOOP_TRN2C (   _ISNZ_,
  _DO_INNER_,
  _DO_OUTER_ 
)
Value:
do { \
if (ul == 'U') { \
for (j = 0; j < n; px0 += n - (++j)) { \
for (i = 0; i <= j; ++i, ++px0) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} else { \
for (j = 0; j < n; px0 += (++j)) { \
for (i = j; i < n; ++i, ++px0) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} \
} while (0)

◆ DAS_LOOP_TRN2R

#define DAS_LOOP_TRN2R (   _ISNZ_,
  _DO_INNER_,
  _DO_OUTER_ 
)
Value:
do { \
R_xlen_t d; \
if (ul == 'U') { \
d = (R_xlen_t) n * n - 1; \
for (i = 0; i < n; ++i, px0 -= (d -= n)) { \
for (j = i; j < n; ++j, px0 += n) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} else { \
d = -1; \
for (i = 0; i < n; ++i, px0 -= (d += n)) { \
for (j = 0; j <= i; ++j, px0 += n) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} \
} while (0)

◆ DAS_LOOP_TRU2C

#define DAS_LOOP_TRU2C (   _ISNZ_,
  _DO_INNER_,
  _DO_OUTER_ 
)
Value:
do { \
if (ul == 'U') { \
px0 += n; \
for (j = 1; j < n; ++j) { \
for (i = 0; i < j; ++i, ++px0) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
px0 += n - j; \
} \
} else { \
for (j = 0; j < n; ++j) { \
px0 += j + 1; \
for (i = j + 1; i < n; ++i, ++px0) \
if (_ISNZ_(*px0)) _DO_INNER_; \
_DO_OUTER_; \
} \
} \
} while (0)

◆ DAS_LOOP_TRU2R

#define DAS_LOOP_TRU2R (   _ISNZ_,
  _DO_INNER_,
  _DO_OUTER_ 
)
Value:
do { \
R_xlen_t d; \
if (ul == 'U') { \
d = (R_xlen_t) n * (n - 1) - 1; \
for (i = 0; i < n; ++i) { \
for (j = i + 1; j < n; ++j) { \
px0 += n; \
if (_ISNZ_(*px0)) _DO_INNER_; \
} \
_DO_OUTER_; \
px0 -= (d -= n); \
} \
} else { \
++px0; \
d = -1; \
for (i = 1; i < n; ++i) { \
for (j = 0; j < i; ++j) { \
if (_ISNZ_(*px0)) _DO_INNER_; \
px0 += n; \
} \
_DO_OUTER_; \
px0 -= (d += n); \
} \
} \
} while (0)

◆ DAS_SUBCASES

#define DAS_SUBCASES (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ISNZ_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0) ; \
_MASK_(_CTYPE_ *px1 = _PTR_(x1)); \
if (class[1] == 'g') \
/* .geMatrix */ \
_MASK_, _ISNZ_); \
else if (class[2] != 'p' && di == 'N') \
/* .syMatrix, non-unit diagonal .trMatrix */ \
_MASK_, _ISNZ_); \
else if (class[2] != 'p') \
/* unit diagonal .trMatrix */ \
_MASK_, _ISNZ_); \
else if (di == 'N') \
/* .spMatrix, non-unit diagonal .tpMatrix */ \
_MASK_, _ISNZ_); \
else \
/* unit diagonal .tpMatrix */ \
_MASK_, _ISNZ_); \
} while (0)
#define DAS_LOOP_TPU2R(_ISNZ_, _DO_INNER_, _DO_OUTER_)
#define DAS_LOOP_GEN2C(_ISNZ_, _DO_INNER_, _DO_OUTER_)
#define DAS_LOOP_TPN2C(_ISNZ_, _DO_INNER_, _DO_OUTER_)
#define DAS_LOOP_TPU2C(_ISNZ_, _DO_INNER_, _DO_OUTER_)
#define DAS_LOOP_TRN2R(_ISNZ_, _DO_INNER_, _DO_OUTER_)
#define DAS_LOOP_TRN2C(_ISNZ_, _DO_INNER_, _DO_OUTER_)
#define DAS_LOOP_TRU2R(_ISNZ_, _DO_INNER_, _DO_OUTER_)
#define DAS_LOOP_TPN2R(_ISNZ_, _DO_INNER_, _DO_OUTER_)
#define DAS_LOOP_GEN2R(_ISNZ_, _DO_INNER_, _DO_OUTER_)
#define DAS_LOOP_TRU2C(_ISNZ_, _DO_INNER_, _DO_OUTER_)

◆ DAS_SUBSUBCASES [1/2]

#define DAS_SUBSUBCASES (   _LOOP_C_,
  _LOOP_R_,
  _LOOP_T_,
  _MASK_,
  _ISNZ_ 
)
Value:
do { \
switch (cl[2]) { \
case 'C': \
_LOOP_C_(_ISNZ_, ++nnz, DAS_VALID2C); \
break; \
case 'R': \
_LOOP_R_(_ISNZ_, ++nnz, DAS_VALID2R); \
break; \
case 'T': \
_LOOP_T_(_ISNZ_, ++nnz, DAS_VALID2T); \
break; \
default: \
break; \
} \
} while (0)
#define DAS_VALID2T
#define DAS_VALID2R
#define DAS_VALID2C

◆ DAS_SUBSUBCASES [2/2]

#define DAS_SUBSUBCASES (   _LOOP_C_,
  _LOOP_R_,
  _LOOP_T_,
  _MASK_,
  _ISNZ_ 
)
Value:
do { \
switch (repr) { \
case 'C': \
_LOOP_C_(_ISNZ_, \
do { \
*(pi++) = i; \
_MASK_(*(px1++) = *px0); \
} while (0), ); \
break; \
case 'R': \
_LOOP_R_(_ISNZ_, \
do { \
*(pj++) = j; \
_MASK_(*(px1++) = *px0); \
} while (0), ); \
break; \
case 'T': \
_LOOP_T_(_ISNZ_, \
do { \
*(pi++) = i; \
*(pj++) = j; \
_MASK_(*(px1++) = *px0); \
} while (0), ); \
break; \
default: \
break; \
} \
} while (0)

◆ DAS_VALID2C

#define DAS_VALID2C    do { DAS_VALID2T; else *(pp++) = (int) nnz; } while (0)

◆ DAS_VALID2R

#define DAS_VALID2R   DAS_VALID2C

◆ DAS_VALID2T

#define DAS_VALID2T
Value:
if (nnz > INT_MAX) \
error(_("attempt to construct %s with more than %s nonzero entries"), \
"sparseMatrix", "2^31-1")
#define _(String)
Definition Mdefines.h:44

◆ IAD_SUBCASES

#define IAD_SUBCASES (   _CTYPE_,
  _PTR_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *px = _PTR_(x); \
Matrix_memset(px, 0, (R_xlen_t) len, sizeof(_CTYPE_)); \
if (mg == 0) { \
R_xlen_t m1 = (R_xlen_t) m; \
for (int i = 0; i < m; ++i) \
px[i + m1 * (*(pperm++) - 1)] = _ONE_; \
} else { \
for (int j = 0; j < n; ++j, px += m) \
px[ *(pperm++) - 1 ] = _ONE_; \
} \
} while (0)

◆ IAS_SUBCASES

#define IAS_SUBCASES (   _CTYPE_,
  _PTR_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *px = _PTR_(x); \
for (int k = 0; k < r; ++k) \
*(px++) = _ONE_; \
} while (0)

◆ PACK

#define PACK (   _PREFIX_,
  _CTYPE_,
  _PTR_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
_PREFIX_ ## pack2(px1, px0, n, ul, 'N'); \
} while (0)

◆ SAD_CASES

#define SAD_CASES
Value:
do { \
switch (class[0]) { \
case 'l': \
SAD_SUBCASES(int, LOGICAL, SHOW, FIRSTOF, INCREMENT_LOGICAL, 1); \
break; \
case 'i': \
SAD_SUBCASES(int, INTEGER, SHOW, FIRSTOF, INCREMENT_INTEGER, 1); \
break; \
case 'd': \
SAD_SUBCASES(double, REAL, SHOW, FIRSTOF, INCREMENT_REAL, 1.0); \
break; \
case 'z': \
SAD_SUBCASES(Rcomplex, COMPLEX, SHOW, FIRSTOF, INCREMENT_COMPLEX, Matrix_zone); \
break; \
default: \
break; \
} \
} while (0)
#define FIRSTOF(x, y)
Definition Mdefines.h:99
#define INCREMENT_REAL(_X_, _Y_)
Definition Mdefines.h:169
#define INCREMENT_COMPLEX(_X_, _Y_)
Definition Mdefines.h:173
#define INCREMENT_INTEGER(_X_, _Y_)
Definition Mdefines.h:155
#define SHOW(...)
Definition Mdefines.h:201
#define INCREMENT_LOGICAL(_X_, _Y_)
Definition Mdefines.h:147

◆ SAD_LOOP_C2LP

#define SAD_LOOP_C2LP (   _MASK_,
  _REPLACE_,
  _INCREMENT_ 
)
Value:
do { \
for (j = 0, k = 0; j < n; px1 += n - (j++)) { \
kend = pp[j]; \
while (k < kend) { \
px1[*pi - j] = _REPLACE_(*px0, 1); \
++k; ++pi; _MASK_(++px0); \
} \
} \
} while (0)

◆ SAD_LOOP_C2NP

#define SAD_LOOP_C2NP (   _MASK_,
  _REPLACE_,
  _INCREMENT_ 
)
Value:
do { \
for (j = 0, k = 0; j < n; ++j, px1 += m) { \
kend = pp[j]; \
while (k < kend) { \
px1[*pi] = _REPLACE_(*px0, 1); \
++k; ++pi; _MASK_(++px0); \
} \
} \
} while (0)

◆ SAD_LOOP_C2UP

#define SAD_LOOP_C2UP (   _MASK_,
  _REPLACE_,
  _INCREMENT_ 
)
Value:
do { \
for (j = 0, k = 0; j < n; px1 += (++j)) { \
kend = pp[j]; \
while (k < kend) { \
px1[*pi] = _REPLACE_(*px0, 1); \
++k; ++pi; _MASK_(++px0); \
} \
} \
} while (0)

◆ SAD_LOOP_R2LP

#define SAD_LOOP_R2LP (   _MASK_,
  _REPLACE_,
  _INCREMENT_ 
)
Value:
do { \
R_xlen_t n2 = (R_xlen_t) n * 2; \
for (i = 0, k = 0; i < n; ++i) { \
kend = pp[i]; \
while (k < kend) { \
px1[PACKED_AR21_LO(i, *pj, n2)] = _REPLACE_(*px0, 1); \
++k; ++pj; _MASK_(++px0); \
} \
} \
} while (0)
#define PACKED_AR21_LO(i, j, m2)
Definition Mdefines.h:196

◆ SAD_LOOP_R2NP

#define SAD_LOOP_R2NP (   _MASK_,
  _REPLACE_,
  _INCREMENT_ 
)
Value:
do { \
R_xlen_t m1 = (R_xlen_t) m; \
for (i = 0, k = 0; i < m; ++i, ++px1) { \
kend = pp[i]; \
while (k < kend) { \
px1[m1 * *pj] = _REPLACE_(*px0, 1); \
++k; ++pj; _MASK_(++px0); \
} \
} \
} while (0)

◆ SAD_LOOP_R2UP

#define SAD_LOOP_R2UP (   _MASK_,
  _REPLACE_,
  _INCREMENT_ 
)
Value:
do { \
for (i = 0, k = 0; i < n; ++i) { \
kend = pp[i]; \
while (k < kend) { \
px1[PACKED_AR21_UP(i, *pj)] = _REPLACE_(*px0, 1); \
++k; ++pj; _MASK_(++px0); \
} \
} \
} while (0)
#define PACKED_AR21_UP(i, j)
Definition Mdefines.h:194

◆ SAD_LOOP_T2LP

#define SAD_LOOP_T2LP (   _MASK_,
  _REPLACE_,
  _INCREMENT_ 
)
Value:
do { \
R_xlen_t n2 = (R_xlen_t) n * 2; \
for (k = 0; k < nnz; ++k) { \
index = PACKED_AR21_LO(*pi, *pj, n2); \
_INCREMENT_(px1[index], (*px0)); \
++pi; ++pj; _MASK_(++px0); \
} \
} while (0)

◆ SAD_LOOP_T2NP

#define SAD_LOOP_T2NP (   _MASK_,
  _REPLACE_,
  _INCREMENT_ 
)
Value:
do { \
R_xlen_t m1 = (R_xlen_t) m; \
for (k = 0; k < nnz; ++k) { \
index = m1 * *pj + *pi; \
_INCREMENT_(px1[index], (*px0)); \
++pi; ++pj; _MASK_(++px0); \
} \
} while (0)

◆ SAD_LOOP_T2UP

#define SAD_LOOP_T2UP (   _MASK_,
  _REPLACE_,
  _INCREMENT_ 
)
Value:
do { \
for (k = 0; k < nnz; ++k) { \
index = PACKED_AR21_UP(*pi, *pj); \
_INCREMENT_(px1[index], (*px0)); \
++pi; ++pj; _MASK_(++px0); \
} \
} while (0)

◆ SAD_SUBCASES

#define SAD_SUBCASES (   _CTYPE_,
  _PTR_,
  _MASK_,
  _REPLACE_,
  _INCREMENT_,
  _ONE_ 
)

◆ SAD_SUBSUBCASES

#define SAD_SUBSUBCASES (   _LOOP_C_,
  _LOOP_R_,
  _LOOP_T_,
  _MASK_,
  _REPLACE_,
  _INCREMENT_ 
)
Value:
do { \
switch (class[2]) { \
case 'C': \
{ \
int j, k, kend; \
_LOOP_C_(_MASK_, _REPLACE_, _INCREMENT_); \
break; \
} \
case 'R': \
{ \
int i, k, kend; \
_LOOP_R_(_MASK_, _REPLACE_, _INCREMENT_); \
break; \
} \
case 'T': \
{ \
R_xlen_t index, k, nnz = XLENGTH(i0); \
_LOOP_T_(_MASK_, _REPLACE_, _INCREMENT_); \
break; \
} \
default: \
break; \
} \
} while (0)

◆ SAG_CASES

#define SAG_CASES
Value:
do { \
switch (class[0]) { \
case 'l': \
SAG_SUBCASES(int, LOGICAL, SHOW, 1, \
break; \
case 'i': \
SAG_SUBCASES(int, INTEGER, SHOW, 1, \
break; \
case 'd': \
SAG_SUBCASES(double, REAL, SHOW, 1.0, \
break; \
case 'z': \
SAG_SUBCASES(Rcomplex, COMPLEX, SHOW, Matrix_zone, \
break; \
default: \
break; \
} \
} while (0)
#define ASSIGN_REAL(_X_, _Y_)
Definition Mdefines.h:179
#define ASSIGN_COMPLEX_JI(_X_, _Y_)
#define ASSIGN_COMPLEX_JJ(_X_, _Y_)

◆ SAG_SUBCASES [1/2]

#define SAG_SUBCASES (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ONE_,
  _ASSIGN_JJ_,
  _ASSIGN_JI_ 
)

◆ SAG_SUBCASES [2/2]

#define SAG_SUBCASES (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ONE_,
  _ASSIGN_JJ_,
  _ASSIGN_JI_ 
)

◆ TAGGR_LOOP

#define TAGGR_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _INCREMENT_ 
)

◆ TRANS_LOOP

#define TRANS_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_ 
)
Value:
do { \
_MASK_(_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1)); \
for (j = 0, k = 0; j < n; ++j) { \
kend = pp0[j]; \
while (k < kend) { \
i = pi0[k]; \
pi1[pp1_[i]] = j; \
_MASK_(px1[pp1_[i]] = px0[k]); \
++pp1_[i]; \
++k; \
} \
} \
} while (0)

◆ TSORT_LOOP

#define TSORT_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _INCREMENT_ 
)

◆ UNPACK

#define UNPACK (   _PREFIX_,
  _CTYPE_,
  _PTR_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
Matrix_memset(px1, 0, (R_xlen_t) n * n, sizeof(_CTYPE_)); \
_PREFIX_ ## unpack1(px1, px0, n, ul, 'N'); \
} while (0)

◆ VAD_SUBCASES

#define VAD_SUBCASES (   _PREFIX_,
  _CTYPE_,
  _PTR_,
  _NA_ 
)

◆ VAS_SUBCASES

#define VAS_SUBCASES (   ...)
Value:
do { \
switch (TYPEOF(i0)) { \
case INTSXP: \
{ \
int *pi0 = INTEGER(i0); \
VAS_SUBSUBCASES(__VA_ARGS__); \
break; \
} \
case REALSXP: \
{ \
double *pi0 = REAL(i0); \
VAS_SUBSUBCASES(__VA_ARGS__); \
break; \
} \
default: \
break; \
} \
} while (0)

◆ VAS_SUBSUBCASES [1/2]

#define VAS_SUBSUBCASES ( )

◆ VAS_SUBSUBCASES [2/2]

#define VAS_SUBSUBCASES (   _MASK0_,
  _MASK1_,
  _REPLACE_,
  _CTYPE_,
  _PTR_,
  _ONE_,
  _NA_ 
)

Function Documentation

◆ dense_as_general()

SEXP dense_as_general ( SEXP  from,
const char *  class,
int  new 
)

◆ dense_as_kind()

SEXP dense_as_kind ( SEXP  from,
const char *  class,
char  kind,
int  new 
)

◆ dense_as_packed()

SEXP dense_as_packed ( SEXP  from,
const char *  class,
char  ul,
char  di 
)

◆ dense_as_sparse()

SEXP dense_as_sparse ( SEXP  from,
const char *  class,
char  repr 
)

◆ dense_as_unpacked()

SEXP dense_as_unpacked ( SEXP  from,
const char *  class 
)

◆ diagonal_as_dense()

SEXP diagonal_as_dense ( SEXP  from,
const char *  class,
char  kind,
char  shape,
int  packed,
char  ul 
)

◆ diagonal_as_kind()

SEXP diagonal_as_kind ( SEXP  from,
const char *  class,
char  kind 
)

◆ diagonal_as_sparse()

SEXP diagonal_as_sparse ( SEXP  from,
const char *  class,
char  kind,
char  shape,
char  repr,
char  ul 
)

◆ index_as_dense()

SEXP index_as_dense ( SEXP  from,
const char *  class,
char  kind 
)

◆ index_as_kind()

SEXP index_as_kind ( SEXP  from,
const char *  class,
char  kind 
)

Definition at line 2712 of file coerce.c.

References index_as_sparse().

Referenced by R_index_as_kind().

◆ index_as_sparse()

SEXP index_as_sparse ( SEXP  from,
const char *  class,
char  kind,
char  repr 
)

◆ matrix_as_dense()

SEXP matrix_as_dense ( SEXP  from,
const char *  zzz,
char  ul,
char  di,
int  trans,
int  new 
)

◆ matrix_as_sparse()

SEXP matrix_as_sparse ( SEXP  from,
const char *  zzz,
char  ul,
char  di,
int  trans 
)

◆ R_dense_as_general()

SEXP R_dense_as_general ( SEXP  from)

Definition at line 2821 of file coerce.c.

References dense_as_general(), ERROR_INVALID_CLASS, valid, and VALID_DENSE.

◆ R_dense_as_kind()

SEXP R_dense_as_kind ( SEXP  from,
SEXP  kind 
)

Definition at line 2483 of file coerce.c.

References _, dense_as_kind(), ERROR_INVALID_CLASS, valid, and VALID_DENSE.

◆ R_dense_as_packed()

SEXP R_dense_as_packed ( SEXP  from,
SEXP  uplo,
SEXP  diag 
)

Definition at line 3330 of file coerce.c.

References _, dense_as_packed(), ERROR_INVALID_CLASS, valid, and VALID_DENSE.

◆ R_dense_as_sparse()

SEXP R_dense_as_sparse ( SEXP  from,
SEXP  repr 
)

Definition at line 2050 of file coerce.c.

References _, dense_as_sparse(), ERROR_INVALID_CLASS, valid, and VALID_DENSE.

◆ R_dense_as_unpacked()

SEXP R_dense_as_unpacked ( SEXP  from)

Definition at line 3219 of file coerce.c.

References dense_as_unpacked(), ERROR_INVALID_CLASS, valid, and VALID_DENSE.

◆ R_diagonal_as_dense()

SEXP R_diagonal_as_dense ( SEXP  from,
SEXP  kind,
SEXP  shape,
SEXP  packed,
SEXP  uplo 
)

Definition at line 893 of file coerce.c.

References _, diagonal_as_dense(), ERROR_INVALID_CLASS, valid, and VALID_DIAGONAL.

◆ R_diagonal_as_kind()

SEXP R_diagonal_as_kind ( SEXP  from,
SEXP  kind 
)

Definition at line 2696 of file coerce.c.

References _, diagonal_as_kind(), ERROR_INVALID_CLASS, valid, and VALID_DIAGONAL.

◆ R_diagonal_as_sparse()

SEXP R_diagonal_as_sparse ( SEXP  from,
SEXP  kind,
SEXP  shape,
SEXP  repr,
SEXP  uplo 
)

Definition at line 2244 of file coerce.c.

References _, diagonal_as_sparse(), ERROR_INVALID_CLASS, valid, and VALID_DIAGONAL.

◆ R_index_as_dense()

SEXP R_index_as_dense ( SEXP  from,
SEXP  kind 
)

Definition at line 1004 of file coerce.c.

References _, ERROR_INVALID_CLASS, index_as_dense(), and valid.

◆ R_index_as_kind()

SEXP R_index_as_kind ( SEXP  from,
SEXP  kind 
)

Definition at line 2718 of file coerce.c.

References _, ERROR_INVALID_CLASS, index_as_kind(), and valid.

◆ R_index_as_sparse()

SEXP R_index_as_sparse ( SEXP  from,
SEXP  kind,
SEXP  repr 
)

Definition at line 2386 of file coerce.c.

References _, ERROR_INVALID_CLASS, index_as_sparse(), and valid.

◆ R_Matrix_as_Csparse()

SEXP R_Matrix_as_Csparse ( SEXP  from)

◆ R_matrix_as_dense()

SEXP R_matrix_as_dense ( SEXP  from,
SEXP  zzz,
SEXP  uplo,
SEXP  diag,
SEXP  trans 
)

Definition at line 454 of file coerce.c.

References _, ERROR_INVALID_TYPE, matrix_as_dense(), and trans().

◆ R_Matrix_as_general()

SEXP R_Matrix_as_general ( SEXP  from,
SEXP  kind 
)

◆ R_Matrix_as_kind()

SEXP R_Matrix_as_kind ( SEXP  from,
SEXP  kind,
SEXP  sparse 
)

◆ R_Matrix_as_matrix()

SEXP R_Matrix_as_matrix ( SEXP  from)

◆ R_Matrix_as_packed()

SEXP R_Matrix_as_packed ( SEXP  from)

◆ R_Matrix_as_Rsparse()

SEXP R_Matrix_as_Rsparse ( SEXP  from)

◆ R_matrix_as_sparse()

SEXP R_matrix_as_sparse ( SEXP  from,
SEXP  zzz,
SEXP  uplo,
SEXP  diag,
SEXP  trans 
)

Definition at line 1602 of file coerce.c.

References _, ERROR_INVALID_TYPE, matrix_as_sparse(), and trans().

◆ R_Matrix_as_Tsparse()

SEXP R_Matrix_as_Tsparse ( SEXP  from)

◆ R_Matrix_as_unpacked()

SEXP R_Matrix_as_unpacked ( SEXP  from)

◆ R_Matrix_as_vector()

SEXP R_Matrix_as_vector ( SEXP  from)

◆ R_sparse_as_Csparse()

SEXP R_sparse_as_Csparse ( SEXP  from)

◆ R_sparse_as_dense()

SEXP R_sparse_as_dense ( SEXP  from,
SEXP  packed 
)

◆ R_sparse_as_general()

SEXP R_sparse_as_general ( SEXP  from)

◆ R_sparse_as_kind()

SEXP R_sparse_as_kind ( SEXP  from,
SEXP  kind 
)

◆ R_sparse_as_Rsparse()

SEXP R_sparse_as_Rsparse ( SEXP  from)

◆ R_sparse_as_Tsparse()

SEXP R_sparse_as_Tsparse ( SEXP  from)

◆ R_vector_as_dense()

SEXP R_vector_as_dense ( SEXP  from,
SEXP  zzz,
SEXP  uplo,
SEXP  diag,
SEXP  m,
SEXP  n,
SEXP  byrow,
SEXP  dimnames 
)

Definition at line 164 of file coerce.c.

References _, ERROR_INVALID_TYPE, and vector_as_dense().

◆ R_vector_as_sparse()

SEXP R_vector_as_sparse ( SEXP  from,
SEXP  zzz,
SEXP  uplo,
SEXP  diag,
SEXP  m,
SEXP  n,
SEXP  byrow,
SEXP  dimnames 
)

◆ sparse_as_Csparse()

SEXP sparse_as_Csparse ( SEXP  from,
const char *  class 
)

◆ sparse_as_dense()

SEXP sparse_as_dense ( SEXP  from,
const char *  class,
int  packed 
)

◆ sparse_as_general()

SEXP sparse_as_general ( SEXP  from,
const char *  class 
)

◆ sparse_as_kind()

SEXP sparse_as_kind ( SEXP  from,
const char *  class,
char  kind 
)

◆ sparse_as_Rsparse()

SEXP sparse_as_Rsparse ( SEXP  from,
const char *  class 
)

◆ sparse_as_Tsparse()

SEXP sparse_as_Tsparse ( SEXP  from,
const char *  class 
)

◆ taggr()

void taggr ( SEXP  i0,
SEXP  j0,
SEXP  x0,
SEXP *  i1,
SEXP *  j1,
SEXP *  x1,
int  m,
int  n 
)

◆ trans()

void trans ( SEXP  p0,
SEXP  i0,
SEXP  x0,
SEXP  p1,
SEXP  i1,
SEXP  x1,
int  m,
int  n 
)

◆ tsort()

void tsort ( SEXP  i0,
SEXP  j0,
SEXP  x0,
SEXP *  p1,
SEXP *  i1,
SEXP *  x1,
int  m,
int  n 
)

◆ vector_as_dense()

SEXP vector_as_dense ( SEXP  from,
const char *  zzz,
char  ul,
char  di,
int  m,
int  n,
int  byrow,
SEXP  dimnames 
)

◆ vector_as_sparse()

SEXP vector_as_sparse ( SEXP  from,
const char *  zzz,
char  ul,
char  di,
int  m,
int  n,
int  byrow,
SEXP  dimnames 
)