The R Project SVN R

Rev

Rev 60667 | Rev 61566 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 60667 Rev 60844
Line 224... Line 224...
224
 
224
 
225
    if (nrow < 0 || ncol < 0 || nface < 0)
225
    if (nrow < 0 || ncol < 0 || nface < 0)
226
	error(_("negative extents to 3D array"));
226
	error(_("negative extents to 3D array"));
227
#ifndef LONG_VECTOR_SUPPORT
227
#ifndef LONG_VECTOR_SUPPORT
228
    if ((double)nrow * (double)ncol * (double)nface > INT_MAX)
228
    if ((double)nrow * (double)ncol * (double)nface > INT_MAX)
229
	error(_("alloc3Darray: too many elements specified"));
229
	error(_("'alloc3Darray': too many elements specified"));
230
#endif
230
#endif
231
    n = ((R_xlen_t) nrow) * ncol * nface;
231
    n = ((R_xlen_t) nrow) * ncol * nface;
232
    PROTECT(s = allocVector(mode, n));
232
    PROTECT(s = allocVector(mode, n));
233
    PROTECT(t = allocVector(INTSXP, 3));
233
    PROTECT(t = allocVector(INTSXP, 3));
234
    INTEGER(t)[0] = nrow;
234
    INTEGER(t)[0] = nrow;
Line 249... Line 249...
249
 
249
 
250
    for (i = 0; i < LENGTH(dims); i++) {
250
    for (i = 0; i < LENGTH(dims); i++) {
251
	dn *= INTEGER(dims)[i];
251
	dn *= INTEGER(dims)[i];
252
#ifndef LONG_VECTOR_SUPPORT
252
#ifndef LONG_VECTOR_SUPPORT
253
	if(dn > INT_MAX)
253
	if(dn > INT_MAX)
254
	    error(_("allocArray: too many elements specified by 'dims'"));
254
	    error(_("'allocArray': too many elements specified by 'dims'"));
255
#endif
255
#endif
256
	n *= INTEGER(dims)[i];
256
	n *= INTEGER(dims)[i];
257
    }
257
    }
258
 
258
 
259
    PROTECT(dims = duplicate(dims));
259
    PROTECT(dims = duplicate(dims));
Line 433... Line 433...
433
 
433
 
434
    checkArity(op, args);
434
    checkArity(op, args);
435
    /* This is the dimensions vector */
435
    /* This is the dimensions vector */
436
    x = CAR(args);
436
    x = CAR(args);
437
    if (!isInteger(x) || LENGTH(x) != 2)
437
    if (!isInteger(x) || LENGTH(x) != 2)
438
	error(_("a matrix-like object is required as argument to 'row/col'"));
438
	error(_("a matrix-like object is required as argument to '%s'"),
-
 
439
	      (PRIMVAL(op) == 2) ? "col" : "row");
439
 
440
 
440
    nr = INTEGER(x)[0];
441
    nr = INTEGER(x)[0];
441
    nc = INTEGER(x)[1];
442
    nc = INTEGER(x)[1];
442
 
443
 
443
    ans = allocMatrix(INTSXP, nr, nc);
444
    ans = allocMatrix(INTSXP, nr, nc);
Line 1102... Line 1103...
1102
	    const char *this = translateChar(STRING_ELT(perm, i));
1103
	    const char *this = translateChar(STRING_ELT(perm, i));
1103
	    for (j = 0; j < n; j++)
1104
	    for (j = 0; j < n; j++)
1104
		if (streql(translateChar(STRING_ELT(dnna, j)),
1105
		if (streql(translateChar(STRING_ELT(dnna, j)),
1105
			   this)) {pp[i] = j; break;}
1106
			   this)) {pp[i] = j; break;}
1106
	    if (j >= n)
1107
	    if (j >= n)
1107
		error(_("perm[%d] does not match a dimension name"), i+1);
1108
		error(_("'perm[%d]' does not match a dimension name"), i+1);
1108
	}
1109
	}
1109
    } else {
1110
    } else {
1110
	PROTECT(perm = coerceVector(perm, INTSXP));
1111
	PROTECT(perm = coerceVector(perm, INTSXP));
1111
	if (LENGTH(perm) == n) {
1112
	if (LENGTH(perm) == n) {
1112
	    for (i = 0; i < n; i++) pp[i] = INTEGER(perm)[i] - 1;
1113
	    for (i = 0; i < n; i++) pp[i] = INTEGER(perm)[i] - 1;