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

Go to the source code of this file.

Macros

#define SUM_TYPEOF(c)
 
#define MAP(i)
 
#define lCAST(x)
 
#define iCAST(x)
 
#define dCAST(x)
 
#define zCAST(x)
 
#define nCAST(x)
 
#define SUM(c0, c1)
 
#define SUM_KERNEL(c0, c1, __for__)
 
#define SUM(c0, c1)
 
#define SUM_KERNEL(c0, c1, __for__)
 
#define nCAST(x)
 
#define SUM(c0, c1)
 
#define SUM(c0, c1)
 
#define SUM(c0, c1)
 

Functions

SEXP sparse_aggregate (SEXP, const char *)
 
static void dense_colsum (SEXP x, const char *class, int m, int n, char ul, char ct, char nu, int narm, int mean, SEXP ans)
 
static void dense_rowsum (SEXP x, const char *class, int m, int n, char ul, char ct, char nu, int narm, int mean, SEXP ans)
 
static void Csparse_colsum (SEXP obj, const char *class, int m, int n, char ul, char ct, char nu, int narm, int mean, SEXP ans)
 
static void Csparse_rowsum (SEXP obj, const char *class, int m, int n, char ul, char ct, char nu, int narm, int mean, SEXP ans, SEXP iSym)
 
static void Tsparse_colsum (SEXP obj, const char *class, int m, int n, char ul, char ct, char nu, int narm, int mean, SEXP ans, SEXP iSym, SEXP jSym)
 
SEXP dense_marginsum (SEXP obj, const char *class, int mg, int narm, int mean)
 
SEXP sparse_marginsum (SEXP obj, const char *class, int mg, int narm, int mean, int sparse)
 
SEXP R_sparse_marginsum (SEXP s_obj, SEXP s_margin, SEXP s_narm, SEXP s_mean, SEXP s_sparse)
 
SEXP R_dense_marginsum (SEXP s_obj, SEXP s_margin, SEXP s_narm, SEXP s_mean)
 

Macro Definition Documentation

◆ dCAST

#define dCAST ( x)
Value:
(x)

Definition at line 16 of file colSums.c.

◆ iCAST

#define iCAST ( x)
Value:
(x)

Definition at line 15 of file colSums.c.

◆ lCAST

#define lCAST ( x)
Value:
(x)

Definition at line 14 of file colSums.c.

◆ MAP

#define MAP ( i)
Value:
(map) ? map[i] : i

Definition at line 12 of file colSums.c.

◆ nCAST [1/2]

#define nCAST ( x)
Value:
(x != 0)

Definition at line 20 of file colSums.c.

◆ nCAST [2/2]

#define nCAST ( x)
Value:
(1)

Definition at line 20 of file colSums.c.

◆ SUM [1/5]

#define SUM ( c0,
c1 )

◆ SUM [2/5]

#define SUM ( c0,
c1 )

◆ SUM [3/5]

#define SUM ( c0,
c1 )
Value:
do { \
c0##IF_NPATTERN( \
SEXP x0 = GET_SLOT(obj, Matrix_xSym); \
c0##TYPE *px0 = c0##PTR(x0); \
); \
c1##TYPE *px1 = c1##PTR(x1), tmp1 = (un) ? c1##UNIT : c1##ZERO; \
for (j = 0, k = 0; j < n; ++j) { \
kend = pp0[j]; \
if (full || k < kend) { \
*px1 = tmp1; \
if (mean) \
count = m; \
while (k < kend) { \
if (c0##NOT_NA(*px0)) \
c1##INCREMENT_IDEN(*px1, c0##CAST(*px0)); \
else if (!narm) \
*px1 = c1##NA; \
else if (mean) \
--count; \
c0##IF_NPATTERN( \
++px0; \
); \
++k; \
} \
if (mean) \
c1##DIVIDE(*px1, count); \
++px1; \
} \
} \
} while (0)
#define GET_SLOT(x, name)
Definition Mdefines.h:72
SEXP Matrix_xSym
Definition init.c:635

◆ SUM [4/5]

#define SUM ( c0,
c1 )

◆ SUM [5/5]

#define SUM ( c0,
c1 )

◆ SUM_KERNEL [1/2]

