Matrix r5059
Loading...
Searching...
No Matches
Summary.c File Reference
#include "Mdefines.h"
#include "M5.h"

Go to the source code of this file.

Macros

#define LONGDOUBLE_AS_DOUBLE(x)
 
#define TRY_INCREMENT(x, y, label)
 
#define SUM
 
#define SUM_KERNEL(__for__)
 
#define SUM_KERNEL(__for__)
 
#define SUM_KERNEL(__for__)
 
#define SUM_KERNEL(__for__)
 
#define SUM_KERNEL(__for__)
 
#define PROD
 
#define PROD_KERNEL(__for__)
 
#define PROD_KERNEL(__for__)
 
#define PROD_KERNEL(__for__)
 
#define PROD_KERNEL(__for__)
 

Functions

SEXP sparse_aggregate (SEXP, const char *)
 
SEXP dense_sum (SEXP obj, const char *class, int narm)
 
SEXP sparse_sum (SEXP obj, const char *class, int narm)
 
SEXP R_dense_sum (SEXP s_obj, SEXP s_narm)
 
SEXP R_sparse_sum (SEXP s_obj, SEXP s_narm)
 
SEXP dense_prod (SEXP obj, const char *class, int narm)
 
SEXP sparse_prod (SEXP obj, const char *class, int narm)
 
SEXP R_dense_prod (SEXP s_obj, SEXP s_narm)
 
SEXP R_sparse_prod (SEXP s_obj, SEXP s_narm)
 

Macro Definition Documentation

◆ LONGDOUBLE_AS_DOUBLE

#define LONGDOUBLE_AS_DOUBLE ( x)
Value:
(((x) > DBL_MAX) ? R_PosInf : (((x) < -DBL_MAX) ? R_NegInf : (double) (x)))

Definition at line 9 of file Summary.c.

Referenced by dense_prod(), dense_sum(), sparse_prod(), and sparse_sum().

◆ PROD

#define PROD

Referenced by dense_prod().

◆ PROD_KERNEL [1/4]

#define PROD_KERNEL ( __for__)
Value:
do { \
__for__ { \
if (*px == 0) \
return Rf_ScalarReal(0.0); \
px += 1; \
} \
} while (0)

◆ PROD_KERNEL [2/4]

#define PROD_KERNEL ( __for__)
Value:
do { \
__for__ { \
if (*px != NA_INTEGER) \
lr *= (sy && i != j) ? (long double) *px * *px : *px; \
else if (!narm) \
lr *= NA_REAL; \
px += 1; \
} \
} while (0)

◆ PROD_KERNEL [3/4]

#define PROD_KERNEL ( __for__)
Value:
do { \
__for__ { \
if (!(narm && ISNAN(*px))) \
lr *= (sy && i != j) ? (long double) *px * *px : *px; \
px += 1; \
} \
} while (0)

◆ PROD_KERNEL [4/4]

#define PROD_KERNEL ( __for__)
Value:
do { \
__for__ { \
if (!(narm && (ISNAN((*px).r) || (!(he && i == j) && ISNAN((*px).i))))) { \
if (he) { \
lr0 = (*px).r; \
if (i != j) { \
li0 = (*px).i; \
lr0 = lr0 * lr0 + li0 * li0; \
} \
lr *= lr0; \
li *= lr0; \
} else { \
lr0 = lr; li0 = li; \
lr = lr0 * (*px).r - li0 * (*px).i; \
li = li0 * (*px).r + lr0 * (*px).i; \
if (i != j) { \
lr0 = lr; li0 = li; \
lr = lr0 * (*px).r - li0 * (*px).i; \
li = li0 * (*px).r + lr0 * (*px).i; \
} \
} \
} \
px += 1; \
} \
} while (0)

◆ SUM

#define SUM

Referenced by dense_sum().

◆ SUM_KERNEL [1/5]

