tatami_stats
Matrix statistics for tatami
Loading...
Searching...
No Matches
tatami_stats::counts Namespace Reference

Functions for computing dimension-wise counts. More...

Namespaces

namespace  nan
 Functions for counting NaNs on each dimension.
 
namespace  zero
 Functions for counting zeros on each dimension.
 

Functions

template<typename Value_ , typename Index_ , typename Output_ , class Condition_ >
void apply (bool row, const tatami::Matrix< Value_, Index_ > &mat, Output_ *output, int num_threads, Condition_ condition)
 

Detailed Description

Functions for computing dimension-wise counts.

Function Documentation

◆ apply()

template<typename Value_ , typename Index_ , typename Output_ , class Condition_ >
void tatami_stats::counts::apply ( bool row,
const tatami::Matrix< Value_, Index_ > & mat,
Output_ * output,
int num_threads,
Condition_ condition )

Count the number of values that satisfy the condition in each element of a chosen dimension.

Template Parameters
Value_Numeric type of the matrix value.
Index_Integer type of the row/column indices.
Output_Numeric type of the output count. To avoid overflow, we recommend using a type that is large enough to hold the dimension extents of mat.
Condition_Function that accepts a single Value_ and returns a bool.
Parameters
rowWhether to perform the count within each row. If false, the count is performed within each column instead.
matInstance of a tatami::Matrix.
[out]outputPointer to an array of length equal to the number of rows (if row = true) or columns (otherwise). On output, this will contain the row/column variances.
num_threadsNumber of threads to use, for parallelization via tatami::parallelize().
conditionFunction to indicate whether a value should be counted. This function is also responsible for handling any NaNs that might be present in p.