Matrix r4655
Loading...
Searching...
No Matches
Macros | Functions
utils-R.c File Reference
#include "Mdefines.h"
#include "utils-R.h"
#include "t_rle.c"

Go to the source code of this file.

Macros

#define DO_INDEX
 
#define DO_INDEX
 
#define DO_NNZ(_CTYPE_, _PTR_, _ISNA_, _ISNZ_, _STRICTLY_ISNZ_)
 
#define TRUE_   ScalarLogical(1)
 
#define FALSE_   ScalarLogical(0)
 
#define do_ii_FILL(_i_, _j_)
 
#define _rle_d_
 
#define _rle_i_
 

Functions

SEXP R_Matrix_version (void)
 
SEXP R_index_triangle (SEXP n, SEXP packed, SEXP upper, SEXP diag)
 
SEXP R_index_diagonal (SEXP n, SEXP packed, SEXP upper)
 
SEXP R_nnz (SEXP x, SEXP countNA, SEXP nnzmax)
 
SEXP R_all0 (SEXP x)
 
SEXP R_any0 (SEXP x)
 
SEXP Mmatrix (SEXP args)
 
static int * expand_cmprPt (int ncol, const int mp[], int mj[])
 Expand compressed pointers in the array mp into a full set of indices in the array mj.
 
SEXP compressed_non_0_ij (SEXP x, SEXP colP)
 Return a 2 column matrix '' cbind(i, j) '' of 0-origin index vectors (i,j) which entirely correspond to the (i,j) slots of as(x, "TsparseMatrix") :
 
SEXP Matrix_expand_pointers (SEXP pP)
 
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}.
 
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}.
 

Macro Definition Documentation

◆ _rle_d_

#define _rle_d_

Definition at line 646 of file utils-R.c.

◆ _rle_i_

#define _rle_i_

Definition at line 650 of file utils-R.c.

◆ do_ii_FILL

#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 Mdefines.h:44

◆ DO_INDEX [1/2]

#define DO_INDEX

◆ DO_INDEX [2/2]

#define DO_INDEX
Value:
do { \
if (!packed_) { \
for (j = 0; j < n_; ++j) { \
*(pr++) = k++; \
k += n_; \
} \
} else if (upper_) { \
for (j = 0; j < n_; ++j) { \
*(pr++) = k; \
k += j+2; \
} \
} else { \
for (j = 0; j < n_; ++j) { \
*(pr++) = k; \
k += n_-j; \
} \
} \
} while (0)

◆ DO_NNZ

#define DO_NNZ (   _CTYPE_,
  _PTR_,
  _ISNA_,
  _ISNZ_,
  _STRICTLY_ISNZ_ 
)
Value:
do { \
_CTYPE_ *px = _PTR_(x); \
if (do_countNA == NA_LOGICAL) { \
while (n-- > 0) { \
if (_ISNA_(*px)) \
return ScalarInteger(NA_INTEGER); \
if (_ISNZ_(*px)) \
++nnz; \
++px; \
} \
} else if (do_countNA != 0) { \
while (n-- > 0) { \
if (_ISNZ_(*px)) \
++nnz; \
++px; \
} \
} else { \
while (n-- > 0) { \
if (_STRICTLY_ISNZ_(*px)) \
++nnz; \
++px; \
} \
} \
} while (0)

◆ FALSE_

#define FALSE_   ScalarLogical(0)

Definition at line 226 of file utils-R.c.

◆ TRUE_

#define TRUE_   ScalarLogical(1)

Definition at line 225 of file utils-R.c.

Function Documentation

◆ compressed_non_0_ij()

SEXP compressed_non_0_ij ( SEXP  x,
SEXP  colP 
)

Return a 2 column matrix '' cbind(i, j) '' of 0-origin index vectors (i,j) which entirely correspond to the (i,j) slots of as(x, "TsparseMatrix") :

Definition at line 483 of file utils-R.c.

References expand_cmprPt(), GET_SLOT, Matrix_DimSym, Matrix_iSym, Matrix_jSym, and Matrix_pSym.

◆ expand_cmprPt()

static int * expand_cmprPt ( int  ncol,
const int  mp[],
int  mj[] 
)
static

Expand compressed pointers in the array mp into a full set of indices in the array mj.

Parameters
ncolnumber of columns (or rows)
mpcolumn pointer vector of length ncol + 1
mjvector of length mp[ncol] to hold the result
Returns
mj

Definition at line 468 of file utils-R.c.

Referenced by compressed_non_0_ij(), and Matrix_expand_pointers().

◆ m_encodeInd()

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 529 of file utils-R.c.

References _, and do_ii_FILL.

◆ m_encodeInd2()

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 607 of file utils-R.c.

References _, and do_ii_FILL.

◆ Matrix_expand_pointers()

SEXP Matrix_expand_pointers ( SEXP  pP)

Definition at line 509 of file utils-R.c.

References expand_cmprPt().

◆ Mmatrix()

SEXP Mmatrix ( SEXP  args)

Definition at line 325 of file utils-R.c.

References _.

◆ R_all0()

SEXP R_all0 ( SEXP  x)

Definition at line 231 of file utils-R.c.

References _, FALSE_, and TRUE_.

◆ R_any0()

SEXP R_any0 ( SEXP  x)

Definition at line 277 of file utils-R.c.

References _, FALSE_, and TRUE_.

◆ R_index_diagonal()

SEXP R_index_diagonal ( SEXP  n,
SEXP  packed,
SEXP  upper 
)

Definition at line 107 of file utils-R.c.

References _, and DO_INDEX.

◆ R_index_triangle()

SEXP R_index_triangle ( SEXP  n,
SEXP  packed,
SEXP  upper,
SEXP  diag 
)

Definition at line 20 of file utils-R.c.

References _, and DO_INDEX.

◆ R_Matrix_version()

SEXP R_Matrix_version ( void  )

Definition at line 4 of file utils-R.c.

References MATRIX_ABI_VERSION, MATRIX_PACKAGE_VERSION, and MATRIX_SUITESPARSE_VERSION.

◆ R_nnz()

SEXP R_nnz ( SEXP  x,
SEXP  countNA,
SEXP  nnzmax 
)