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

Go to the source code of this file.

Macros

#define TOLBASED_ISNZ_REAL(_X_)    (ISNA_REAL(_X_) || fabs(_X_) > tol)
 
#define TOLBASED_ISNZ_COMPLEX(_X_)    (ISNA_COMPLEX(_X_) || hypot((_X_).r, (_X_).i) > tol)
 
#define DROP0_CASES(_DO_)
 
#define DROP0_LOOP1(_CTYPE_, _PTR_, _ISNZ_)
 
#define DROP0_LOOP2(_CTYPE_, _PTR_, _ISNZ_)
 
#define DROP0_LOOP2(_CTYPE_, _PTR_, _ISNZ_)
 
#define BAND_CASES
 
#define BAND_SUBCASES(_CTYPE_, _PTR_, _MASK_)
 
#define BAND_SUBCASES(_CTYPE_, _PTR_, _MASK_)
 
#define DG_CASES
 
#define DG_LOOP(_CTYPE_, _PTR_, _MASK_, _REPLACE_, _INCREMENT_, _ZERO_, _ONE_)
 
#define DG_LOOP(_CTYPE_, _PTR_, _MASK_, _REPLACE_, _INCREMENT_, _ZERO_, _ONE_)
 
#define DG_LOOP(_CTYPE_, _PTR_, _MASK_, _REPLACE_, _INCREMENT_, _ZERO_, _ONE_)
 
#define DS_CASES
 
#define DS_LOOP(_CTYPE_, _PTR_, _MASK_, _ISNZ_)
 
#define DS_LOOP(_CTYPE_, _PTR_, _MASK_, _ISNZ_)
 
#define DS_LOOP(_CTYPE_, _PTR_, _MASK_, _ISNZ_)
 
#define DS_LOOP(_CTYPE_, _PTR_, _MASK_, _ISNZ_)
 
#define FS_CASES
 
#define FS_SUBCASES(_CTYPE_, _PTR_, _MASK_, _ONE_)
 
#define FS_SUBCASES(_CTYPE_, _PTR_, _MASK_, _ONE_)
 
#define SP_LOOP(_CTYPE_, _PTR_, _ASSIGN_, _INCREMENT_)
 
#define SP_LOOP(_CTYPE_, _PTR_, _ASSIGN_)
 
#define SP_LOOP(_CTYPE_, _PTR_, _ASSIGN_, _ONE_)
 
#define SP_LOOP(_CTYPE_, _PTR_, _ASSIGN_)
 
#define SP_LOOP(_CTYPE_, _PTR_, _ASSIGN_)
 
#define SP_LOOP(_CTYPE_, _PTR_, _ASSIGN_, _ONE_)
 
#define SP_LOOP(_CTYPE_, _PTR_, _ASSIGN_, _INCREMENT_)
 
#define SP_LOOP(_CTYPE_, _PTR_, _ASSIGN_)
 
#define IS_LOOP(_CTYPE_, _PTR_, _MASK_, _NOTREAL_, _NOTCONJ_)
 
#define NOTCONJ_PATTERN(_X_, _Y_)   0
 
#define MAP(_I_)   work[_I_]
 
#define NOMAP(_I_)   _I_
 
#define CAST_PATTERN(_X_)   1
 
#define CAST_LOGICAL(_X_)   (_X_ != 0)
 
#define CAST_INTEGER(_X_)   _X_
 
#define CAST_REAL(_X_)   _X_
 
#define CAST_COMPLEX(_X_)   _X_
 
#define SUM_CASES(_MAP_)
 
#define SUM_TYPEOF(c)   (c == 'z') ? CPLXSXP : ((mean || c == 'd' || c == 'i') ? REALSXP : INTSXP)
 
#define SUM_LOOP(_CTYPE0_, _PTR0_, _CTYPE1_, _PTR1_, _MASK_, _ZERO_, _ONE_, _NA_, _ISNA_, _MAP_, _CAST_, _INCREMENT_, _SCALE2_)
 
#define SUM_LOOP(_CTYPE0_, _PTR0_, _CTYPE1_, _PTR1_, _MASK_, _ZERO_, _ONE_, _NA_, _ISNA_, _MAP_, _CAST_, _INCREMENT_, _SCALE2_)
 
