Skip to content

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.

How to normalize index?

Things to consider:

  1. Recycle of index when assigning
  2. Negative index
  3. Boolean index
  4. Error when mixing negative subscripts and positive/zero subscripts

Related implementation:

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

Use MAYBE_SHARED in C code of [<- and [[<-?

Avoid duplication when possible.