Convert a matrix to a vector of arrays

matrix_to_tuples(x)

tuples_to_matrix(x)

Arguments

x

object to be converted

Details

The algorithms in kdtools can accept either matrices or an arrayvec object. When a matrix is passed, it is converted to an arrayvec object internally and the results are converted back to a matrix. For optimal performance, pre-convert matrices.

Examples

x = matrix(1:10, 5) y = matrix_to_tuples(x) str(x)
#> int [1:5, 1:2] 1 2 3 4 5 6 7 8 9 10
str(y)
#> List of 3 #> $ xptr: num 1 #> $ nrow: num 2 #> $ ncol: num 3 #> - attr(*, "class")= chr "arrayvec"
y[1:2, ]
#> [,1] [,2] #> [1,] 1 6 #> [2,] 2 7