#define SUM_LOOP(_CTYPE0_, _PTR0_, _CTYPE1_, _PTR1_, _MASK_, _ZERO_, _ONE_, _NA_, _ISNA_, _MAP_, _CAST_, _INCREMENT_, _SCALE2_)
 
#define TRY_INCREMENT(_LABEL_)
 
#define LONGDOUBLE_AS_DOUBLE(v)    (v > DBL_MAX) ? R_PosInf : ((v < -DBL_MAX) ? R_NegInf : (double) v);
 

Functions

SEXP sparse_drop0 (SEXP from, const char *class, double tol)
 
SEXP R_sparse_drop0 (SEXP from, SEXP tol)
 
SEXP sparse_diag_U2N (SEXP from, const char *class)
 
SEXP R_sparse_diag_U2N (SEXP from)
 
SEXP sparse_diag_N2U (SEXP from, const char *class)
 
SEXP R_sparse_diag_N2U (SEXP from)
 
SEXP sparse_band (SEXP from, const char *class, int a, int b)
 
SEXP R_sparse_band (SEXP from, SEXP k1, SEXP k2)
 
SEXP sparse_diag_get (SEXP obj, const char *class, int names)
 
SEXP R_sparse_diag_get (SEXP obj, SEXP names)
 
SEXP sparse_diag_set (SEXP from, const char *class, SEXP value)
 
SEXP R_sparse_diag_set (SEXP from, SEXP value)
 
SEXP sparse_transpose (SEXP from, const char *class, int lazy)
 
SEXP R_sparse_transpose (SEXP from, SEXP lazy)
 
SEXP sparse_force_symmetric (SEXP from, const char *class, char ul)
 
SEXP R_sparse_force_symmetric (SEXP from, SEXP uplo)
 
SEXP sparse_symmpart (SEXP from, const char *class)
 
SEXP R_sparse_symmpart (SEXP from)
 
SEXP sparse_skewpart (SEXP from, const char *class)
 
SEXP R_sparse_skewpart (SEXP from)
 
int sparse_is_symmetric (SEXP obj, const char *class, int checkDN)
 
SEXP R_sparse_is_symmetric (SEXP obj, SEXP checkDN)
 
int sparse_is_triangular (SEXP obj, const char *class, int upper)
 
SEXP R_sparse_is_triangular (SEXP obj, SEXP upper)
 
int sparse_is_diagonal (SEXP obj, const char *class)
 
SEXP R_sparse_is_diagonal (SEXP obj)
 
static void Csparse_colsum (SEXP obj, const char *class, int m, int n, char di, int narm, int mean, SEXP res)
 
static void Csparse_rowsum (SEXP obj, const char *class, int m, int n, char di, int narm, int mean, SEXP res, SEXP iSym)
 
static void Tsparse_colsum (SEXP obj, const char *class, int m, int n, char di, int narm, int mean, SEXP res, SEXP iSym, SEXP jSym)
 
SEXP sparse_marginsum (SEXP obj, const char *class, int margin, int narm, int mean, int sparse)
 
SEXP R_sparse_marginsum (SEXP obj, SEXP margin, SEXP narm, SEXP mean, SEXP sparse)
 
SEXP sparse_sum (SEXP obj, const char *class, int narm)
 
SEXP R_sparse_sum (SEXP obj, SEXP narm)
 
SEXP sparse_prod (SEXP obj, const char *class, int narm)
 
SEXP R_sparse_prod (SEXP obj, SEXP narm)
 
SEXP Tsparse_aggregate (SEXP from)
 

Macro Definition Documentation

◆ BAND_CASES

#define BAND_CASES
Value:
do { \
switch (class[0]) { \
case 'l': \
BAND_SUBCASES(int, LOGICAL, SHOW); \
break; \
case 'i': \
BAND_SUBCASES(int, INTEGER, SHOW); \
break; \
case 'd': \
BAND_SUBCASES(double, REAL, SHOW); \
break; \
case 'z': \
BAND_SUBCASES(Rcomplex, COMPLEX, SHOW); \
break; \
default: \
break; \
} \
} while (0)
#define SHOW(...)
Definition Mdefines.h:201

