The R Project SVN R

Rev

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

Rev 47460 Rev 49592
Line 20... Line 20...
20
 *
20
 *
21
 * EXPORTS:
21
 * EXPORTS:
22
 *
22
 *
23
 *  OneIndex()        -- used for "[[<-" in ./subassign.c
23
 *  OneIndex()        -- used for "[[<-" in ./subassign.c
24
 *  get1index()       -- used for "[["   in ./subassign.c & subset.c
24
 *  get1index()       -- used for "[["   in ./subassign.c & subset.c
-
 
25
 *  vectorIndex()     -- used for "[[" with a vector arg
25
 
26
 
26
 *  mat2indsub()      -- for "mat[i]"     "    "            "
27
 *  mat2indsub()      -- for "mat[i]"     "    "            "
27
 
28
 
28
 *  makeSubscript()   -- for "[" and "[<-" in ./subset.c and ./subassign.c
29
 *  makeSubscript()   -- for "[" and "[<-" in ./subset.c and ./subassign.c,
-
 
30
 *			 and "[[<-" with a scalar in ./subassign.c
29
 *  vectorSubscript() -- for makeSubscript()   {currently unused externally}
31
 *  vectorSubscript() -- for makeSubscript()   {currently unused externally}
30
 *  arraySubscript()  -- for "[i,j,..." and "[<-..." in ./subset.c, ./subassign.c
32
 *  arraySubscript()  -- for "[i,j,..." and "[<-..." in ./subset.c, ./subassign.c
31
 */
33
 */
32
 
34
 
33
#ifdef HAVE_CONFIG_H
35
#ifdef HAVE_CONFIG_H
Line 242... Line 244...
242
		      type2char(TYPEOF(s)));
244
		      type2char(TYPEOF(s)));
243
    }
245
    }
244
    return indx;
246
    return indx;
245
}
247
}
246
 
248
 
-
 
249
SEXP attribute_hidden vectorIndex(SEXP x, SEXP thesub, int start, int stop, int pok, SEXP call) 
-
 
250
{
-
 
251
    int i, len = length(thesub), offset;
-
 
252
 
-
 
253
    for(i = start; i < stop; i++) {
-
 
254
	if(!isVectorList(x) && !isPairList(x))
-
 
255
	    errorcall(call, _("recursive indexing failed at level %d\n"), i+1);
-
 
256
	offset = get1index(thesub, getAttrib(x, R_NamesSymbol),
-
 
257
		           length(x), pok, i, call);
-
 
258
	if(offset < 0 || offset >= length(x))
-
 
259
	    errorcall(call, _("no such index at level %d\n"), i+1);
-
 
260
	if(isPairList(x)) {
-
 
261
	    x = CAR(nthcdr(x, offset));
-
 
262
	} else {
-
 
263
	    x = VECTOR_ELT(x, offset);
-
 
264
    	}
-
 
265
    }
-
 
266
    return x;
-
 
267
}
-
 
268
 
247
/* Special Matrix Subscripting: Handles the case x[i] where */
269
/* Special Matrix Subscripting: Handles the case x[i] where */
248
/* x is an n-way array and i is a matrix with n columns. */
270
/* x is an n-way array and i is a matrix with n columns. */
249
/* This code returns a vector containing the integer subscripts */
271
/* This code returns a vector containing the integer subscripts */
250
/* to be extracted when x is regarded as unravelled. */
272
/* to be extracted when x is regarded as unravelled. */
251
/* Negative indices are not allowed. */
273
/* Negative indices are not allowed. */