mem_matrix: Memory-Mapped Matrix Object

View source: R/utils.R

mem_matrixR Documentation

Memory-Mapped Matrix Object

Description

S3 object wrapping an external pointer to a Cpp MemoryMappedMatrix.

Usage

mem_matrix(filename, rows, cols, mode = "readwrite")

Arguments

filename

Path to binary mmap file

rows

Number of rows

cols

Number of columns

mode

Access mode: 'readonly' or 'readwrite' (default). Code that writes into the matrix needs 'readwrite': a selector that standardizes the design in place and restores it (scaling_mode "L2" or "ZSCORE"), a T-solver with normalize or intercept on, TRexSPCASelector and the in-place scalers. Code that only reads accepts 'readonly' as well: a selector under scaling_mode = "NONE", a T-solver with normalize and intercept off, and the fits that say so.

Details

A file serves one writer at a time. Do not run several selectors or T-solvers that standardize the file in place on one file at the same time, neither through a second handle in one session nor in several processes. Each would change the data the other works on, and the results come out wrong. To use one design in several processes at once, pre-normalize it with trex_normalize_design, open the file in 'readonly' mode and run every selector with scaling_mode = "NONE".

Value

Object of classes MemoryMappedMatrix and mmap_matrix (S3 XPtr wrapper)

References

F. Scheidt, J. Machkour, and M. Muma, "Solving FDR-Controlled Sparse Regression Problems with Five Million Variables on a Laptop," in Proc. IEEE 9th Int. Workshop Comput. Adv. Multi-Sensor Adapt. Process. (CAMSAP), 2023, pp. 116-120.

See Also

Other memory-mapped matrices: [.mmap_matrix(), as.matrix.mmap_matrix(), dim.mmap_matrix(), mem_matrix_from(), print.mmap_matrix()

Examples


mat <- matrix(as.double(1:20), nrow = 4, ncol = 5)
f <- tempfile(fileext = ".bin")
on.exit(unlink(f), add = TRUE)
mem_matrix_from(mat, f)
mm <- mem_matrix(f, rows = 4, cols = 5)



TRexSelector documentation built on Nov. 20, 2026, 5:09 p.m.