tatami_stats
Matrix statistics for tatami
|
Functions for computing dimension-wise sums. More...
Classes | |
struct | Options |
Summation options. More... | |
class | RunningDense |
Running sums from dense data. More... | |
class | RunningSparse |
Running sums from sparse data. More... | |
Functions | |
template<typename Output_ = double, typename Value_ , typename Index_ > | |
Output_ | direct (const Value_ *ptr, Index_ num, bool skip_nan) |
template<typename Value_ , typename Index_ , typename Output_ > | |
void | apply (bool row, const tatami::Matrix< Value_, Index_ > *p, Output_ *output, const Options &sopt) |
template<typename Output_ = double, typename Value_ , typename Index_ > | |
std::vector< Output_ > | by_column (const tatami::Matrix< Value_, Index_ > *p, const Options &sopt) |
template<typename Output_ = double, typename Value_ , typename Index_ > | |
std::vector< Output_ > | by_column (const tatami::Matrix< Value_, Index_ > *p) |
template<typename Output_ = double, typename Value_ , typename Index_ > | |
std::vector< Output_ > | by_row (const tatami::Matrix< Value_, Index_ > *p, const Options &sopt) |
template<typename Output_ = double, typename Value_ , typename Index_ > | |
std::vector< Output_ > | by_row (const tatami::Matrix< Value_, Index_ > *p) |
Functions for computing dimension-wise sums.
Output_ tatami_stats::sums::direct | ( | const Value_ * | ptr, |
Index_ | num, | ||
bool | skip_nan | ||
) |
Compute the sum across an objective vector using naive accumulation. This is best used with a sufficiently high-precision Output_
, hence the default of double
.
Output_ | Type of the output data. |
Value_ | Type of the input data. |
Index_ | Type of the row/column index. |
[in] | ptr | Pointer to an array of length num , containing the values of the objective vector. |
num | Size of the array at ptr . This may be less than the length of the objective vector for sparse data. | |
skip_nan | See Options::skip_nan . |
void tatami_stats::sums::apply | ( | bool | row, |
const tatami::Matrix< Value_, Index_ > * | p, | ||
Output_ * | output, | ||
const Options & | sopt | ||
) |
Compute sums for each element of a chosen dimension of a tatami::Matrix
. This is done using direct()
, RunningDense
or RunningSparse
, depending on the requested dimension in row
and the preferred dimension for access in p
. Note that all sums are obtained using naive accumulation, so it is best to use a sufficiently high-precision Output_
to mitigate round-off errors.
Value_ | Type of the matrix value, should be numeric. |
Index_ | Type of the row/column indices. |
Output_ | Type of the output value. |
row | Whether to compute the sum for each row. If false, the sum is computed for each column instead. | |
p | Pointer to a tatami::Matrix . | |
[out] | output | Pointer 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. |
sopt | Summation options. |
std::vector< Output_ > tatami_stats::sums::by_column | ( | const tatami::Matrix< Value_, Index_ > * | p, |
const Options & | sopt | ||
) |
Wrapper around apply()
for column sums.
Value_ | Type of the matrix value, should be summable. |
Index_ | Type of the row/column indices. |
Output_ | Type of the output value. |
p | Pointer to a tatami::Matrix . |
sopt | Summation options. |
std::vector< Output_ > tatami_stats::sums::by_column | ( | const tatami::Matrix< Value_, Index_ > * | p | ) |
Overload with default options.
Value_ | Type of the matrix value, should be summable. |
Index_ | Type of the row/column indices. |
Output_ | Type of the output value. |
p | Pointer to a tatami::Matrix . |
std::vector< Output_ > tatami_stats::sums::by_row | ( | const tatami::Matrix< Value_, Index_ > * | p, |
const Options & | sopt | ||
) |
Wrapper around apply()
for row sums.
Output_ | Type of the output value. |
Value_ | Type of the matrix value, should be summable. |
Index_ | Type of the row/column indices. |
p | Pointer to a tatami::Matrix . |
sopt | Summation options. |
std::vector< Output_ > tatami_stats::sums::by_row | ( | const tatami::Matrix< Value_, Index_ > * | p | ) |
Overload with default options.
Output_ | Type of the output value. |
Value_ | Type of the matrix value, should be summable. |
Index_ | Type of the row/column indices. |
p | Pointer to a tatami::Matrix . |