◆ BAND_SUBCASES [1/2]

#define BAND_SUBCASES (   _CTYPE_,
  _PTR_,
  _MASK_ 
)

◆ BAND_SUBCASES [2/2]

#define BAND_SUBCASES (   _CTYPE_,
  _PTR_,
  _MASK_ 
)
Value:
do { \
_MASK_(_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1)); \
if (class[1] == 's' && !sy) { \
for (k = 0; k < nnz0; ++k) { \
if ((d = pj0[k] - pi0[k]) >= a && d <= b) { \
*(pi1++) = pi0[k]; \
*(pj1++) = pj0[k]; \
_MASK_(*(px1++) = px0[k]); \
} \
if (d != 0 && -d >= a && -d <= b) { \
*(pi1++) = pj0[k]; \
*(pj1++) = pi0[k]; \
_MASK_(*(px1++) = px0[k]); \
} \
} \
} else { \
for (k = 0; k < nnz0; ++k) { \
if ((d = pj0[k] - pi0[k]) >= a && d <= b) { \
*(pi1++) = pi0[k]; \
*(pj1++) = pj0[k]; \
_MASK_(*(px1++) = px0[k]); \
} \
} \
} \
} while (0)

◆ CAST_COMPLEX

#define CAST_COMPLEX (   _X_)    _X_

Definition at line 2660 of file sparse.c.

◆ CAST_INTEGER

#define CAST_INTEGER (   _X_)    _X_

Definition at line 2658 of file sparse.c.

◆ CAST_LOGICAL

#define CAST_LOGICAL (   _X_)    (_X_ != 0)

Definition at line 2657 of file sparse.c.

◆ CAST_PATTERN

#define CAST_PATTERN (   _X_)    1

Definition at line 2656 of file sparse.c.

◆ CAST_REAL

#define CAST_REAL (   _X_)    _X_

Definition at line 2659 of file sparse.c.

◆ DG_CASES

#define DG_CASES
Value:
do { \
switch (class[0]) { \
case 'n': \
case 'l': \
DG_LOOP(int, LOGICAL, SHOW, FIRSTOF, INCREMENT_LOGICAL, 0, 1); \
break; \
case 'i': \
DG_LOOP(int, INTEGER, SHOW, FIRSTOF, INCREMENT_INTEGER, 0, 1); \
break; \
case 'd': \
DG_LOOP(double, REAL, SHOW, FIRSTOF, INCREMENT_REAL, 0.0, 1.0); \
break; \
case 'z': \
DG_LOOP(Rcomplex, COMPLEX, SHOW, FIRSTOF, INCREMENT_COMPLEX, Matrix_zzero, 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 INCREMENT_LOGICAL(_X_, _Y_)
Definition Mdefines.h:147
Rcomplex Matrix_zone
Definition init.c:26
Rcomplex Matrix_zzero
Definition init.c:26

◆ DG_LOOP [1/3]

#define DG_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _REPLACE_,
  _INCREMENT_,
  _ZERO_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *pres = _PTR_(res); \
for (j = 0; j < r; ++j) \
*(pres++) = _ONE_; \
} while (0)

◆ DG_LOOP [2/3]

#define DG_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _REPLACE_,
  _INCREMENT_,
  _ZERO_,
  _ONE_ 
)

◆ DG_LOOP [3/3]

#define DG_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _REPLACE_,
  _INCREMENT_,
  _ZERO_,
  _ONE_ 
)
Value:
do { \
_MASK_(_CTYPE_ *px0 = _PTR_(x0)); \
_CTYPE_ *pres = _PTR_(res); \
Matrix_memset(pres, 0, r, sizeof(_CTYPE_)); \
for (k = 0; k < nnz0; ++k) { \
if (*pi0 == *pj0) \
_INCREMENT_(pres[*pi0], (*px0)); \
++pi0; ++pj0; _MASK_(++px0); \
} \
} while (0)

◆ DROP0_CASES

