kuwisdelu / matter

Out-of-core statistical computing and signal processing
http://www.cardinalmsi.org
54 stars 4 forks source link

Supporting linear indexing #7

Closed PeteHaitch closed 5 years ago

PeteHaitch commented 6 years ago

Would it be possible to support linear indexing of matter objects, as supported by base::array. E.g.,

suppressPackageStartupMessages(library(matter))
z <- matrix(1:10, ncol = 2)
# base: Extracts the 3rd element
z[3]
#> [1] 3
# matter: Extracts the 3rd row
Z <- matter_mat(z)
Z[3]
#> [1] 3 8

z2 <- array(z, dim = c(dim(z), 1))
dim(z2)
#> [1] 5 2 1
# base: Extracts the 3rd element
z2[3]
#> [1] 3
Z2 <- matter_arr(z2)
# matter: errors
Z2[3]
#> Error in Z2[3]: incorrect number of dimensions
kuwisdelu commented 5 years ago

This is now supported in versions >=1.9.6.