|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
Block diagonal matrix – stores vector of dense2D blocks. More...
#include <block_diagonal2D.hpp>
Public Types | |
| using | value_type = Value |
| using | size_type = std::size_t |
| using | const_reference = Value |
| using | reference = Value |
Public Member Functions | |
| block_diagonal2D ()=default | |
| block_diagonal2D (std::vector< dense2D< Value > > blocks) | |
| Construct from a vector of dense blocks. | |
| block_diagonal2D (std::initializer_list< dense2D< Value > > blocks) | |
| Construct from initializer list of dense blocks. | |
| void | add_block (dense2D< Value > block) |
| Add a block to the diagonal. | |
| value_type | operator() (size_type r, size_type c) const |
| Element (r, c). | |
| size_type | num_rows () const |
| size_type | num_cols () const |
| size_type | size () const |
| size_type | num_blocks () const |
| Number of diagonal blocks. | |
| const dense2D< Value > & | block (size_type k) const |
| Access the k-th block. | |
| dense2D< Value > | block (size_type k) |
| Write access to the k-th block's elements: a dense2D over the block's storage, in the block's shape. | |
| void | set_block (size_type k, dense2D< Value > block) |
| Replace the k-th block, of any shape, and update the offsets. | |
Block diagonal matrix – stores vector of dense2D blocks.
Total dimension is sum of block dimensions.
| using mtl::mat::block_diagonal2D< Value >::const_reference = Value |
| using mtl::mat::block_diagonal2D< Value >::reference = Value |
| using mtl::mat::block_diagonal2D< Value >::size_type = std::size_t |
| using mtl::mat::block_diagonal2D< Value >::value_type = Value |
|
default |
|
inlineexplicit |
Construct from a vector of dense blocks.
|
inline |
Construct from initializer list of dense blocks.
|
inline |
Add a block to the diagonal.
O(1): it appends the new block's offsets, where it recomputed all of them, O(n) per call (#826).
|
inline |
Write access to the k-th block's elements: a dense2D over the block's storage, in the block's shape.
Writing its elements writes the block, and so does assigning to it: bd.block(k) = X copies X into the block (#829). It used to return the block itself, and change_dim on that left the offsets and the total shape stale (#826). The block keeps its shape whatever is done to the returned matrix:
|
inline |
Access the k-th block.
|
inline |
Number of diagonal blocks.
|
inline |
|
inline |
|
inline |
Element (r, c).
The block holding row r is found by binary search over the row offsets: O(log blocks), where it scanned every block (#826). A block with no rows holds no element, so the last block starting at or before r is the only candidate.
|
inline |
Replace the k-th block, of any shape, and update the offsets.
|
inline |