#define DROP0_CASES (   _DO_)
Value:
do { \
switch (class[0]) { \
case 'l': \
_DO_(int, LOGICAL, ISNZ_LOGICAL); \
break; \
case 'i': \
_DO_(int, INTEGER, ISNZ_INTEGER); \
break; \
case 'd': \
if (tol > 0.0) \
_DO_(double, REAL, TOLBASED_ISNZ_REAL); \
else \
_DO_(double, REAL, ISNZ_REAL); \
break; \
case 'z': \
if (tol > 0.0) \
_DO_(Rcomplex, COMPLEX, TOLBASED_ISNZ_COMPLEX); \
else \
_DO_(Rcomplex, COMPLEX, 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
#define TOLBASED_ISNZ_REAL(_X_)
#define TOLBASED_ISNZ_COMPLEX(_X_)

◆ DROP0_LOOP1

#define DROP0_LOOP1 (   _CTYPE_,
  _PTR_,
  _ISNZ_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0); \
for (k = 0; k < nnz0; ++k) { \
if (_ISNZ_(*px0)) \
++nnz1; \
++px0; \
} \
} while (0)

◆ DROP0_LOOP2 [1/2]

#define DROP0_LOOP2 (   _CTYPE_,
  _PTR_,
  _ISNZ_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
for (j = 0, k = 0; j < n; ++j) { \
pp1[j] = pp1[j - 1]; \
kend = pp0[j]; \
while (k < kend) { \
if (_ISNZ_(*px0)) { \
++pp1[j]; \
*(pi1++) = *pi0; \
*(px1++) = *px0; \
} \
++k; ++pi0; ++px0; \
} \
} \
} while (0)

◆ DROP0_LOOP2 [2/2]

#define DROP0_LOOP2 (   _CTYPE_,
  _PTR_,
  _ISNZ_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
for (k = 0; k < nnz0; ++k) { \
if (_ISNZ_(*px0)) { \
*(pi1++) = *pi0; \
*(pj1++) = *pj0; \
*(px1++) = *px0; \
} \
++pi0; ++pj0; ++px0; \
} \
} while (0)

◆ DS_CASES

#define DS_CASES
Value:
do { \
switch (class[0]) { \
case 'n': \
case 'l': \
DS_LOOP(int, LOGICAL, SHOW, ISNZ_LOGICAL); \
break; \
case 'i': \
DS_LOOP(int, INTEGER, SHOW, ISNZ_INTEGER); \
break; \
case 'd': \
DS_LOOP(double, REAL, SHOW, ISNZ_REAL); \
break; \
case 'z': \
DS_LOOP(Rcomplex, COMPLEX, SHOW, ISNZ_COMPLEX); \
break; \
default: \
break; \
} \
} while (0)

◆ DS_LOOP [1/4]

#define DS_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ISNZ_ 
)
Value:
do { \
_CTYPE_ *pvalue = _PTR_(value); \
if (v) { \
for (j = 0; j < r; ++j) { \
if (_ISNZ_(pvalue[j])) \
++nd1; \
pp1[j] += nd1; \
} \
for (j = r; j < n_; ++j) \
pp1[j] += nd1; \
} else if (_ISNZ_(pvalue[0])) { \
full = 1; \
for (j = 0; j < r; ++j) \
pp1[j] += ++nd1; \
for (j = r; j < n_; ++j) \
pp1[j] += nd1; \
} \
} while (0)

◆ DS_LOOP [2/4]

#define DS_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ISNZ_ 
)

◆ DS_LOOP [3/4]

#define DS_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ISNZ_ 
)
Value:
do { \
_CTYPE_ *pvalue = _PTR_(value); \
if (v) { \
for (j = 0; j < r; ++j) \
if (_ISNZ_(pvalue[j])) \
++nd1; \
} else if (_ISNZ_(pvalue[0])) { \
full = 1; \
nd1 = r; \
} \
} while (0)

◆ DS_LOOP [4/4]

