Stage 2 end-to-end check of the FFI bridge: extract @p, @i, @x from a dgCMatrix, ship them to Rust, reconstruct a faer SparseColMat through the dgcmatrix-faer-bridge crate, and return the row sums computed by walking the reconstructed sparse matrix.

sparse_row_sums(A)

Arguments

A

a sparse matrix coercible to Matrix::dgCMatrix.

Value

Numeric vector of length nrow(A).

Details

The result must agree with Matrix::rowSums() for every valid input; this is the basis of the Stage 2 unit tests.

See also

Examples

if (FALSE) { # \dontrun{
  A <- Matrix::sparseMatrix(
    i = c(1, 2, 3, 1, 4),
    j = c(1, 2, 3, 4, 4),
    x = c(2, 3, 4, 5, 6),
    dims = c(4, 4)
  )
  sparse_row_sums(A)        # via Rust bridge
  Matrix::rowSums(A)        # reference
} # }