jlview_sparse: Create a zero-copy R sparse matrix view of a Julia...

View source: R/sparse.R

jlview_sparseR Documentation

Create a zero-copy R sparse matrix view of a Julia SparseMatrixCSC

Description

Creates a dgCMatrix-class backed by a zero-copy ALTREP vector for the nonzero values (x slot). The row indices (i slot) and column pointers (p slot) are copied and shifted from 1-based (Julia) to 0-based (R) indexing in Julia, then returned as plain R integer vectors.

Usage

jlview_sparse(julia_sparse_matrix, lazy_indices = FALSE)

Arguments

julia_sparse_matrix

A JuliaObject referencing a Julia SparseMatrixCSC. The value type must be supported for zero-copy (Float64, Float32, Int32, Int64, Int16, UInt8).

lazy_indices

Ignored. Retained for API compatibility only. Previously controlled lazy vs eager materialization of ALTREP index vectors, which have been removed in favor of simple copy+shift in Julia.

Value

A dgCMatrix-class sparse matrix.

Examples

## Not run: 
JuliaCall::julia_setup()
JuliaCall::julia_command("using SparseArrays")
m <- JuliaCall::julia_eval("sprand(Float64, 100, 50, 0.1)")
s <- jlview_sparse(m)
class(s) # "dgCMatrix"

## End(Not run)

jlview documentation built on March 24, 2026, 1:07 a.m.