#define DS_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ISNZ_ 
)
Value:
do { \
_MASK_(_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1)); \
_CTYPE_ *pvalue = _PTR_(value); \
for (k = 0; k < nnz0; ++k) { \
if (pi0[k] != pj0[k]) { \
*(pi1++) = pi0[k]; \
*(pj1++) = pj0[k]; \
_MASK_(*(px1++) = px0[k]); \
} \
} \
if (v) { \
for (j = 0; j < r; ++j) { \
if (_ISNZ_(pvalue[j])) { \
*(pi1++) = *(pj1++) = j; \
_MASK_(*(px1++) = pvalue[j]); \
} \
} \
} else if (full) { \
for (j = 0; j < r; ++j) { \
*(pi1++) = *(pj1++) = j; \
_MASK_(*(px1++) = pvalue[0]); \
} \
} \
} while (0)

◆ FS_CASES

#define FS_CASES
Value:
do { \
switch (class[0]) { \
case 'l': \
FS_SUBCASES(int, LOGICAL, SHOW, 1); \
break; \
case 'i': \
FS_SUBCASES(int, INTEGER, SHOW, 1); \
break; \
case 'd': \
FS_SUBCASES(double, REAL, SHOW, 1.0); \
break; \
case 'z': \
FS_SUBCASES(Rcomplex, COMPLEX, SHOW, Matrix_zone); \
break; \
default: \
break; \
} \
} while (0)

◆ FS_SUBCASES [1/2]

#define FS_SUBCASES (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ONE_ 
)

◆ FS_SUBCASES [2/2]

#define FS_SUBCASES (   _CTYPE_,
  _PTR_,
  _MASK_,
  _ONE_ 
)

◆ IS_LOOP

#define IS_LOOP (   _CTYPE_,
  _PTR_,
  _MASK_,
  _NOTREAL_,
  _NOTCONJ_ 
)
Value:
do { \
_MASK_(_CTYPE_ *px0 = _PTR_(x0)); \
for (j = 0, k = 0; j < n; ++j) { \
kend = pp0[j]; \
while (k < kend) { \
i = pi0[k]; \
if (i >= j) { \
if (i == j) { \
if (_NOTREAL_(px0[k])) \
goto finish; \
++pp_[j]; \
} \
k = kend; \
} else { \
if (pp_[i] == pp0[i] || pi0[pp_[i]] != j || \
_NOTCONJ_(px0[k], px0[pp_[i]])) \
goto finish; \
++pp_[i]; \
++pp_[j]; \
++k; \
} \
} \
} \
} while (0)

◆ LONGDOUBLE_AS_DOUBLE

#define LONGDOUBLE_AS_DOUBLE (   v)     (v > DBL_MAX) ? R_PosInf : ((v < -DBL_MAX) ? R_NegInf : (double) v);

Definition at line 3174 of file sparse.c.

◆ MAP

#define MAP (   _I_)    work[_I_]

Definition at line 2653 of file sparse.c.

◆ NOMAP

#define NOMAP (   _I_)    _I_

Definition at line 2654 of file sparse.c.

◆ NOTCONJ_PATTERN

#define NOTCONJ_PATTERN (   _X_,
  _Y_ 
)    0

◆ SP_LOOP [1/8]

#define SP_LOOP (   _CTYPE_,
  _PTR_,
  _ASSIGN_ 
)

◆ SP_LOOP [2/8]

#define SP_LOOP (   _CTYPE_,
  _PTR_,
  _ASSIGN_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
for (k = 0; k < nnz; ++k) { \
if (*pi0 == *pj0) { \
*pi1 = *pi0; \
*pj1 = *pj0; \
*px1 = *px0; \
} else if (*pi0 < *pj0) { \
*pi1 = *pi0; \
*pj1 = *pj0; \
_ASSIGN_((*px1), 0.5 * (*px0)); \
} else { \
*pi1 = *pj0; \
*pj1 = *pi0; \
_ASSIGN_((*px1), 0.5 * (*px0)); \
} \
++pi0; ++pi1; ++pj0; ++pj1; ++px0; ++px1; \
} \
} while (0)

◆ SP_LOOP [3/8]

#define SP_LOOP (   _CTYPE_,
  _PTR_,
  _ASSIGN_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
