9 if (
class[1] ==
'g' &&
class[0] !=
'n')
12 int naToUnitIfPattern = (check) ? 0 : 1;
13 if (
class[0] ==
'n' && !naToUnitIfPattern) {
15 R_xlen_t nx = XLENGTH(x);
16 while (nx-- > 0)
if (*(px++) == NA_LOGICAL)
break;
17 naToUnitIfPattern = nx >= 0;
18 if (
class[1] ==
'g' && !naToUnitIfPattern)
22 int *pdim =
DIM(from), m = pdim[0], n = pdim[1],
23 packed =
class[2] ==
'p', canonical = !naToUnitIfPattern;
24 char ul =
'\0', ct = (
class[1] ==
'p') ?
'C' :
'\0', nu =
'\0';
27 if (
class[1] ==
's' &&
class[0] ==
'z')
34 c##TYPE *px = c##PTR(x); \
35 canonical = (!packed) \
36 ? !c##NAME(test2)(px, (size_t) n, ul, ct, nu) \
37 : !c##NAME(test1)(px, (size_t) n, ul, ct, nu); \
46 SEXP y = PROTECT(Rf_allocVector(
TYPEOF(x), XLENGTH(x)));
49 c##TYPE *px = c##PTR(x), *py = c##PTR(y); \
50 if (class[1] == 'g') \
51 memcpy(py, px, sizeof(c##TYPE) * (size_t) m * (size_t) n); \
53 c##NAME(force2)(py, px, (size_t) n, ul, ct, nu); \
55 c##NAME(force1)(py, px, (size_t) n, ul, ct, nu); \
59 if (
class[0] ==
'n' && naToUnitIfPattern) {
61 R_xlen_t ny = XLENGTH(y);
62 while (ny-- > 0) { *py = *py != 0; ++py; }
67 if (
class[1] !=
'g' && ul !=
'U')
69 if (
class[1] ==
's' && ct !=
'C' &&
class[0] ==
'z')
88 if (
class[0] ==
'z' &&
TRANS(from) ==
'C') {
90 Rcomplex *px = COMPLEX(x);
91 int n =
DIM(from)[1], canonical = (check) ? 1 : 0;
93 if (
class[2] !=
'T') {
97 int *pp = INTEGER(p) + 1, *pi = INTEGER(i), j, k_, k, kend,
98 up = (
class[2] ==
'C') == (ul ==
'U');
103 if (k < kend && pi[k_ = (up) ? kend - 1 : k] == j &&
104 (ISNAN(px[k_].i) || px[k_].i != 0.0))
112 Rcomplex *py = COMPLEX(y);
115 if (k < kend && pi[k_ = (up) ? kend - 1 : k] == j)
132 int *pi = INTEGER(i), *pj = INTEGER(j);
133 R_xlen_t k = 0, kend = XLENGTH(i);
135 for (; k < kend; ++k)
136 if (pi[k] == pj[k] &&
137 (ISNAN(px[k].i) || px[k].i != 0.0))
139 canonical = k == kend;
143 Rcomplex *py = COMPLEX(y);
144 for (; k < kend; ++k)
164 if (
DIAG(from) !=
'N') {
167 SEXP value = R_NilValue;
170 value = Rf_allocVector(c##TYPESXP, 1); \
171 c##PTR(value)[0] = c##UNIT; \
181 Rf_error(
"should never happen ...");
#define SWITCH5(c, template)
#define SWITCH4(c, template)
const char * valid_dense[]
#define SET_DIMNAMES(x, mode, value)
SEXP duplicateVector(SEXP)
const char * Matrix_class(SEXP, const char **, int, const char *)
#define DIMNAMES(x, mode)
#define GET_SLOT(x, name)
SEXP newObject(const char *)
#define COPY_SLOT(dest, src, name)
const char * valid_sparse[]
#define SET_SLOT(x, name, value)
#define VALID_LOGIC2(s, d)
SEXP sparse_diag_set(SEXP from, const char *class, SEXP value)
SEXP R_sparse_force_canonical(SEXP s_from, SEXP s_check)
SEXP dense_force_canonical(SEXP from, const char *class, int check)
SEXP sparse_force_canonical(SEXP from, const char *class, int check)
SEXP R_dense_force_canonical(SEXP s_from, SEXP s_check)