tensorr
provides methods to manipulate and store sparse tensors. Tensors are multi-dimensional generalizations of matrices (two dimensional) and vectors (one dimensional).
It has three main goals:
The development version of tensorr is available on github.
devtools::install_github("zamorarr/tensorr")
See the introduction vignette for a comprehensive overview. To create a sparse tensor you have to provide the non-zero values, subscripts to the non-zero values, and the overall dimensions of the tensor.
library(tensorr)
subs <- list(c(1,1,1), c(1,1,2))
vals <- c(10, 20)
dims <- c(2,2,2)
x <- sptensor(subs, vals, dims)
x
#> <A 2x2x2 sparse tensor with 2 non-zero entries>
#> subs: <1,1,1> <1,1,2>
#> vals: 10 20
Many of the dense and sparse implementation ideas were adpated from:
For a review on tensors, see: