tatami_stats
Matrix statistics for tatami
|
Functions for computing dimension-wise grouped sums. More...
Classes | |
struct | Options |
Grouped summation options. More... | |
Functions | |
template<typename Value_ , typename Index_ , typename Group_ , typename Output_ > | |
void | apply (bool row, const tatami::Matrix< Value_, Index_ > *p, const Group_ *group, size_t num_groups, Output_ **output, const Options &sopt) |
template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ > | |
std::vector< std::vector< Output_ > > | by_row (const tatami::Matrix< Value_, Index_ > *p, const Group_ *group, const Options &sopt) |
template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ > | |
std::vector< std::vector< Output_ > > | by_row (const tatami::Matrix< Value_, Index_ > *p, const Group_ *group) |
template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ > | |
std::vector< std::vector< Output_ > > | by_column (const tatami::Matrix< Value_, Index_ > *p, const Group_ *group, const Options &sopt) |
template<typename Output_ = double, typename Value_ , typename Index_ , typename Group_ > | |
std::vector< std::vector< Output_ > > | by_column (const tatami::Matrix< Value_, Index_ > *p, const Group_ *group) |
Functions for computing dimension-wise grouped sums.
void tatami_stats::grouped_sums::apply | ( | bool | row, |
const tatami::Matrix< Value_, Index_ > * | p, | ||
const Group_ * | group, | ||
size_t | num_groups, | ||
Output_ ** | output, | ||
const Options & | sopt | ||
) |
Compute per-group sums for each element of a chosen dimension of a tatami::Matrix
.
Value_ | Type of the matrix value, should be numeric. |
Index_ | Type of the row/column indices. |
Group_ | Type of the group assignments for each column. |
Output_ | Type of the output value. This should be floating-point to store potential averages. |
row | Whether to compute group-wise sums within each row. If false, sums are computed within the column instead. | |
p | Pointer to a tatami::Matrix . | |
[in] | group | Pointer to an array of length equal to the number of columns (if row = true ) or rows (otherwise). Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups. |
num_groups | Number of groups, i.e., \(N\). This can be determined by calling tatami_stats::total_groups() on group . | |
[out] | output | Pointer to an array of pointers of length equal to the number of groups. Each inner pointer should reference an array of length equal to the number of rows (if row = true ) or columns (otherwise). On output, this will contain the row/column sums for each group (indexed according to the assignment in group ). |
sopt | Summation options. |
std::vector< std::vector< Output_ > > tatami_stats::grouped_sums::by_row | ( | const tatami::Matrix< Value_, Index_ > * | p, |
const Group_ * | group, | ||
const Options & | sopt | ||
) |
Wrapper around apply()
for row-wise grouped sums.
Output_ | Type of the output. |
Value_ | Type of the matrix value. |
Index_ | Type of the row/column indices. |
Group_ | Type of the group assignments for each row. |
p | Pointer to a tatami::Matrix . | |
[in] | group | Pointer to an array of length equal to the number of columns. Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups. |
sopt | Summation options. |
std::vector< std::vector< Output_ > > tatami_stats::grouped_sums::by_row | ( | const tatami::Matrix< Value_, Index_ > * | p, |
const Group_ * | group | ||
) |
Overload with default options.
Output_ | Type of the output. |
Value_ | Type of the matrix value. |
Index_ | Type of the row/column indices. |
Group_ | Type of the group assignments for each column. |
p | Pointer to a tatami::Matrix . | |
[in] | group | Pointer to an array of length equal to the number of columns. Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups. |
std::vector< std::vector< Output_ > > tatami_stats::grouped_sums::by_column | ( | const tatami::Matrix< Value_, Index_ > * | p, |
const Group_ * | group, | ||
const Options & | sopt | ||
) |
Wrapper around apply()
for column-wise grouped sums.
Output_ | Type of the output. |
Value_ | Type of the matrix value. |
Index_ | Type of the column/column indices. |
Group_ | Type of the group assignments for each column. |
p | Pointer to a tatami::Matrix . | |
[in] | group | Pointer to an array of length equal to the number of rows. Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups. |
sopt | Summation options. |
std::vector< std::vector< Output_ > > tatami_stats::grouped_sums::by_column | ( | const tatami::Matrix< Value_, Index_ > * | p, |
const Group_ * | group | ||
) |
Overload with default options.
Output_ | Type of the output. |
Value_ | Type of the matrix value. |
Index_ | Type of the column/column indices. |
Group_ | Type of the group assignments for each column. |
p | Pointer to a tatami::Matrix . | |
[in] | group | Pointer to an array of length equal to the number of rows. Each value should be an integer that specifies the group assignment. Values should lie in \([0, N)\) where \(N\) is the number of unique groups. |