for (k = 0; k < nnz; ++k) { \
if (*pi0 == *pj0) \
*px1 = *px0; \
else \
_ASSIGN_((*px1), 0.5 * (*px0)); \
++px0; ++px1; \
} \
} while (0)

◆ SP_LOOP [4/8]

#define SP_LOOP (   _CTYPE_,
  _PTR_,
  _ASSIGN_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
for (k = 0; k < nnz0; ++k) { \
if (*pi0 != *pj0) { \
*pi1 = *pi0; \
*pj1 = *pj0; \
_ASSIGN_((*px1), 0.5 * (*px0)); \
++pi1; ++pj1; ++px1; \
*pi1 = *pj0; \
*pj1 = *pi0; \
_ASSIGN_((*px1), -0.5 * (*px0)); \
++pi1; ++pj1; ++px1; \
} \
++pi0; ++pj0; ++px0; \
} \
} while (0)

◆ SP_LOOP [5/8]

#define SP_LOOP (   _CTYPE_,
  _PTR_,
  _ASSIGN_,
  _INCREMENT_ 
)

◆ SP_LOOP [6/8]

#define SP_LOOP (   _CTYPE_,
  _PTR_,
  _ASSIGN_,
  _INCREMENT_ 
)

◆ SP_LOOP [7/8]

#define SP_LOOP (   _CTYPE_,
  _PTR_,
  _ASSIGN_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
if (leading) { \
for (j = 0, k = 0; j < n; ++j) { \
kend = pp0[j]; \
pp1[j] = pp1[j - 1] + kend - k + 1; \
*pi1 = j; \
_ASSIGN_((*px1), _ONE_); \
++pi1, ++px1; \
while (k < kend) { \
*pi1 = *pi0; \
_ASSIGN_((*px1), 0.5 * (*px0)); \
++k; ++pi0; ++pi1; ++px0; ++px1; \
} \
} \
} else { \
for (j = 0, k = 0; j < n; ++j) { \
kend = pp0[j]; \
pp1[j] = pp1[j - 1] + kend - k + 1; \
while (k < kend) { \
*pi1 = *pi0; \
_ASSIGN_((*px1), 0.5 * (*px0)); \
++k; ++pi0; ++pi1; ++px0; ++px1; \
} \
*pi1 = j; \
_ASSIGN_((*px1), _ONE_); \
++pi1; ++px1; \
} \
} \
} while (0)

◆ SP_LOOP [8/8]

#define SP_LOOP (   _CTYPE_,
  _PTR_,
  _ASSIGN_,
  _ONE_ 
)
Value:
do { \
_CTYPE_ *px0 = _PTR_(x0), *px1 = _PTR_(x1); \
for (k = 0; k < nnz; ++k) { \
*pi1 = *pi0; \
*pj1 = *pj0; \
_ASSIGN_((*px1), 0.5 * (*px0)); \
++pi0; ++pi1; ++pj0; ++pj1; ++px0; ++px1; \
} \
for (j = 0; j < n; ++j) { \
*pi1 = *pj1 = j; \
_ASSIGN_((*px1), _ONE_); \
++pi1; ++pj1; ++px1; \
} \
} while (0)

◆ SUM_CASES

#define SUM_CASES (   _MAP_)

Definition at line 2662 of file sparse.c.

◆ SUM_LOOP [1/3]

#define SUM_LOOP (   _CTYPE0_,
  _PTR0_,
  _CTYPE1_,
  _PTR1_,
  _MASK_,
  _ZERO_,
  _ONE_,
  _NA_,
  _ISNA_,
  _MAP_,
  _CAST_,
  _INCREMENT_,
  _SCALE2_ 
)
Value:
do { \
_MASK_(_CTYPE0_ *px0 = _PTR0_(x0)); \
_CTYPE1_ *px1 = _PTR1_(x1) , tmp; \
for (j = 0, k = 0; j < n; ++j) { \
kend = pp0[j]; \
if (k < kend || nnz1 == n) { \
*px1 = (di != 'N') ? _ONE_ : _ZERO_; \
if (mean) \
count = m; \
while (k < kend) { \
if (_ISNA_(*px0)) { \
if (!narm) \
*px1 = _NA_; \
else if (narm_) \
--count; \
} else { \
tmp = _CAST_(*px0); \
_INCREMENT_((*px1), tmp); \
} \
_MASK_(++px0); \
++k; \
} \
if (mean) \
_SCALE2_((*px1), count); \
++px1; \
} \
} \
} while (0)

