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

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

Classes

struct  Options
 Range calculation options. More...
 
class  RunningDense
 Running minima/maxima from dense data. More...
 
class  RunningSparse
 Running minima/maxima from sparse data. More...
 

Functions

template<typename Value_ , typename Index_ >
Value_ direct (const Value_ *ptr, Index_ num, bool minimum, bool skip_nan)
 
template<typename Value_ , typename Index_ >
Value_ direct (const Value_ *value, Index_ num_nonzero, Index_ num_all, bool minimum, bool skip_nan)
 
template<typename Value_ , typename Index_ , typename Output_ >
void apply (bool row, const tatami::Matrix< Value_, Index_ > &mat, Output_ *min_out, Output_ *max_out, const Options &ropt)
 
template<typename Output_ = double, typename Value_ , typename Index_ >
std::pair< std::vector< Output_ >, std::vector< Output_ > > by_column (const tatami::Matrix< Value_, Index_ > &mat, const Options &ropt)
 
template<typename Output_ = double, typename Value_ , typename Index_ >
std::pair< std::vector< Output_ >, std::vector< Output_ > > by_row (const tatami::Matrix< Value_, Index_ > &mat, const Options &ropt)
 

Detailed Description

Functions for computing dimension-wise ranges.

Function Documentation

◆ direct() [1/2]

template<typename Value_ , typename Index_ >
Value_ tatami_stats::ranges::direct ( const Value_ * ptr,
Index_ num,
bool minimum,
bool skip_nan )

Directly compute the minimum or maximum of a dense objective vector.

Template Parameters
Value_Type of the input data.
Index_Type of the row/column indices.
Parameters
[in]ptrPointer to an array of length num, containing the values of the objective vector.
numLength of the objective vector, i.e., length of the array at ptr.
minimumWhether to compute the minimum. If false, the maximum is computed instead.
skip_nanSee Options::skip_nan for details.
Returns
The minimum or maximum value, depending on minimum. If num = 0 or (if skip_nan = true) there are no non-NaN values, a placeholder value is returned instead that is never less than (if minimum true) or greater than (otherwise) any non-NaN value of type Value_.

◆ direct() [2/2]

template<typename Value_ , typename Index_ >
Value_ tatami_stats::ranges::direct ( const Value_ * value,
Index_ num_nonzero,
Index_ num_all,
bool minimum,
bool skip_nan )

Compute the extremes of a sparse objective vector.

Template Parameters
Value_Type of the input data.
Index_Type of the row/column indices.
Parameters
[in]valuePointer to an array of length num_nonzero, containing the values of the structural non-zeros.
num_nonzeroNumber of structural non-zeros in the objective vector.
num_allLength of the objective vector, including the structural zeros not in value. This should be greater than or equal to num_nonzero.
Template Parameters
minimumWhether to compute the minimum. If false, the maximum is computed instead.
Parameters
skip_nanSee Options::skip_nan for details.
Returns
The minimum or maximum value, depending on minimum. If num_all = 0 or (if skip_nan = true) there are no non-NaN values, a placeholder value is returned instead that is never less than (if minimum true) or greater than (otherwise) any non-NaN value of type Value_.

◆ apply()

template<typename Value_ , typename Index_ , typename Output_ >
void tatami_stats::ranges::apply ( bool row,
const tatami::Matrix< Value_, Index_ > & mat,
Output_ * min_out,
Output_ * max_out,
const Options & ropt )

Compute ranges for each element of a chosen dimension of a tatami::Matrix.

Template Parameters
Value_Type of the matrix value, should be numeric.
Index_Type of the row/column indices.
Output_Type of the output value.
Parameters
rowWhether to compute the range for each row. If false, the range is computed for each column instead.
matInstance of a tatami::Matrix.
[out]min_outPointer to an array of length equal to the number of rows (if row = true) or columns (otherwise). On output, this will contain the minimum of each row/column. Alternatively, this may be NULL, in which case the minima are not computed.
[out]max_outPointer to an array of length equal to the number of rows (if row = true) or columns (otherwise). On output, this will contain the maximum of each row/column. Alternatively, this may be NULL, in which case the maxima are not computed.
roptRange calculation options.

◆ by_column()

template<typename Output_ = double, typename Value_ , typename Index_ >
std::pair< std::vector< Output_ >, std::vector< Output_ > > tatami_stats::ranges::by_column ( const tatami::Matrix< Value_, Index_ > & mat,
const Options & ropt )

Wrapper around apply() for column ranges.

Template Parameters
OutputType of the output value.
Value_Type of the matrix value.
Index_Type of the row/column indices.
Parameters
matInstance of a tatami::Matrix.
roptRange calculation options.
Returns
A pair of vectors, each of length equal to the number of columns. The first and second vector contains the minimum and maximum value per column, respectively.

◆ by_row()

template<typename Output_ = double, typename Value_ , typename Index_ >
std::pair< std::vector< Output_ >, std::vector< Output_ > > tatami_stats::ranges::by_row ( const tatami::Matrix< Value_, Index_ > & mat,
const Options & ropt )

Wrapper around apply() for row ranges.

Template Parameters
OutputType of the output value.
Value_Type of the matrix value.
Index_Type of the row/column indices.
Parameters
matInstance of a tatami::Matrix.
roptRange calculation options.
Returns
A pair of vectors, each of length equal to the number of rows. The first and second vector contains the minimum and maximum value per row, respectively.