Matrix r4655
Loading...
Searching...
No Matches
utils-R.c
Go to the documentation of this file.
1#include "Mdefines.h"
2#include "utils-R.h"
3
5{
6 SEXP ans, nms;
7 PROTECT(ans = allocVector(INTSXP, 3));
8 INTEGER(ans)[0] = MATRIX_PACKAGE_VERSION;
9 INTEGER(ans)[1] = MATRIX_ABI_VERSION;
10 INTEGER(ans)[2] = MATRIX_SUITESPARSE_VERSION;
11 PROTECT(nms = allocVector(STRSXP, 3));
12 SET_STRING_ELT(nms, 0, mkChar("package"));
13 SET_STRING_ELT(nms, 1, mkChar("abi"));
14 SET_STRING_ELT(nms, 2, mkChar("suitesparse"));
15 setAttrib(ans, R_NamesSymbol, nms);
16 UNPROTECT(2);
17 return ans;
18}
19
20SEXP R_index_triangle(SEXP n, SEXP packed, SEXP upper, SEXP diag)
21{
22 SEXP r;
23 int i, j, n_ = asInteger(n), packed_ = asLogical(packed),
24 upper_ = asLogical(upper), diag_ = asLogical(diag);
26 nn = (Matrix_int_fast64_t) n_ * n_,
27 nx = (packed_) ? n_ + (nn - n_) / 2 : nn,
28 nr = (diag_) ? n_ + (nn - n_) / 2 : (nn - n_) / 2;
29 if (nx > 0x1.0p+53)
30 error(_("indices would exceed %s"), "2^53");
31 if (nr > R_XLEN_T_MAX)
32 error(_("attempt to allocate vector of length exceeding %s"),
33 "R_XLEN_T_MAX");
34
35#define DO_INDEX \
36 do { \
37 if (packed_) { \
38 if (diag_) { \
39 while (k <= nr_) \
40 *(pr++) = k++; \
41 } else if (upper_) { \
42 for (j = 0; j < n_; ++j) { \
43 for (i = 0; i < j; ++i) \
44 *(pr++) = k++; \
45 k++; \
46 } \
47 } else { \
48 for (j = 0; j < n_; ++j) { \
49 k++; \
50 for (i = j+1; i < n_; ++i) \
51 *(pr++) = k++; \
52 } \
53 } \
54 } else if (diag_) { \
55 if (upper_) { \
56 for (j = 0; j < n_; ++j) { \
57 for (i = 0; i <= j; ++i) \
58 *(pr++) = k++; \
59 k += n_-j-1; \
60 } \
61 } else { \
62 for (j = 0; j < n_; ++j) { \
63 k += j; \
64 for (i = j; i < n_; ++i) \
65 *(pr++) = k++; \
66 } \
67 } \
68 } else { \
69 if (upper_) { \
70 for (j = 0; j < n_; ++j) { \
71 for (i = 0; i < j; ++i) \
72 *(pr++) = k++; \
73 k += n_-j; \
74 } \
75 } else { \
76 for (j = 0; j < n_; ++j) { \
77 k += j+1; \
78 for (i = j+1; i < n_; ++i) \
79 *(pr++) = k++; \
80 } \
81 } \
82 } \
83 } while (0)
84
85 if (nx > INT_MAX) {
86
87 PROTECT(r = allocVector(REALSXP, (R_xlen_t) nr));
88 double k = 1.0, nr_ = (double) nr, *pr = REAL(r);
89
91
92 } else {
93
94 PROTECT(r = allocVector(INTSXP, (R_xlen_t) nr));
95 int k = 1, nr_ = (int) nr, *pr = INTEGER(r);
96
98
99 }
100
101#undef DO_INDEX
102
103 UNPROTECT(1);
104 return r;
105}
106
107SEXP R_index_diagonal(SEXP n, SEXP packed, SEXP upper)
108{
109 SEXP r;
110 int j, n_ = asInteger(n), packed_ = asLogical(packed),
111 upper_ = asLogical(upper);
113 nn = (Matrix_int_fast64_t) n_ * n_,
114 nx = (packed_) ? n_ + (nn - n_) / 2 : nn;
115 if (nx > 0x1.0p+53)
116 error(_("indices would exceed %s"), "2^53");
117
118#define DO_INDEX \
119 do { \
120 if (!packed_) { \
121 for (j = 0; j < n_; ++j) { \
122 *(pr++) = k++; \
123 k += n_; \
124 } \
125 } else if (upper_) { \
126 for (j = 0; j < n_; ++j) { \
127 *(pr++) = k; \
128 k += j+2; \
129 } \
130 } else { \
131 for (j = 0; j < n_; ++j) { \
132 *(pr++) = k; \
133 k += n_-j; \
134 } \
135 } \
136 } while (0)
137
138 if (nx > INT_MAX) {
139
140 PROTECT(r = allocVector(REALSXP, n_));
141 double k = 1.0, *pr = REAL(r);
142
143 DO_INDEX;
144
145 } else {
146
147 PROTECT(r = allocVector(INTSXP, n_));
148 int k = 1, *pr = INTEGER(r);
149 DO_INDEX;
150
151 }
152
153#undef DO_INDEX
154
155 UNPROTECT(1);
156 return r;
157}
158
159SEXP R_nnz(SEXP x, SEXP countNA, SEXP nnzmax)
160{
161 int do_countNA = asLogical(countNA);
162 R_xlen_t n = XLENGTH(x), nnz = 0;
163 double n_ = asReal(nnzmax);
164 if (!ISNAN(n_) && n_ >= 0.0 && n_ < (double) n)
165 n = (R_xlen_t) n_;
166
167#define DO_NNZ(_CTYPE_, _PTR_, _ISNA_, _ISNZ_, _STRICTLY_ISNZ_) \
168 do { \
169 _CTYPE_ *px = _PTR_(x); \
170 if (do_countNA == NA_LOGICAL) { \
171 while (n-- > 0) { \
172 if (_ISNA_(*px)) \
173 return ScalarInteger(NA_INTEGER); \
174 if (_ISNZ_(*px)) \
175 ++nnz; \
176 ++px; \
177 } \
178 } else if (do_countNA != 0) { \
179 while (n-- > 0) { \
180 if (_ISNZ_(*px)) \
181 ++nnz; \
182 ++px; \
183 } \
184 } else { \
185 while (n-- > 0) { \
186 if (_STRICTLY_ISNZ_(*px)) \
187 ++nnz; \
188 ++px; \
189 } \
190 } \
191 } while (0)
192
193 switch (TYPEOF(x)) {
194 case LGLSXP:
195 DO_NNZ(int, LOGICAL,
197 break;
198 case INTSXP:
199 DO_NNZ(int, INTEGER,
201 break;
202 case REALSXP:
203 DO_NNZ(double, REAL,
205 break;
206 case CPLXSXP:
207 DO_NNZ(Rcomplex, COMPLEX,
209 break;
210 default:
211 ERROR_INVALID_TYPE(x, __func__);
212 }
213
214#undef DO_NNZ
215
216 return (nnz <= INT_MAX)
217 ? ScalarInteger((int) nnz) : ScalarReal((double) nnz);
218}
219
220
221/* ================================================================== */
222/* ================================================================== */
223
224
225#define TRUE_ ScalarLogical(1)
226#define FALSE_ ScalarLogical(0)
227
228// Fast implementation of [ originally in ../R/Auxiliaries.R ]
229// all0 <- function(x) !any(is.na(x)) && all(!x) ## ~= allFalse
230// allFalse <- function(x) !any(x) && !any(is.na(x)) ## ~= all0
231SEXP R_all0(SEXP x) {
232 if (!isVectorAtomic(x)) {
233 if (length(x) == 0) return TRUE_;
234 // Typically S4. TODO: Call the R code above, instead!
235 error(_("Argument must be numeric-like atomic vector"));
236 }
237 R_xlen_t i, n = XLENGTH(x);
238 if (n == 0) return TRUE_;
239
240 switch (TYPEOF(x)) {
241 case LGLSXP:
242 {
243 int *xx = LOGICAL(x);
244 for (i = 0; i < n; i++)
245 if (xx[i] == NA_LOGICAL || xx[i] != 0) return FALSE_;
246 return TRUE_;
247 }
248 case INTSXP:
249 {
250 int *xx = INTEGER(x);
251 for (i = 0; i < n; i++)
252 if (xx[i] == NA_INTEGER || xx[i] != 0) return FALSE_;
253 return TRUE_;
254 }
255 case REALSXP:
256 {
257 double *xx = REAL(x);
258 for (i = 0; i < n; i++)
259 if (ISNAN(xx[i]) || xx[i] != 0.) return FALSE_;
260 return TRUE_;
261 }
262 case RAWSXP:
263 {
264 unsigned char *xx = RAW(x);
265 for (i = 0; i < n; i++)
266 if (xx[i] != 0) return FALSE_;
267 return TRUE_;
268 }
269 }
270 error(_("Argument must be numeric-like atomic vector"));
271 return R_NilValue; // -Wall
272}
273
274// Fast implementation of [ originally in ../R/Auxiliaries.R ]
275// any0 <- function(x) isTRUE(any(x == 0)) ## ~= anyFalse
276// anyFalse <- function(x) isTRUE(any(!x)) ## ~= any0
277SEXP R_any0(SEXP x) {
278 if (!isVectorAtomic(x)) {
279 if (length(x) == 0) return FALSE_;
280 // Typically S4. TODO: Call the R code above, instead!
281 error(_("Argument must be numeric-like atomic vector"));
282 }
283 R_xlen_t i, n = XLENGTH(x);
284 if (n == 0) return FALSE_;
285
286 switch (TYPEOF(x)) {
287 case LGLSXP:
288 {
289 int *xx = LOGICAL(x);
290 for (i = 0; i < n; i++) if (xx[i] == 0) return TRUE_;
291 return FALSE_;
292 }
293 case INTSXP:
294 {
295 int *xx = INTEGER(x);
296 for (i = 0; i < n; i++) if (xx[i] == 0) return TRUE_;
297 return FALSE_;
298 }
299 case REALSXP:
300 {
301 double *xx = REAL(x);
302 for (i = 0; i < n; i++) if (xx[i] == 0.) return TRUE_;
303 return FALSE_;
304 }
305 case RAWSXP:
306 {
307 unsigned char *xx = RAW(x);
308 for (i = 0; i < n; i++) if (xx[i] == 0) return TRUE_;
309 return FALSE_;
310 }
311 }
312 error(_("Argument must be numeric-like atomic vector"));
313 return R_NilValue; // -Wall
314}
315
316#undef TRUE_
317#undef FALSE_
318
319// Almost "Cut n Paste" from ...R../src/main/array.c do_matrix() :
320// used in ../R/Matrix.R as
321//
322// .External(Mmatrix,
323// data, nrow, ncol, byrow, dimnames,
324// missing(nrow), missing(ncol))
325SEXP Mmatrix(SEXP args)
326{
327 SEXP vals, ans, snr, snc, dimnames;
328 int nr = 1, nc = 1, byrow, miss_nr, miss_nc;
329 R_xlen_t lendat;
330
331 args = CDR(args); /* skip 'name' */
332 vals = CAR(args); args = CDR(args);
333 /* Supposedly as.vector() gave a vector type, but we check */
334 switch (TYPEOF(vals)) {
335 case LGLSXP:
336 case INTSXP:
337 case REALSXP:
338 case CPLXSXP:
339 case STRSXP:
340 case RAWSXP:
341 case EXPRSXP:
342 case VECSXP:
343 break;
344 default:
345 error(_("'data' must be of a vector type"));
346 }
347 lendat = XLENGTH(vals);
348 snr = CAR(args); args = CDR(args);
349 snc = CAR(args); args = CDR(args);
350 byrow = asLogical(CAR(args)); args = CDR(args);
351 if (byrow == NA_INTEGER)
352 error(_("invalid '%s' argument"), "byrow");
353 dimnames = CAR(args);
354 args = CDR(args);
355 miss_nr = asLogical(CAR(args)); args = CDR(args);
356 miss_nc = asLogical(CAR(args));
357
358 if (!miss_nr) {
359 if (!isNumeric(snr)) error(_("non-numeric matrix extent"));
360 nr = asInteger(snr);
361 if (nr == NA_INTEGER)
362 error(_("invalid 'nrow' value (too large or NA)"));
363 if (nr < 0)
364 error(_("invalid 'nrow' value (< 0)"));
365 }
366 if (!miss_nc) {
367 if (!isNumeric(snc)) error(_("non-numeric matrix extent"));
368 nc = asInteger(snc);
369 if (nc == NA_INTEGER)
370 error(_("invalid 'ncol' value (too large or NA)"));
371 if (nc < 0)
372 error(_("invalid 'ncol' value (< 0)"));
373 }
374 if (miss_nr && miss_nc) {
375 if (lendat > INT_MAX) error("data is too long");
376 nr = (int) lendat;
377 } else if (miss_nr) {
378 if (lendat > (double) nc * INT_MAX) error("data is too long");
379 nr = (int) ceil((double) lendat / (double) nc);
380 } else if (miss_nc) {
381 if (lendat > (double) nr * INT_MAX) error("data is too long");
382 nc = (int) ceil((double) lendat / (double) nr);
383 }
384
385 if (lendat > 0) {
386 R_xlen_t nrc = (R_xlen_t) nr * nc;
387 if (lendat > 1 && nrc % lendat != 0) {
388 if ((lendat > nr && (lendat / nr) * nr != lendat) ||
389 (lendat < nr && (nr / lendat) * lendat != nr))
390 warning(_("data length [%lld] is not a sub-multiple "
391 "or multiple of the number of rows [%d]"),
392 (long long)lendat, nr);
393 else if ((lendat > nc && (lendat / nc) * nc != lendat) ||
394 (lendat < nc && (nc / lendat) * lendat != nc))
395 warning(_("data length [%lld] is not a sub-multiple "
396 "or multiple of the number of columns [%d]"),
397 (long long)lendat, nc);
398 } else if (lendat > 1 && nrc == 0)
399 warning(_("data length exceeds size of matrix"));
400 }
401
402#ifndef LONG_VECTOR_SUPPORT
403 if ((double) nr * (double) nc > INT_MAX)
404 error(_("too many elements specified"));
405#endif
406
407 PROTECT(ans = allocMatrix(TYPEOF(vals), nr, nc));
408 if (lendat) {
409 if (isVector(vals))
410 copyMatrix(ans, vals, byrow);
411 else
412 copyListMatrix(ans, vals, byrow);
413 } else if (isVector(vals)) { /* fill with NAs */
414 R_xlen_t N = (R_xlen_t) nr * nc, i;
415 switch (TYPEOF(vals)) {
416 case STRSXP:
417 for (i = 0; i < N; i++)
418 SET_STRING_ELT(ans, i, NA_STRING);
419 break;
420 case LGLSXP:
421 for (i = 0; i < N; i++)
422 LOGICAL(ans)[i] = NA_LOGICAL;
423 break;
424 case INTSXP:
425 for (i = 0; i < N; i++)
426 INTEGER(ans)[i] = NA_INTEGER;
427 break;
428 case REALSXP:
429 for (i = 0; i < N; i++)
430 REAL(ans)[i] = NA_REAL;
431 break;
432 case CPLXSXP:
433 {
434 /* Initialization must work whether Rcomplex is typedef-ed
435 to a struct { R < 4.3.0 } or to a union { R >= 4.3.0 }
436 */
437 Rcomplex zna = { .r = NA_REAL, .i = 0.0 };
438 for (i = 0; i < N; i++)
439 COMPLEX(ans)[i] = zna;
440 break;
441 }
442 case RAWSXP:
443 // FIXME: N may overflow size_t !!
444 memset(RAW(ans), 0, N);
445 break;
446 default:
447 /* don't fill with anything */
448 ;
449 }
450 }
451 if (!isNull(dimnames)&& length(dimnames) > 0)
452 ans = dimnamesgets(ans, dimnames);
453 UNPROTECT(1);
454 return ans;
455}
456
467static
468int *expand_cmprPt(int ncol, const int mp[], int mj[])
469{
470 int j;
471 for (j = 0; j < ncol; j++) {
472 int j2 = mp[j+1], jj;
473 for (jj = mp[j]; jj < j2; jj++)
474 mj[jj] = j;
475 }
476 return mj;
477}
478
483SEXP compressed_non_0_ij(SEXP x, SEXP colP)
484{
485 int col = asLogical(colP); /* 1 if "C"olumn compressed; 0 if "R"ow */
486 SEXP ans, indSym = col ? Matrix_iSym : Matrix_jSym;
487 SEXP indP = PROTECT(GET_SLOT(x, indSym)),
488 pP = PROTECT(GET_SLOT(x, Matrix_pSym));
489 int i, *ij;
490 int nouter = INTEGER(GET_SLOT(x, Matrix_DimSym))[col ? 1 : 0],
491 n_el = INTEGER(pP)[nouter]; /* is only == length(indP), if the
492 inner slot is not over-allocated */
493
494 ij = INTEGER(ans = PROTECT(allocMatrix(INTSXP, n_el, 2)));
495 /* expand the compressed margin to 'i' or 'j' : */
496 expand_cmprPt(nouter, INTEGER(pP), &ij[col ? n_el : 0]);
497 /* and copy the other one: */
498 if (col)
499 for(i = 0; i < n_el; i++)
500 ij[i] = INTEGER(indP)[i];
501 else /* row compressed */
502 for(i = 0; i < n_el; i++)
503 ij[i + n_el] = INTEGER(indP)[i];
504
505 UNPROTECT(3);
506 return ans;
507}
508
510{
511 int n = length(pP) - 1;
512 int *p = INTEGER(pP);
513 SEXP ans = PROTECT(allocVector(INTSXP, p[n]));
514
515 expand_cmprPt(n, p, INTEGER(ans));
516 UNPROTECT(1);
517 return ans;
518}
519
529SEXP m_encodeInd(SEXP ij, SEXP di, SEXP orig_1, SEXP chk_bnds)
530{
531 SEXP ans;
532 int *ij_di = NULL, n, nprot=1;
533 Rboolean check_bounds = asLogical(chk_bnds), one_ind = asLogical(orig_1);
534
535 if (TYPEOF(di) != INTSXP) {
536 di = PROTECT(coerceVector(di, INTSXP));
537 nprot++;
538 }
539 if (TYPEOF(ij) != INTSXP) {
540 ij = PROTECT(coerceVector(ij, INTSXP));
541 nprot++;
542 }
543 if (!isMatrix(ij) ||
544 (ij_di = INTEGER(getAttrib(ij, R_DimSymbol)))[1] != 2)
545 error(_("Argument ij must be 2-column integer matrix"));
546 n = ij_di[0];
547 int *Di = INTEGER(di), *IJ = INTEGER(ij),
548 *j_ = IJ+n;/* pointer offset! */
549
550 if ((Di[0] * (double) Di[1]) >= 1 + (double)INT_MAX) { /* need double */
551 ans = PROTECT(allocVector(REALSXP, n));
552 double *ii = REAL(ans), nr = (double) Di[0];
553
554#define do_ii_FILL(_i_, _j_) \
555 int i; \
556 if (check_bounds) { \
557 for (i = 0; i < n; i++) { \
558 if (_i_[i] == NA_INTEGER || _j_[i] == NA_INTEGER) \
559 ii[i] = NA_INTEGER; \
560 else { \
561 register int i_i, j_i; \
562 if (one_ind) { \
563 i_i = _i_[i]-1; \
564 j_i = _j_[i]-1; \
565 } else { \
566 i_i = _i_[i]; \
567 j_i = _j_[i]; \
568 } \
569 if (i_i < 0 || i_i >= Di[0]) \
570 error(_("subscript 'i' out of bounds in M[ij]")); \
571 if (j_i < 0 || j_i >= Di[1]) \
572 error(_("subscript 'j' out of bounds in M[ij]")); \
573 ii[i] = i_i + j_i * nr; \
574 } \
575 } \
576 } else { \
577 for (i = 0; i < n; i++) \
578 ii[i] = (_i_[i] == NA_INTEGER || _j_[i] == NA_INTEGER) \
579 ? NA_INTEGER \
580 : ((one_ind) \
581 ? ((_i_[i]-1) + (_j_[i]-1) * nr) \
582 : _i_[i] + _j_[i] * nr); \
583 }
584
585 do_ii_FILL(IJ, j_);
586 } else {
587 ans = PROTECT(allocVector(INTSXP, n));
588 int *ii = INTEGER(ans), nr = Di[0];
589
590 do_ii_FILL(IJ, j_);
591 }
592 UNPROTECT(nprot);
593 return ans;
594}
595
607SEXP m_encodeInd2(SEXP i, SEXP j, SEXP di, SEXP orig_1, SEXP chk_bnds)
608{
609 SEXP ans;
610 int n = LENGTH(i), nprot = 1;
611 Rboolean check_bounds = asLogical(chk_bnds), one_ind = asLogical(orig_1);
612
613 if (TYPEOF(di)!= INTSXP) {
614 di = PROTECT(coerceVector(di,INTSXP));
615 nprot++;
616 }
617 if (TYPEOF(i) != INTSXP) {
618 i = PROTECT(coerceVector(i, INTSXP));
619 nprot++;
620 }
621 if (TYPEOF(j) != INTSXP) {
622 j = PROTECT(coerceVector(j, INTSXP));
623 nprot++;
624 }
625 if (LENGTH(j) != n)
626 error(_("i and j must be integer vectors of the same length"));
627
628 int *Di = INTEGER(di), *i_ = INTEGER(i), *j_ = INTEGER(j);
629
630 if ((Di[0] * (double) Di[1]) >= 1 + (double) INT_MAX) { /* need double */
631 ans = PROTECT(allocVector(REALSXP, n));
632 double *ii = REAL(ans), nr = (double) Di[0];
633
634 do_ii_FILL(i_, j_);
635 } else {
636 ans = PROTECT(allocVector(INTSXP, n));
637 int *ii = INTEGER(ans), nr = Di[0];
638
639 do_ii_FILL(i_, j_);
640 }
641 UNPROTECT(nprot);
642 return ans;
643}
644#undef do_ii_FILL
645
646#define _rle_d_
647#include "t_rle.c"
648#undef _rle_d_
649
650#define _rle_i_
651#include "t_rle.c"
652#undef _rle_i_
#define STRICTLY_ISNZ_REAL(_X_)
Definition Mdefines.h:120
long long Matrix_int_fast64_t
Definition Mdefines.h:27
#define ISNA_LOGICAL(_X_)
Definition Mdefines.h:103
#define STRICTLY_ISNZ_LOGICAL(_X_)
Definition Mdefines.h:116
#define STRICTLY_ISNZ_COMPLEX(_X_)
Definition Mdefines.h:122
#define _(String)
Definition Mdefines.h:44
#define ISNZ_REAL(_X_)
Definition Mdefines.h:111
#define ISNA_INTEGER(_X_)
Definition Mdefines.h:104
#define STRICTLY_ISNZ_INTEGER(_X_)
Definition Mdefines.h:118
#define ERROR_INVALID_TYPE(_X_, _FUNC_)
Definition Mdefines.h:204
#define ISNZ_LOGICAL(_X_)
Definition Mdefines.h:109
#define ISNA_REAL(_X_)
Definition Mdefines.h:105
#define ISNZ_INTEGER(_X_)
Definition Mdefines.h:110
#define GET_SLOT(x, what)
Definition Mdefines.h:85
#define ISNZ_COMPLEX(_X_)
Definition Mdefines.h:112
#define ISNA_COMPLEX(_X_)
Definition Mdefines.h:106
SEXP Matrix_DimSym
Definition Msymbols.h:3
SEXP Matrix_iSym
Definition Msymbols.h:13
SEXP Matrix_jSym
Definition Msymbols.h:14
SEXP Matrix_pSym
Definition Msymbols.h:17
SEXP R_all0(SEXP x)
Definition utils-R.c:231
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 utils-R.c:607
SEXP R_index_diagonal(SEXP n, SEXP packed, SEXP upper)
Definition utils-R.c:107
SEXP R_nnz(SEXP x, SEXP countNA, SEXP nnzmax)
Definition utils-R.c:159
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 ...
Definition utils-R.c:483
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.
Definition utils-R.c:468
#define DO_NNZ(_CTYPE_, _PTR_, _ISNA_, _ISNZ_, _STRICTLY_ISNZ_)
#define do_ii_FILL(_i_, _j_)
SEXP R_Matrix_version(void)
Definition utils-R.c:4
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 utils-R.c:529
#define TRUE_
Definition utils-R.c:225
SEXP R_index_triangle(SEXP n, SEXP packed, SEXP upper, SEXP diag)
Definition utils-R.c:20
#define FALSE_
Definition utils-R.c:226
SEXP R_any0(SEXP x)
Definition utils-R.c:277
#define DO_INDEX
SEXP Matrix_expand_pointers(SEXP pP)
Definition utils-R.c:509
SEXP Mmatrix(SEXP args)
Definition utils-R.c:325
#define MATRIX_SUITESPARSE_VERSION
Definition version.h:13
#define MATRIX_PACKAGE_VERSION
Definition version.h:5
#define MATRIX_ABI_VERSION
Definition version.h:10