The R Project SVN R

Rev

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

Rev 33598 Rev 34864
Line 1... Line 1...
1
/*
1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
3
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
4
 *  Copyright (C) 1998-2001   The R Development Core Team
4
 *  Copyright (C) 1998-2001   The R Development Core Team
5
 *  Copyright (C) 2002--2004  The R Foundation
5
 *  Copyright (C) 2002--2005  The R Foundation
6
 *
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  (at your option) any later version.
10
 *  (at your option) any later version.
Line 193... Line 193...
193
 
193
 
194
    dn = n = 1;
194
    dn = n = 1;
195
    for (i = 0; i < LENGTH(dims); i++) {
195
    for (i = 0; i < LENGTH(dims); i++) {
196
	dn *= INTEGER(dims)[i];
196
	dn *= INTEGER(dims)[i];
197
	if(dn > INT_MAX)
197
	if(dn > INT_MAX)
198
	    error(_("allocArray: too many elements specified by dims"));
198
	    error(_("allocArray: too many elements specified by 'dims'"));
199
	n *= INTEGER(dims)[i];
199
	n *= INTEGER(dims)[i];
200
    }
200
    }
201
 
201
 
202
    PROTECT(dims = duplicate(dims));
202
    PROTECT(dims = duplicate(dims));
203
    PROTECT(array = allocVector(mode, n));
203
    PROTECT(array = allocVector(mode, n));
Line 1022... Line 1022...
1022
    checkArity(op, args);
1022
    checkArity(op, args);
1023
    x = CAR(args); args = CDR(args);
1023
    x = CAR(args); args = CDR(args);
1024
    n = asInteger(CAR(args)); args = CDR(args);
1024
    n = asInteger(CAR(args)); args = CDR(args);
1025
    p = asInteger(CAR(args)); args = CDR(args);
1025
    p = asInteger(CAR(args)); args = CDR(args);
1026
    NaRm = asLogical(CAR(args));
1026
    NaRm = asLogical(CAR(args));
1027
    if (n == NA_INTEGER || n <= 0)
1027
    if (n == NA_INTEGER || n < 0)
1028
	errorcall(call, _("invalid value of 'n'"));
1028
	errorcall(call, _("invalid value of 'n'"));
1029
    if (p == NA_INTEGER || p <= 0)
1029
    if (p == NA_INTEGER || p < 0)
1030
	errorcall(call, _("invalid value of 'p'"));
1030
	errorcall(call, _("invalid value of 'p'"));
1031
    if (NaRm == NA_LOGICAL) errorcall(call, _("invalid value of 'na.rm'"));
1031
    if (NaRm == NA_LOGICAL) errorcall(call, _("invalid value of 'na.rm'"));
1032
    keepNA = !NaRm;
1032
    keepNA = !NaRm;
1033
 
1033
 
1034
    OP = PRIMVAL(op);
1034
    OP = PRIMVAL(op);