tatami_r
R bindings to tatami matrices
Loading...
Searching...
No Matches
sparse_matrix.hpp File Reference

Parse sparse matrices from block processing. More...

#include "utils.hpp"
#include "tatami/tatami.hpp"
#include <type_traits>

Go to the source code of this file.

Functions

template<class Function_ >
void tatami_r::parse_SVT_SparseMatrix (Rcpp::RObject matrix, Function_ fun)
 

Detailed Description

Parse sparse matrices from block processing.

Function Documentation

◆ parse_SVT_SparseMatrix()

template<class Function_ >
void tatami_r::parse_SVT_SparseMatrix ( Rcpp::RObject matrix,
Function_ fun )

Parse the contents of a SVT_SparseMatrix from the DelayedArray package. This accounts for different versions of the class definition, different types of the values, and the presence of lacunar leaf nodes.

Template Parameters
Function_Function to be applied at each leaf node.
Parameters
matrixThe SVT_SparseMatrix object.
funFunction to apply to each leaf node, accepting four arguments:
  1. c, an integer specifying the index of the leaf node, i.e., the column index.
  2. indices, an Rcpp::IntegerVector containing the sorted, zero-based indices of the structural non-zero elements in this node (i.e., column).
  3. all_ones, a boolean indicating whether all values in this node/column are equal to 1.
  4. values, an Rcpp::IntegerVector, Rcpp::LogicalVector or Rcpp::NumericVector containing the values of the structural non-zeros. This should be of the same length as indices. It should be ignored if all_ones = true.
The return value of this function is ignored. Note that fun may not be called for all c - if leaf nodes do not contain any data, they will be skipped.