◆ SUM_LOOP [2/3]

#define SUM_LOOP (   _CTYPE0_,
  _PTR0_,
  _CTYPE1_,
  _PTR1_,
  _MASK_,
  _ZERO_,
  _ONE_,
  _NA_,
  _ISNA_,
  _MAP_,
  _CAST_,
  _INCREMENT_,
  _SCALE2_ 
)

◆ SUM_LOOP [3/3]

#define SUM_LOOP (   _CTYPE0_,
  _PTR0_,
  _CTYPE1_,
  _PTR1_,
  _MASK_,
  _ZERO_,
  _ONE_,
  _NA_,
  _ISNA_,
  _MAP_,
  _CAST_,
  _INCREMENT_,
  _SCALE2_ 
)

◆ SUM_TYPEOF

#define SUM_TYPEOF (   c)    (c == 'z') ? CPLXSXP : ((mean || c == 'd' || c == 'i') ? REALSXP : INTSXP)

Definition at line 2708 of file sparse.c.

◆ TOLBASED_ISNZ_COMPLEX

#define TOLBASED_ISNZ_COMPLEX (   _X_)     (ISNA_COMPLEX(_X_) || hypot((_X_).r, (_X_).i) > tol)

◆ TOLBASED_ISNZ_REAL

#define TOLBASED_ISNZ_REAL (   _X_)     (ISNA_REAL(_X_) || fabs(_X_) > tol)

◆ TRY_INCREMENT

#define TRY_INCREMENT (   _LABEL_)
Value:
do { \
if ((s >= 0) \
? ( t <= MATRIX_INT_FAST64_MAX - s) \
: (-t <= s - MATRIX_INT_FAST64_MIN)) { \
s += t; \
t = 0; \
count = 0; \
} else { \
over = 1; \
goto _LABEL_; \
} \
} while (0)
#define MATRIX_INT_FAST64_MAX
Definition Mdefines.h:29
#define MATRIX_INT_FAST64_MIN
Definition Mdefines.h:28

Definition at line 3160 of file sparse.c.

Function Documentation

◆ Csparse_colsum()

static void Csparse_colsum ( SEXP  obj,
const char *  class,
int  m,
int  n,
char  di,
int  narm,
int  mean,
SEXP  res 
)
static

Definition at line 2711 of file sparse.c.

References GET_SLOT, MAP, Matrix_iSym, Matrix_pSym, Matrix_xSym, NOMAP, SET_SLOT, SUM_CASES, and SUM_TYPEOF.

Referenced by sparse_marginsum().

◆ Csparse_rowsum()

static void Csparse_rowsum ( SEXP  obj,
const char *  class,
int  m,
int  n,
char  di,
int  narm,
int  mean,
SEXP  res,
SEXP  iSym 
)
static

◆ R_sparse_band()

SEXP R_sparse_band ( SEXP  from,
SEXP  k1,
SEXP  k2 
)

◆ R_sparse_diag_get()

SEXP R_sparse_diag_get ( SEXP  obj,
SEXP  names 
)

◆ R_sparse_diag_N2U()

SEXP R_sparse_diag_N2U ( SEXP  from)

◆ R_sparse_diag_set()

SEXP R_sparse_diag_set ( SEXP  from,
SEXP  value 
)

◆ R_sparse_diag_U2N()

SEXP R_sparse_diag_U2N ( SEXP  from)

◆ R_sparse_drop0()

SEXP R_sparse_drop0 ( SEXP  from,
SEXP  tol 
)

Definition at line 185 of file sparse.c.

References _, ERROR_INVALID_CLASS, sparse_drop0(), valid, VALID_CSPARSE, VALID_RSPARSE, and VALID_TSPARSE.

◆ R_sparse_force_symmetric()

SEXP R_sparse_force_symmetric ( SEXP  from,
SEXP  uplo 
)

◆ R_sparse_is_diagonal()

