8 int m = INTEGER(dim)[0], n = INTEGER(dim)[1];
9 int_fast64_t mn = (int_fast64_t) m * n;
11 ans = Rf_allocVector(INTSXP, 1);
12 INTEGER(ans)[0] = (int) mn;
14 int_fast64_t mn_ = (int_fast64_t) (
double) mn;
16 mn_ = (int_fast64_t) nextafter((
double) mn, 0.0);
17 ans = Rf_allocVector(REALSXP, 1);
18 REAL(ans)[0] = (double) mn_;
22 PROTECT(off = Rf_allocVector(REALSXP, 1));
23 REAL(off)[0] = (double) (mn - mn_);
26 Rf_warning(
_(
"true length %llu truncated to %llu"),
49 const char *nrn, *ncn;
53 !(((rn = VECTOR_ELT(dn, 0)) != R_NilValue &&
54 (cn = VECTOR_ELT(dn, 1)) != R_NilValue &&
56 ((n = LENGTH(rn)) != LENGTH(cn) ||
58 (((ndn = Rf_getAttrib(dn, R_NamesSymbol)) != R_NilValue &&
59 *(nrn = CHAR(STRING_ELT(ndn, 0))) !=
'\0' &&
60 *(ncn = CHAR(STRING_ELT(ndn, 1))) !=
'\0' &&
61 strcmp(nrn, ncn) != 0)));
69void symDN(SEXP dest, SEXP src,
int J )
71 J = (J < 0) ? -1 : (J != 0);
74 if ((s = VECTOR_ELT(src, J = 1)) != R_NilValue ||
75 (s = VECTOR_ELT(src, J = 0)) != R_NilValue) {
76 SET_VECTOR_ELT(dest, 0, s);
77 SET_VECTOR_ELT(dest, 1, s);
81 if ((s = VECTOR_ELT(src, J)) != R_NilValue) {
82 SET_VECTOR_ELT(dest, 0, s);
83 SET_VECTOR_ELT(dest, 1, s);
86 PROTECT(s = Rf_getAttrib(src, R_NamesSymbol));
87 if (s != R_NilValue) {
88 SEXP destnms = PROTECT(Rf_allocVector(STRSXP, 2));
89 if (CHAR(s = STRING_ELT(s, J))[0] !=
'\0') {
90 SET_STRING_ELT(destnms, 0, s);
91 SET_STRING_ELT(destnms, 1, s);
93 Rf_setAttrib(dest, R_NamesSymbol, destnms);
110void cpyDN(SEXP dest, SEXP src,
int J )
114 if ((s = VECTOR_ELT(src, 0)) != R_NilValue)
115 SET_VECTOR_ELT(dest, J, s);
116 if ((s = VECTOR_ELT(src, 1)) != R_NilValue)
117 SET_VECTOR_ELT(dest, !J, s);
118 PROTECT(s = Rf_getAttrib(src, R_NamesSymbol));
119 if (s != R_NilValue) {
120 SEXP srcnms = s, destnms = PROTECT(Rf_allocVector(STRSXP, 2));
121 if (CHAR(s = STRING_ELT(srcnms, 0))[0] !=
'\0')
122 SET_STRING_ELT(destnms, J, s);
123 if (CHAR(s = STRING_ELT(srcnms, 1))[0] !=
'\0')
124 SET_STRING_ELT(destnms, !J, s);
125 Rf_setAttrib(dest, R_NamesSymbol, destnms);
197 nms = PROTECT(Rf_getAttrib(factors, R_NamesSymbol));
200 SET_VECTOR_ELT(factors, i, val);
204 R_xlen_t n = XLENGTH(factors);
205 SEXP factors1 = PROTECT(Rf_allocVector(VECSXP, n + 1)),
206 nms1 = PROTECT(Rf_allocVector(STRSXP, n + 1));
207 for (i = 0; i < n; ++i) {
208 SET_VECTOR_ELT(factors1, i, VECTOR_ELT(factors, i));
209 if (nms != R_NilValue)
210 SET_STRING_ELT( nms1, i, STRING_ELT( nms, i));
212 SET_VECTOR_ELT(factors1, n, val);
213 SET_STRING_ELT( nms1, n, Rf_mkChar(nm));
214 Rf_setAttrib(factors1, R_NamesSymbol, nms1);
222 if (
TYPEOF(s_nm) != STRSXP || LENGTH(s_nm) < 1 ||
223 (s_nm = STRING_ELT(s_nm, 0)) == NA_STRING)
224 Rf_error(
_(
"invalid factor name"));
227 else if (Rf_asLogical(s_warn))
228 Rf_warning(
_(
"attempt to set factor on %s without '%s' slot"),
229 "Matrix",
"factors");