Convert a matrix to a vector of arrays

matrix_to_tuples(x)

tuples_to_matrix(x)

Arguments

x

object to be converted

Details

Most of the R functions exposed by kdtools can operate natively on a data.frame, matrix or an arrayvec object. An arrayvec object is a pointer to a native C++ vector of arrays and will be the fastest option. Only doubles are supported by arrayvec. Use this function to convert your data before processing for optimal speed.

Examples

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