#define SUM_KERNEL ( c0,
c1,
__for__ )
Value:
do { \
if (mean) \
count = m; \
__for__ { \
if (c0##NOT_NA(*px0)) \
c1##INCREMENT_IDEN(*px1, c0##CAST(*px0)); \
else if (!narm) \
*px1 = c1##NA; \
else if (mean) \
--count; \
px0 += 1; \
} \
if (mean) \
c1##DIVIDE(*px1, count); \
} while (0)

◆ SUM_KERNEL [2/2]

#define SUM_KERNEL ( c0,
c1,
__for__ )
Value:
do { \
__for__ { \
if (he && i == j) \
c0##ASSIGN_PROJ_REAL(tmp0, *px0); \
else \
c0##ASSIGN_IDEN (tmp0, *px0); \
if (c0##NOT_NA(tmp0)) { \
c1##INCREMENT_IDEN(px1[i], c0##CAST(tmp0)); \
if (sy && i != j) { \
if (he) \
c1##INCREMENT_CONJ(px1[j], c0##CAST(tmp0)); \
else \
c1##INCREMENT_IDEN(px1[j], c0##CAST(tmp0)); \
} \
} else if (!narm) { \
px1[i] = c1##NA; \
if (sy && i != j) \
px1[j] = c1##NA; \
} else if (mean) { \
--count[i]; \
if (sy && i != j) \
--count[j]; \
} \
px0 += 1; \
} \
} while (0)

◆ SUM_TYPEOF

#define SUM_TYPEOF ( c)
Value:
(c == 'z') ? CPLXSXP : (mean || c == 'd' || c == 'i') ? REALSXP : INTSXP
cholmod_common c
Definition cholmod-etc.c:5

Definition at line 9 of file colSums.c.

Referenced by Csparse_colsum(), Csparse_rowsum(), dense_marginsum(), sparse_marginsum(), and Tsparse_colsum().

◆ zCAST

#define zCAST ( x)
Value:
(x)

Definition at line 17 of file colSums.c.

Function Documentation

◆ Csparse_colsum()

static void Csparse_colsum ( SEXP obj,
const char * class,
int m,
int n,
char ul,
char ct,
char nu,
int narm,
int mean,
SEXP ans )
static

Definition at line 224 of file colSums.c.

References GET_SLOT, Matrix_iSym, Matrix_pSym, Matrix_xSym, SET_SLOT, SUM, SUM_TYPEOF, and TYPEOF.

Referenced by sparse_marginsum().

◆ Csparse_rowsum()

static void Csparse_rowsum ( SEXP obj,
const char * class,
int m,
int n,
char ul,
char ct,
char nu,
int narm,
int mean,
SEXP ans,
SEXP iSym )
static

Definition at line 316 of file colSums.c.

References GET_SLOT, Matrix_Calloc, Matrix_Free, Matrix_iSym, Matrix_pSym, Matrix_xSym, SET_SLOT, SUM, SUM_TYPEOF, and TYPEOF.

Referenced by sparse_marginsum().

◆ dense_colsum()

static void dense_colsum ( SEXP x,
const char * class,
int m,
int n,
char ul,
char ct,
char nu,
int narm,
int mean,
SEXP ans )
static

Definition at line 23 of file colSums.c.

References SUM.

Referenced by dense_marginsum().

◆ dense_marginsum()

SEXP dense_marginsum ( SEXP obj,
const char * class,
int mg,
int narm,
int mean )

Definition at line 593 of file colSums.c.

References dense_colsum(), dense_rowsum(), DIAG, DIM, DIMNAMES, GET_SLOT, Matrix_xSym, SUM_TYPEOF, TRANS, and UPLO.

Referenced by R_dense_marginsum().

◆ dense_rowsum()

static void dense_rowsum ( SEXP x,
const char * class,
int m,
int n,
char ul,
char ct,
char nu,
int narm,
int mean,
SEXP ans )
static

Definition at line 112 of file colSums.c.

References Matrix_Calloc, Matrix_Free, and SUM.

Referenced by dense_marginsum().

◆ R_dense_marginsum()

SEXP R_dense_marginsum ( SEXP s_obj,
SEXP s_margin,
SEXP s_narm,
SEXP s_mean )

Definition at line 729 of file colSums.c.

References dense_marginsum(), Matrix_class(), valid_dense, VALID_LOGIC2, and VALID_MARGIN.

◆ R_sparse_marginsum()

SEXP R_sparse_marginsum ( SEXP s_obj,
SEXP s_margin,
SEXP s_narm,
SEXP s_mean,
SEXP s_sparse )

Definition at line 713 of file colSums.c.

References Matrix_class(), sparse_marginsum(), VALID_LOGIC2, VALID_MARGIN, and valid_sparse.

◆ sparse_aggregate()

SEXP sparse_aggregate ( SEXP from,
const char * class )

Definition at line 5 of file aggregate.c.

Referenced by Tsparse_colsum().

◆ sparse_marginsum()

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

◆ Tsparse_colsum()

static void Tsparse_colsum ( SEXP obj,
const char * class,
int m,
int n,
char ul,
char ct,
char nu,
int narm,
int mean,
SEXP ans,
SEXP iSym,
SEXP jSym )
static