Matrix  $Rev: 3071 $ at $LastChangedDate: 2015-03-26 15:35:47 +0100 (Thu, 26 Mar 2015) $
Mutils.h
Go to the documentation of this file.
1 #ifndef MATRIX_MUTILS_H
2 #define MATRIX_MUTILS_H
3 
4 #undef Matrix_with_SPQR
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 #include <stdint.h> // C99 for int64_t
11 #include <ctype.h>
12 #include <R.h> /* includes Rconfig.h */
13 #include <Rversion.h>
14 #include <Rdefines.h> /* Rinternals.h + GET_SLOT etc */
15 
16 // must come after <R.h> above, for clang (2015-08-05)
17 #ifdef __GNUC__
18 # undef alloca
19 # define alloca(x) __builtin_alloca((x))
20 #elif defined(__sun) || defined(_AIX)
21 /* this is necessary (and sufficient) for Solaris 10 and AIX 6: */
22 # include <alloca.h>
23 #endif
24 /* For R >= 3.2.2, the 'elif' above shall be replaced by
25 #elif defined(HAVE_ALLOCA_H)
26 */
27 
28 #ifdef ENABLE_NLS
29 #include <libintl.h>
30 #define _(String) dgettext ("Matrix", String)
31 #else
32 #define _(String) (String)
33 /* Note that this is not yet supported (for Windows, e.g.) in R 2.9.0 : */
34 #define dngettext(pkg, String, StringP, N) (N > 1 ? StringP : String)
35 #endif
36 
37 #ifndef LONG_VECTOR_SUPPORT
38 // notably for R <= 2.15.x :
39 # define XLENGTH(x) LENGTH(x)
40 # if R_VERSION < R_Version(2,16,0)
41  typedef int R_xlen_t;
42 # endif
43 #endif
44 
45 #define Alloca(n, t) (t *) alloca( (size_t) ( (n) * sizeof(t) ) )
46 
47 #define SMALL_4_Alloca 10000
48 // ==== R uses the same cutoff in several places
49 
50 #define C_or_Alloca_TO(_VAR_, _N_, _TYPE_) \
51  if(_N_ < SMALL_4_Alloca) { \
52  _VAR_ = Alloca(_N_, _TYPE_); R_CheckStack(); \
53  } else { \
54  _VAR_ = Calloc(_N_, _TYPE_); \
55  }
56 // and user needs to if(_N_ >= SMALL_4_Alloca) Free(_VAR_);
57 
58 SEXP triangularMatrix_validate(SEXP obj);
59 SEXP symmetricMatrix_validate(SEXP obj);
60 SEXP dense_nonpacked_validate(SEXP obj);
61 SEXP dim_validate(SEXP Dim, const char* name);
62 SEXP Dim_validate(SEXP obj, SEXP name);
63 SEXP dimNames_validate(SEXP obj);
64 
65 // La_norm_type() & La_rcond_type() have been in R_ext/Lapack.h
66 // but have still not been available to package writers ...
67 char La_norm_type (const char *typstr);
68 char La_rcond_type(const char *typstr);
69 
70 /* enum constants from cblas.h and some short forms */
76 #define RMJ CblasRowMajor
77 #define CMJ CblasColMajor
78 #define NTR CblasNoTrans
79 #define TRN CblasTrans
80 #define CTR CblasConjTrans
81 #define UPP CblasUpper
82 #define LOW CblasLower
83 #define NUN CblasNonUnit
84 #define UNT CblasUnit
85 #define LFT CblasLeft
86 #define RGT CblasRight
87 
88 double get_double_by_name(SEXP obj, char *nm);
89 SEXP set_double_by_name(SEXP obj, double val, char *nm);
90 SEXP as_det_obj(double val, int log, int sign);
91 SEXP get_factors(SEXP obj, char *nm);
92 SEXP set_factors(SEXP obj, SEXP val, char *nm);
93 SEXP R_set_factors(SEXP obj, SEXP val, SEXP name, SEXP warn);
94 
95 #if 0
96 SEXP dgCMatrix_set_Dim(SEXP x, int nrow);
97 #endif /* unused */
98 
99 /* int csc_unsorted_columns(int ncol, const int p[], const int i[]); */
100 /* void csc_sort_columns(int ncol, const int p[], int i[], double x[]); */
101 /* SEXP csc_check_column_sorting(SEXP A); */
102 
103 SEXP check_scalar_string(SEXP sP, char *vals, char *nm);
104 Rboolean equal_string_vectors(SEXP s1, SEXP s2);
105 
106 void d_packed_getDiag(double *dest, SEXP x, int n);
107 void l_packed_getDiag( int *dest, SEXP x, int n);
108 SEXP d_packed_setDiag(double *diag, int l_d, SEXP x, int n);
109 SEXP l_packed_setDiag( int *diag, int l_d, SEXP x, int n);
110 SEXP d_packed_addDiag(double *diag, int l_d, SEXP x, int n);
111 
112 void tr_d_packed_getDiag(double *dest, SEXP x, int n);
113 void tr_l_packed_getDiag( int *dest, SEXP x, int n);
114 
115 SEXP tr_d_packed_setDiag(double *diag, int l_d, SEXP x, int n);
116 SEXP tr_l_packed_setDiag( int *diag, int l_d, SEXP x, int n);
117 SEXP tr_d_packed_addDiag(double *diag, int l_d, SEXP x, int n);
118 
119 SEXP Matrix_getElement(SEXP list, char *nm);
120 
121 #define PACKED_TO_FULL(TYPE) \
122 TYPE *packed_to_full_ ## TYPE(TYPE *dest, const TYPE *src, \
123  int n, enum CBLAS_UPLO uplo)
124 PACKED_TO_FULL(double);
125 PACKED_TO_FULL(int);
126 #undef PACKED_TO_FULL
127 
128 #define FULL_TO_PACKED(TYPE) \
129 TYPE *full_to_packed_ ## TYPE(TYPE *dest, const TYPE *src, int n, \
130  enum CBLAS_UPLO uplo, enum CBLAS_DIAG diag)
131 FULL_TO_PACKED(double);
132 FULL_TO_PACKED(int);
133 #undef FULL_TO_PACKED
134 
135 
136 extern /* stored pointers to symbols initialized in R_init_Matrix */
137 #include "Syms.h"
138 
139 /* zero an array */
140 #define AZERO(x, n) {int _I_, _SZ_ = (n); for(_I_ = 0; _I_ < _SZ_; _I_++) (x)[_I_] = 0;}
141 // R's RS.h :
142 #define Memzero(p,n) memset(p, 0, (size_t)(n) * sizeof(*p))
143 
144 /* number of elements in one triangle of a square matrix of order n */
145 #define PACKED_LENGTH(n) ((n) * ((n) + 1))/2
146 
147 /* duplicate the slot with name given by sym from src to dest */
148 
149 #define slot_dup(dest, src, sym) SET_SLOT(dest, sym, duplicate(GET_SLOT(src, sym)))
150 
151 /* is not yet used: */
152 #define slot_nonNull_dup(dest, src, sym) \
153  if(GET_SLOT(src, sym) != R_NilValue) \
154  SET_SLOT(dest, sym, duplicate(GET_SLOT(src, sym)))
155 
156 #define slot_dup_if_has(dest, src, sym) \
157  if(R_has_slot(src, sym)) \
158  SET_SLOT(dest, sym, duplicate(GET_SLOT(src, sym)))
159 
160 static R_INLINE
161 void SET_DimNames(SEXP dest, SEXP src) {
162  SEXP dn = GET_SLOT(src, Matrix_DimNamesSym);
163  // Be fast (do nothing!) for the case where dimnames = list(NULL,NULL) :
164  if (!(isNull(VECTOR_ELT(dn,0)) && isNull(VECTOR_ELT(dn,1))))
165  SET_SLOT(dest, Matrix_DimNamesSym, duplicate(dn));
166 }
167 
168 // code in ./Mutils.c :
169 SEXP symmetric_DimNames(SEXP dn);
170 SEXP R_symmetric_Dimnames(SEXP x);
171 void SET_DimNames_symm(SEXP dest, SEXP src);
172 
173 
174 #define uplo_P(_x_) CHAR(STRING_ELT(GET_SLOT(_x_, Matrix_uploSym), 0))
175 #define diag_P(_x_) CHAR(STRING_ELT(GET_SLOT(_x_, Matrix_diagSym), 0))
176 #define Diag_P(_x_) (R_has_slot(x, Matrix_diagSym) ? \
177  CHAR(STRING_ELT(GET_SLOT(_x_, Matrix_diagSym), 0)) : " ")
178 #define class_P(_x_) CHAR(asChar(getAttrib(_x_, R_ClassSymbol)))
179 
180 
182 
183 // Define this "Cholmod compatible" to some degree
185 // n d l i z
186 
187 /* should also work for "matrix" matrices: */
188 #define Real_KIND(_x_) (IS_S4_OBJECT(_x_) ? Real_kind(_x_) : \
189  (isReal(_x_) ? x_double : (isLogical(_x_) ? x_logical : -1)))
190 /* This one gives '0' also for integer "matrix" :*/
191 #define Real_KIND2(_x_) (IS_S4_OBJECT(_x_) ? Real_kind(_x_) : \
192  (isLogical(_x_) ? x_logical : 0))
193 
194 /* requires 'x' slot, i.e., not for ..nMatrix. FIXME ? via R_has_slot(obj, name) */
195 #define Real_kind(_x_) (isReal(GET_SLOT(_x_, Matrix_xSym)) ? 0 : \
196  (isLogical(GET_SLOT(_x_, Matrix_xSym)) ? 1 : -1))
197 
198 #define DECLARE_AND_GET_X_SLOT(__C_TYPE, __SEXP) \
199  __C_TYPE *xx = __SEXP(GET_SLOT(x, Matrix_xSym))
200 
201 
210 static R_INLINE
211 int packed_ncol(int len)
212 {
213  int disc = 8 * len + 1; /* discriminant */
214  int sqrtd = (int) sqrt((double) disc);
215 
216  if (len < 0 || disc != sqrtd * sqrtd)
217  error(_("invalid 'len' = %d in packed_ncol"));
218  return (sqrtd - 1)/2;
219 }
220 
239 static R_INLINE
240 SEXP ALLOC_SLOT(SEXP obj, SEXP nm, SEXPTYPE type, int length)
241 {
242  SEXP val = allocVector(type, length);
243 
244  SET_SLOT(obj, nm, val);
245  return val;
246 }
247 
258 static R_INLINE
259 int* expand_cmprPt(int ncol, const int mp[], int mj[])
260 {
261  int j;
262  for (j = 0; j < ncol; j++) {
263  int j2 = mp[j+1], jj;
264  for (jj = mp[j]; jj < j2; jj++) mj[jj] = j;
265  }
266  return mj;
267 }
268 
276 static R_INLINE
277 Rboolean any_NA_in_x(SEXP obj)
278 {
279  double *x = REAL(GET_SLOT(obj, Matrix_xSym));
280  int i, n = LENGTH(GET_SLOT(obj, Matrix_xSym));
281  for(i=0; i < n; i++)
282  if(ISNAN(x[i])) return TRUE;
283  /* else */
284  return FALSE;
285 }
286 
287 
288 
292 static R_INLINE
293 SEXP inv_permutation(SEXP p_, SEXP zero_p, SEXP zero_res)
294 {
295  int np = 0;
296  if(!isInteger(p_)) {p_ = PROTECT(coerceVector(p_, INTSXP)); np++; }
297  int *p = INTEGER(p_), n = LENGTH(p_);
298  SEXP val = allocVector(INTSXP, n);// (not PROTECT()ing: no alloc from here on)
299  int *v = INTEGER(val), p_0 = asLogical(zero_p), r_0 = asLogical(zero_res);
300  if(!p_0) v--; // ==> use 1-based indices
301  // shorter (but not 100% sure if ok: is LHS always eval'ed *before* RHS ?) :
302  // for(int i=0; i < n; ) v[p[i]] = ++i;
303  for(int i=0; i < n; ) {
304  int j = p[i]; v[j] = (r_0) ? i++ : ++i;
305  }
306  UNPROTECT(np);
307  return val;
308 }
309 
310 SEXP Mmatrix(SEXP args);
311 
312 void make_d_matrix_triangular(double *x, SEXP from);
313 void make_i_matrix_triangular( int *x, SEXP from);
314 
315 void make_d_matrix_symmetric(double *to, SEXP from);
316 void make_i_matrix_symmetric( int *to, SEXP from);
317 
318 SEXP Matrix_expand_pointers(SEXP pP);
319 
320 SEXP dup_mMatrix_as_dgeMatrix2(SEXP A, Rboolean tr_if_vec);
321 SEXP dup_mMatrix_as_dgeMatrix (SEXP A);
322 SEXP dup_mMatrix_as_geMatrix (SEXP A);
323 
324 SEXP new_dgeMatrix(int nrow, int ncol);
325 SEXP m_encodeInd (SEXP ij, SEXP di, SEXP orig_1, SEXP chk_bnds);
326 SEXP m_encodeInd2(SEXP i, SEXP j, SEXP di, SEXP orig_1, SEXP chk_bnds);
327 
328 SEXP R_rbind2_vector(SEXP a, SEXP b);
329 
330 SEXP R_all0(SEXP x);
331 SEXP R_any0(SEXP x);
332 
333 static R_INLINE SEXP
335  return strcmp(class_P(A), "dgeMatrix") ? dup_mMatrix_as_dgeMatrix(A) : A;
336 }
337 static R_INLINE SEXP
338 mMatrix_as_dgeMatrix2(SEXP A, Rboolean tr_if_vec) {
339  return strcmp(class_P(A), "dgeMatrix") ? dup_mMatrix_as_dgeMatrix2(A, tr_if_vec) : A;
340 }
341 
342 static R_INLINE SEXP
344 {
345  return strcmp(class_P(A) + 1, "geMatrix") ? dup_mMatrix_as_geMatrix(A) : A;
346 }
347 
348 // Keep centralized --- *and* in sync with ../inst/include/Matrix.h :
349 #define MATRIX_VALID_ge_dense \
350  "dmatrix", "dgeMatrix", \
351  "lmatrix", "lgeMatrix", \
352  "nmatrix", "ngeMatrix", \
353  "zmatrix", "zgeMatrix"
354 
355 /* NB: ddiMatrix & ldiMatrix are part of VALID_ddense / VALID_ldense
356  * -- even though they are no longer "denseMatrix" formally.
357  * CARE: dup_mMatrix_as_geMatrix() code depends on 14 ddense and 6 ldense
358  * ---- entries here :
359 */
360 #define MATRIX_VALID_ddense \
361  "dgeMatrix", "dtrMatrix", \
362  "dsyMatrix", "dpoMatrix", "ddiMatrix", \
363  "dtpMatrix", "dspMatrix", "dppMatrix", \
364  /* sub classes of those above:*/ \
365  /* dtr */ "Cholesky", "LDL", "BunchKaufman",\
366  /* dtp */ "pCholesky", "pBunchKaufman", \
367  /* dpo */ "corMatrix"
368 
369 #define MATRIX_VALID_ldense \
370  "lgeMatrix", "ltrMatrix", \
371  "lsyMatrix", "ldiMatrix", \
372  "ltpMatrix", "lspMatrix"
373 
374 #define MATRIX_VALID_ndense \
375  "ngeMatrix", "ntrMatrix", \
376  "nsyMatrix", \
377  "ntpMatrix", "nspMatrix"
378 
379 #define MATRIX_VALID_dCsparse \
380  "dgCMatrix", "dsCMatrix", "dtCMatrix"
381 #define MATRIX_VALID_nCsparse \
382  "ngCMatrix", "nsCMatrix", "ntCMatrix"
383 
384 #define MATRIX_VALID_Csparse \
385  MATRIX_VALID_dCsparse, \
386  "lgCMatrix", "lsCMatrix", "ltCMatrix", \
387  MATRIX_VALID_nCsparse, \
388  "zgCMatrix", "zsCMatrix", "ztCMatrix"
389 
390 #define MATRIX_VALID_Tsparse \
391  "dgTMatrix", "dsTMatrix", "dtTMatrix", \
392  "lgTMatrix", "lsTMatrix", "ltTMatrix", \
393  "ngTMatrix", "nsTMatrix", "ntTMatrix", \
394  "zgTMatrix", "zsTMatrix", "ztTMatrix"
395 
396 #define MATRIX_VALID_Rsparse \
397  "dgRMatrix", "dsRMatrix", "dtRMatrix", \
398  "lgRMatrix", "lsRMatrix", "ltRMatrix", \
399  "ngRMatrix", "nsRMatrix", "ntRMatrix", \
400  "zgRMatrix", "zsRMatrix", "ztRMatrix"
401 
402 #define MATRIX_VALID_tri_Csparse \
403  "dtCMatrix", "ltCMatrix", "ntCMatrix", "ztCMatrix"
404 
405 #ifdef __UN_USED__
406 #define MATRIX_VALID_tri_sparse \
407  "dtCMatrix", "dtTMatrix", "dtRMatrix", \
408  "ltCMatrix", "ltTMatrix", "ltRMatrix", \
409  "ntCMatrix", "ntTMatrix", "ntRMatrix", \
410  "ztCMatrix", "ztTMatrix", "ztRMatrix"
411 
412 #define MATRIX_VALID_tri_dense \
413  "dtrMatrix", "dtpMatrix" \
414  "ltrMatrix", "ltpMatrix" \
415  "ntrMatrix", "ntpMatrix" \
416  "ztrMatrix", "ztpMatrix"
417 #endif
418 
419 #define MATRIX_VALID_CHMfactor "dCHMsuper", "dCHMsimpl", "nCHMsuper", "nCHMsimpl"
420 
431 static R_INLINE int
432 Matrix_check_class(char *class, const char **valid)
433 {
434  int ans;
435  for (ans = 0; ; ans++) {
436  if (!strlen(valid[ans])) return -1;
437  if (!strcmp(class, valid[ans])) return ans;
438  }
439 }
440 
452 // No longer:
453 #ifdef DEPRECATED_Matrix_check_class_
454 # define Matrix_check_class_etc R_check_class_etc
455 # define Matrix_check_class_and_super R_check_class_and_super
456 #endif
457 
458 
462 // Type_ans sparseVector_sub(int64_t i, int nnz_v, int* v_i, Type_ans* v_x, int len_v):
463 
464 /* Define all of
465  * dsparseVector_sub(....)
466  * isparseVector_sub(....)
467  * lsparseVector_sub(....)
468  * nsparseVector_sub(....)
469  * zsparseVector_sub(....)
470  */
471 #define _dspV_
472 #include "t_sparseVector.c"
473 
474 #define _ispV_
475 #include "t_sparseVector.c"
476 
477 #define _lspV_
478 #include "t_sparseVector.c"
479 
480 #define _nspV_
481 #include "t_sparseVector.c"
482 
483 #define _zspV_
484 #include "t_sparseVector.c"
485 
486 
487 #ifdef __cplusplus
488 }
489 #endif
490 
491 #endif /* MATRIX_MUTILS_H_ */
#define class_P(_x_)
Definition: Mutils.h:178
SEXP R_rbind2_vector(SEXP a, SEXP b)
From the two 'x' slots of two dense matrices a and b, compute the 'x' slot of rbind(a, b)
Definition: Mutils.c:1120
SEXP triangularMatrix_validate(SEXP obj)
Definition: dtrMatrix.c:5
x_slot_kind
Definition: Mutils.h:184
CBLAS_SIDE
Definition: Mutils.h:75
void SET_DimNames_symm(SEXP dest, SEXP src)
Set 'Dimnames' slot of 'dest' from the one of 'src' when 'src' is a "symmetricMatrix" with possibly a...
Definition: Mutils.c:1328
SEXP d_packed_setDiag(double *diag, int l_d, SEXP x, int n)
Definition: Mutils.c:461
static R_INLINE SEXP mMatrix_as_dgeMatrix2(SEXP A, Rboolean tr_if_vec)
Definition: Mutils.h:338
SEXP Matrix_xSym
Definition: Syms.h:2
void make_d_matrix_symmetric(double *to, SEXP from)
char La_rcond_type(const char *typstr)
Definition: Mutils.c:27
SEXP Matrix_DimNamesSym
Definition: Syms.h:2
CBLAS_ORDER
Definition: Mutils.h:71
void make_i_matrix_symmetric(int *to, SEXP from)
static R_INLINE int Matrix_check_class(char *class, const char **valid)
Return the 0-based index of a string match in a vector of strings terminated by an empty string...
Definition: Mutils.h:432
SEXP Dim_validate(SEXP obj, SEXP name)
Definition: Mutils.c:337
static R_INLINE SEXP mMatrix_as_dgeMatrix(SEXP A)
Definition: Mutils.h:334
SEXP symmetricMatrix_validate(SEXP obj)
Definition: dsyMatrix.c:3
dense_enum
Definition: Mutils.h:181
SEXP as_det_obj(double val, int log, int sign)
Definition: Mutils.c:89
void make_i_matrix_triangular(int *x, SEXP from)
SEXP l_packed_setDiag(int *diag, int l_d, SEXP x, int n)
Definition: Mutils.c:491
Definition: Mutils.h:181
SEXP dup_mMatrix_as_geMatrix(SEXP A)
Duplicate a [dln]denseMatrix or a numeric matrix or even a vector as a [dln]geMatrix.
Definition: Mutils.c:648
SEXP tr_d_packed_setDiag(double *diag, int l_d, SEXP x, int n)
Definition: Mutils.c:505
static R_INLINE SEXP inv_permutation(SEXP p_, SEXP zero_p, SEXP zero_res)
Inverse Permutation C version of .inv.perm.R <- function(p) { p[p] <- seq_along(p) ; p }...
Definition: Mutils.h:293
SEXP Mmatrix(SEXP args)
Definition: Mutils.c:980
static R_INLINE SEXP mMatrix_as_geMatrix(SEXP A)
Definition: Mutils.h:343
SEXP R_set_factors(SEXP obj, SEXP val, SEXP name, SEXP warn)
Definition: Mutils.c:166
CBLAS_DIAG
Definition: Mutils.h:74
SEXP tr_l_packed_setDiag(int *diag, int l_d, SEXP x, int n)
Definition: Mutils.c:511
void tr_l_packed_getDiag(int *dest, SEXP x, int n)
Definition: Mutils.c:561
static R_INLINE 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...
Definition: Mutils.h:259
SEXP Matrix_expand_pointers(SEXP pP)
Definition: Mutils.c:571
SEXP R_symmetric_Dimnames(SEXP x)
Even if the Dimnames slot is list(NULL, ) etc, return symmetric dimnames: Get ...
Definition: Mutils.c:1315
void d_packed_getDiag(double *dest, SEXP x, int n)
Copy the diagonal elements of the packed denseMatrix x to dest.
Definition: Mutils.c:433
double get_double_by_name(SEXP obj, char *nm)
Definition: Mutils.c:44
SEXP R_any0(SEXP x)
Definition: Mutils.c:1222
#define _(String)
Definition: Mutils.h:32
SEXP tr_d_packed_addDiag(double *diag, int l_d, SEXP x, int n)
Definition: Mutils.c:539
void l_packed_getDiag(int *dest, SEXP x, int n)
Definition: Mutils.c:450
SEXP d_packed_addDiag(double *diag, int l_d, SEXP x, int n)
Definition: Mutils.c:523
#define FULL_TO_PACKED(TYPE)
Definition: Mutils.h:128
SEXP dup_mMatrix_as_dgeMatrix(SEXP A)
Definition: Mutils.c:852
SEXP get_factors(SEXP obj, char *nm)
Definition: Mutils.c:106
SEXP dense_nonpacked_validate(SEXP obj)
Definition: Mutils.c:310
Definition: Mutils.h:181
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}.
Definition: Mutils.c:945
Rboolean equal_string_vectors(SEXP s1, SEXP s2)
Definition: Mutils.c:286
#define PACKED_TO_FULL(TYPE)
Definition: Mutils.h:121
SEXP check_scalar_string(SEXP sP, char *vals, char *nm)
Check validity of 1-letter string from a set of possible values (typically used in S4 validity method...
Definition: Mutils.c:254
Definition: Mutils.h:181
void make_d_matrix_triangular(double *x, SEXP from)
SEXP set_factors(SEXP obj, SEXP val, char *nm)
Caches 'val' in the 'factors' slot of obj, i.e.
Definition: Mutils.c:130
CBLAS_TRANSPOSE
Definition: Mutils.h:72
static R_INLINE int packed_ncol(int len)
Check for valid length of a packed triangular array and return the corresponding number of columns...
Definition: Mutils.h:211
SEXP dim_validate(SEXP Dim, const char *name)
Definition: Mutils.c:318
static R_INLINE void SET_DimNames(SEXP dest, SEXP src)
Definition: Mutils.h:161
CBLAS_UPLO
Definition: Mutils.h:73
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}.
Definition: Mutils.c:880
static R_INLINE Rboolean any_NA_in_x(SEXP obj)
Check if slot(obj, "x") contains any NA (or NaN).
Definition: Mutils.h:277
char La_norm_type(const char *typstr)
Definition: Mutils.c:8
SEXP new_dgeMatrix(int nrow, int ncol)
Definition: Mutils.c:856
void tr_d_packed_getDiag(double *dest, SEXP x, int n)
Definition: Mutils.c:551
SEXP dimNames_validate(SEXP obj)
Definition: Mutils.c:343
SEXP R_all0(SEXP x)
Definition: Mutils.c:1180
static R_INLINE SEXP ALLOC_SLOT(SEXP obj, SEXP nm, SEXPTYPE type, int length)
Allocate an SEXP of given type and length, assign it as slot nm in the object, and return the SEXP...
Definition: Mutils.h:240
SEXP Matrix_getElement(SEXP list, char *nm)
Return the element of a given name from a named list.
Definition: Mutils.c:592
SEXP set_double_by_name(SEXP obj, double val, char *nm)
Definition: Mutils.c:60
SEXP dup_mMatrix_as_dgeMatrix2(SEXP A, Rboolean tr_if_vec)
Definition: Mutils.c:821
SEXP symmetric_DimNames(SEXP dn)
Produce symmetric 'Dimnames' from possibly asymmetric ones.
Definition: Mutils.c:1269