The R Project SVN R

Rev

Rev 75453 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 75453 Rev 75597
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  Robert Gentleman and Ross Ihaka
3
 *  Copyright (C) 1995  Robert Gentleman and Ross Ihaka
4
 *  Copyright (C) 1997--2014  The R Core Team
4
 *  Copyright (C) 1997--2018  The R Core Team
5
 *  Copyright (C) 2003	      The R Foundation
5
 *  Copyright (C) 2003	      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
Line 2403... Line 2403...
2403
	    }
2403
	    }
2404
	    break;
2404
	    break;
2405
	case REALSXP:
2405
	case REALSXP:
2406
	case SINGLESXP:
2406
	case SINGLESXP:
2407
	    if (copy) {
2407
	    if (copy) {
2408
		s = allocVector(REALSXP, n);
2408
		PROTECT(s = allocVector(REALSXP, n));
2409
		if (type == SINGLESXP || asLogical(getAttrib(arg, CSingSymbol)) == 1) {
2409
		if (type == SINGLESXP || asLogical(getAttrib(arg, CSingSymbol)) == 1) {
2410
		    float *sptr = (float*) p;
2410
		    float *sptr = (float*) p;
2411
		    for(R_xlen_t i = 0 ; i < n ; i++)
2411
		    for(R_xlen_t i = 0 ; i < n ; i++)
2412
			REAL(s)[i] = (double) sptr[i];
2412
			REAL(s)[i] = (double) sptr[i];
2413
		} else {
2413
		} else {
Line 2424... Line 2424...
2424
			if(*--ptr != FILL)
2424
			if(*--ptr != FILL)
2425
			    error("array under-run in %s(\"%s\") in %s argument %d\n",
2425
			    error("array under-run in %s(\"%s\") in %s argument %d\n",
2426
				  Fort ? ".Fortran" : ".C",
2426
				  Fort ? ".Fortran" : ".C",
2427
				  symName, type2char(type), na+1);
2427
				  symName, type2char(type), na+1);
2428
		}
2428
		}
-
 
2429
		UNPROTECT(1); /* s */
2429
	    } else {
2430
	    } else {
2430
		if (type == SINGLESXP || asLogical(getAttrib(arg, CSingSymbol)) == 1) {
2431
		if (type == SINGLESXP || asLogical(getAttrib(arg, CSingSymbol)) == 1) {
2431
		    s = allocVector(REALSXP, n);
2432
		    s = allocVector(REALSXP, n);
2432
		    float *sptr = (float*) p;
2433
		    float *sptr = (float*) p;
2433
		    for(int i = 0 ; i < n ; i++)
2434
		    for(int i = 0 ; i < n ; i++)