SEXP R_sparse_is_diagonal ( SEXP  obj)

◆ R_sparse_is_symmetric()

SEXP R_sparse_is_symmetric ( SEXP  obj,
SEXP  checkDN 
)

◆ R_sparse_is_triangular()

SEXP R_sparse_is_triangular ( SEXP  obj,
SEXP  upper 
)

◆ R_sparse_marginsum()

SEXP R_sparse_marginsum ( SEXP  obj,
SEXP  margin,
SEXP  narm,
SEXP  mean,
SEXP  sparse 
)

◆ R_sparse_prod()

SEXP R_sparse_prod ( SEXP  obj,
SEXP  narm 
)

Definition at line 3653 of file sparse.c.

References _, ERROR_INVALID_CLASS, sparse_prod(), valid, VALID_CSPARSE, VALID_RSPARSE, and VALID_TSPARSE.

◆ R_sparse_skewpart()

SEXP R_sparse_skewpart ( SEXP  from)

◆ R_sparse_sum()

SEXP R_sparse_sum ( SEXP  obj,
SEXP  narm 
)

Definition at line 3416 of file sparse.c.

References _, ERROR_INVALID_CLASS, sparse_sum(), valid, VALID_CSPARSE, VALID_RSPARSE, and VALID_TSPARSE.

◆ R_sparse_symmpart()

SEXP R_sparse_symmpart ( SEXP  from)

◆ R_sparse_transpose()

SEXP R_sparse_transpose ( SEXP  from,
SEXP  lazy 
)

◆ sparse_band()

SEXP sparse_band ( SEXP  from,
const char *  class,
int  a,
int  b 
)

◆ sparse_diag_get()

SEXP sparse_diag_get ( SEXP  obj,
const char *  class,
int  names 
)

◆ sparse_diag_N2U()

SEXP sparse_diag_N2U ( SEXP  from,
const char *  class 
)

◆ sparse_diag_set()

SEXP sparse_diag_set ( SEXP  from,
const char *  class,
SEXP  value 
)

◆ sparse_diag_U2N()

SEXP sparse_diag_U2N ( SEXP  from,
const char *  class 
)

Definition at line 201 of file sparse.c.

References GET_SLOT, Matrix_diagSym, and R_sparse_diag_set().

Referenced by R_diagonal_matmult(), R_sparse_diag_U2N(), and R_sparse_matmult().

◆ sparse_drop0()

SEXP sparse_drop0 ( SEXP  from,
const char *  class,
double  tol 
)

◆ sparse_force_symmetric()

SEXP sparse_force_symmetric ( SEXP  from,
const char *  class,
char  ul 
)

◆ sparse_is_diagonal()

int sparse_is_diagonal ( SEXP  obj,
const char *  class 
)

◆ sparse_is_symmetric()

int sparse_is_symmetric ( SEXP  obj,
const char *  class,
int  checkDN 
)

◆ sparse_is_triangular()

int sparse_is_triangular ( SEXP  obj,
const char *  class,
int  upper 
)

◆ sparse_marginsum()

SEXP sparse_marginsum ( SEXP  obj,
const char *  class,
int  margin,
int  narm,
int  mean,
int  sparse 
)

◆ sparse_prod()

SEXP sparse_prod ( SEXP  obj,
const char *  class,
int  narm 
)

◆ sparse_skewpart()

SEXP sparse_skewpart ( SEXP  from,
const char *  class 
)

◆ sparse_sum()

SEXP sparse_sum ( SEXP  obj,
const char *  class,
int  narm 
)

◆ sparse_symmpart()

SEXP sparse_symmpart ( SEXP  from,
const char *  class 
)

◆ sparse_transpose()

SEXP sparse_transpose ( SEXP  from,
const char *  class,
int  lazy 
)

◆ Tsparse_aggregate()

SEXP Tsparse_aggregate ( SEXP  from)

◆ Tsparse_colsum()

static void Tsparse_colsum ( SEXP  obj,
const char *  class,
int  m,
int  n,
char  di,
int  narm,
int  mean,
SEXP  res,
SEXP  iSym,
SEXP  jSym 
)
static