-
Notifications
You must be signed in to change notification settings - Fork 8
VecBasic
Marlin NȺ edited this page Mar 7, 2018
·
2 revisions
Thoughts on VecBasic
implementation:
We need to implement a vector-like object for VecBasic
.
Things to consider:
- Recycle of index when assigning
- Negative index
- Boolean index
- Error when mixing negative subscripts and positive/zero subscripts
Related implementation:
-
Rcpp
has[
operator to mimic R's[
behavior, see http://gallery.rcpp.org/articles/subsetting/. -
[.bigz
ingmp
package
library(gmp)
as.bigz(c(1,2,3,4))[c(TRUE, FALSE)]
# Big Integer ('bigz') object of length 2:
# [1] 1 3
as.bigz(c(1,2,3,4))[c(1, -1)]
# Error in `[.bigz`(as.bigz(c(1, 2, 3, 4)), c(1, -1)) :
# only 0's may mix with negative subscripts
as.bigz(c(1,2,3,4))[c(-1, 1)] # This should be a bug in gmp
# Big Integer ('bigz') object of length 4:
# [1] 1 2 3 4
-
S4Vectors::normalizeSingleBracketSubscript
and its friends
S4Vectors::normalizeSingleBracketSubscript(c(-1, -2), LETTERS[1:10])
# [1] 3 4 5 6 7 8 9 10
Avoid duplication when possible.