tatami_r
R bindings to tatami matrices
Loading...
Searching...
No Matches
tatami_r Namespace Reference

tatami bindings for arbitrary R matrices. More...

Classes

class  UnknownMatrix
 Unknown matrix-like object in R. More...
 
struct  UnknownMatrixOptions
 Options for data extraction from an UnknownMatrix. More...
 

Functions

manticore::Executorexecutor ()
 
template<class Function_ , class Index_ >
void parallelize (Function_ fun, Index_ ntasks, int nthreads)
 
template<class Function_ >
void parse_SVT_SparseMatrix (Rcpp::RObject matrix, Function_ fun)
 

Detailed Description

tatami bindings for arbitrary R matrices.

Function Documentation

◆ executor()

manticore::Executor & tatami_r::executor ( )
inline

Retrieve a global manticore::Executor object for all tatami_r uses. This function is only available if TATAMI_R_PARALLELIZE_UNKNOWN is defined.

Returns
Reference to a global manticore::Executor.

◆ parallelize()

template<class Function_ , class Index_ >
void tatami_r::parallelize ( Function_ fun,
Index_ ntasks,
int nthreads )
Template Parameters
Function_Function to be executed.
Index_Integer type for the task indices.
Parameters
funFunction to run in each thread. This is a lambda that should accept three arguments:
  • Integer containing the thread ID.
  • Integer specifying the index of the first task to be executed in a thread.
  • Integer specifying the number of tasks to be executed in a thread.
ntasksNumber of tasks to be executed.
nthreadsNumber of threads to parallelize over.

This function is a drop-in replacement for tatami::parallelize(). The series of integers from [0, ntasks) is split into nthreads contiguous ranges. Each range is used as input to a call to fun within a thread created by the standard <thread> library. Serialization can be achieved via <mutex> in most cases, or manticore::Executor::run() if the task must be performed on the main thread (see executor()).

This function is only available if TATAMI_R_PARALLELIZE_UNKNOWN is defined.

◆ 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.