#define SUM_KERNEL ( __for__)
Value:
do { \
__for__ { \
if (*px != 0) \
s += (sy && i != j) ? 2 : 1; \
px += 1; \
} \
} while (0)

◆ SUM_KERNEL [2/5]

#define SUM_KERNEL ( __for__)
Value:
do { \
__for__ { \
if (*px != NA_INTEGER) { \
unsigned int d = (sy && i != j) ? 2 : 1; \
if (count > UINT_MAX - d) \
TRY_INCREMENT(s, t, over); \
t += (sy && i != j) ? 2LL * *px : *px; \
count += d; \
} \
else if (!narm) \
return Rf_ScalarInteger(NA_INTEGER); \
px += 1; \
} \
} while (0)

◆ SUM_KERNEL [3/5]

#define SUM_KERNEL ( __for__)
Value:
do { \
__for__ { \
if (*px != NA_INTEGER) \
lr += (sy && i != j) ? 2.0L * *px : *px; \
else if (!narm) \
return Rf_ScalarInteger(NA_INTEGER); \
px += 1; \
} \
} while (0)

◆ SUM_KERNEL [4/5]

#define SUM_KERNEL ( __for__)
Value:
do { \
__for__ { \
if (!(narm && ISNAN(*px))) \
lr += (sy && i != j) ? 2.0L * *px : *px; \
px += 1; \
} \
} while (0)

◆ SUM_KERNEL [5/5]

#define SUM_KERNEL ( __for__)
Value:
do { \
__for__ { \
if (!(narm && (ISNAN((*px).r) || (!he && ISNAN((*px).i))))) { \
lr += (sy && i != j) ? 2.0L * (*px).r : (*px).r; \
if (!he) \
li += (sy && i != j) ? 2.0L * (*px).i : (*px).i; \
} \
px += 1; \
} \
} while (0)

◆ TRY_INCREMENT

#define TRY_INCREMENT ( x,
y,
label )
Value:
do { \
if ((x >= 0) \
? ( y <= INT_FAST64_MAX - x) \
: (-y <= x - INT_FAST64_MIN)) { \
x += y; \
y = 0; \
count = 0; \
} else \
goto label; \
} while (0)

Definition at line 12 of file Summary.c.

Referenced by dense_sum(), and sparse_sum().

Function Documentation

◆ dense_prod()

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

Definition at line 465 of file Summary.c.

References DIAG, GET_SLOT, LONGDOUBLE_AS_DOUBLE, Matrix_DimSym, Matrix_xSym, PROD, TRANS, and UPLO.

Referenced by R_dense_prod().

◆ dense_sum()

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

Definition at line 24 of file Summary.c.

References DIAG, DIM, GET_SLOT, LONGDOUBLE_AS_DOUBLE, Matrix_xSym, SUM, TRANS, TRY_INCREMENT, and UPLO.

Referenced by R_dense_sum().

◆ R_dense_prod()

SEXP R_dense_prod ( SEXP s_obj,
SEXP s_narm )

Definition at line 898 of file Summary.c.

References dense_prod(), Matrix_class(), valid_dense, and VALID_LOGIC2.

◆ R_dense_sum()

SEXP R_dense_sum ( SEXP s_obj,
SEXP s_narm )

Definition at line 445 of file Summary.c.

References dense_sum(), Matrix_class(), valid_dense, and VALID_LOGIC2.

◆ R_sparse_prod()

SEXP R_sparse_prod ( SEXP s_obj,
SEXP s_narm )

Definition at line 908 of file Summary.c.

References Matrix_class(), sparse_prod(), VALID_LOGIC2, and valid_sparse.

◆ R_sparse_sum()

SEXP R_sparse_sum ( SEXP s_obj,
SEXP s_narm )

Definition at line 455 of file Summary.c.

References Matrix_class(), sparse_sum(), VALID_LOGIC2, and valid_sparse.

◆ sparse_aggregate()

◆ sparse_prod()

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

◆ sparse_sum()

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