|
Template Numerical Library version\ main:4e6e2c1
|
This page provides an overview of all reduction functions available for matrix operations, helping to understand the differences between variants and choose the right function for your needs.
A matrix row reduction performs a reduction operation (like sum, max, min) across the elements within each row of a matrix, producing one result per row. This is a fundamental operation for:
Matrix reduction functions are organized along three independent axes:
| Category | Matrix Modifiable? | Use Case |
|---|---|---|
| Non-const | Yes | Can modify matrix elements during reduction |
| Const | No | Read-only access to matrix elements |
Note: Each reduction function has both const and non-const overloads. The possibility to modify the matrix during reduction allows to fuse reduction with traversing operations into a single pass. This can improve performance by reducing memory accesses.
| Category | Tracks Position? | Use Case |
|---|---|---|
| Basic | No | Only the reduced value is needed (e.g., row sum, row max) |
| WithArgument | Yes | Need value and column position (e.g., max value location) |
| Scope | Rows Processed | Parameters |
|---|---|---|
| All | All rows | No range/array parameters |
| Range | Rows [begin, end) | begin and end indices |
| Array | Specific rows | Array of row indices |
| If | Rows filtered by a condition | Process rows based on row-level properties |
All reduction functions follow this naming pattern: reduce[Scope]Rows[WithArgument][If]
Each function has both const and non-const overloads (×2 multiplier).
| Function | Scope | Conditional | Tracks Position | Overloads |
|---|---|---|---|---|
| reduceAllRows | All | No | No | const & non-const |
| reduceRows (range) | Range [begin,end) | No | No | const & non-const |
| reduceRows (array) | Row array | No | No | const & non-const |
| reduceAllRowsIf | All | Yes | No | const & non-const |
| reduceRowsIf | Range [begin,end) | Yes | No | const & non-const |
| Function | Scope | Conditional | Tracks Position | Overloads |
|---|---|---|---|---|
| reduceAllRowsWithArgument | All | No | Yes | const & non-const |
| reduceRowsWithArgument (range) | Range [begin,end) | No | Yes | const & non-const |
| reduceRowsWithArgument (array) | Row array | No | Yes | const & non-const |
| reduceAllRowsWithArgumentIf | All | Yes | Yes | const & non-const |
| reduceRowsWithArgumentIf | Range [begin,end) | Yes | Yes | const & non-const |
All reduction functions share these common parameters:
Additional parameters:
Matrix type considerations: