|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Dynamic matrix with sparse storage. More...
#include <tpl_dynMat.H>
Classes | |
| class | Iterator |
| Iterator for traversing matrix elements. More... | |
Public Types | |
| using | Set_Type = DynMatrix< T > |
| The container type (self-reference for generic programming). | |
| using | Item_Type = T |
| The type of elements stored in the matrix. | |
| using | Key_Type = T |
| Alias for Item_Type, required by functional mixins. | |
Public Member Functions | |
| void | set_default_initial_value (const T &value) |
| Set the default value for unwritten entries. | |
| const T & | get_default_value () const noexcept |
| Get the default value for unwritten entries. | |
| void | swap (DynMatrix &mat) noexcept |
| Swap the contents of this matrix with another. | |
| void | set_dimension (const size_t num_rows, const size_t num_cols) |
| Change the matrix dimensions. | |
| void | allocate () |
| Pre-allocate memory for the entire matrix. | |
| DynMatrix (const size_t num_rows, const size_t num_cols, const T &zero=T()) | |
| Construct a matrix with specified dimensions. | |
| DynMatrix () noexcept=default | |
| Default constructor - creates an invalid matrix. | |
| ~DynMatrix () | |
| Destructor - releases all allocated memory. | |
| DynMatrix (const DynMatrix< T > &mat) | |
| Copy constructor. | |
| DynMatrix (DynMatrix< T > &&mat) noexcept | |
| Move constructor. | |
| DynMatrix< T > & | operator= (const DynMatrix< T > &mat) |
| Copy assignment operator. | |
| DynMatrix< T > & | operator= (DynMatrix< T > &&mat) noexcept |
| Move assignment operator. | |
| bool | operator== (const DynMatrix< T > &mat) const |
| Equality comparison. | |
| bool | operator!= (const DynMatrix< T > &mat) const |
| Inequality comparison. | |
| constexpr size_t | rows () const noexcept |
| Get the number of rows. | |
| constexpr size_t | cols () const noexcept |
| Get the number of columns. | |
| constexpr size_t | size () const noexcept |
| Get the total number of entries. | |
| constexpr bool | is_square () const noexcept |
| Check if the matrix is square. | |
| constexpr bool | is_empty () const noexcept |
| Check if the matrix is empty (uninitialized). | |
| const T & | read (const size_t i, const size_t j) const |
| Read the entry at position (i, j). | |
| const T & | read_ne (const size_t i, const size_t j) const noexcept |
| Read entry without bounds checking. | |
| T & | write (const size_t i, const size_t j, const T &data) |
| Write a value to position (i, j). | |
| T & | write (const size_t i, const size_t j, T &&data) |
| T & | access (const size_t i, const size_t j) |
| Direct access to an allocated entry. | |
| const T & | access (const size_t i, const size_t j) const |
| Direct const access to an allocated entry. | |
| T & | operator() (const size_t i, const size_t j) |
| Subscript operator for allocated entries. | |
| const T & | operator() (const size_t i, const size_t j) const |
| Const subscript operator for allocated entries. | |
| void | fill (const T &value) |
| Fill all entries with a value. | |
| DynMatrix< T > | transpose () const |
| Create a transposed copy of the matrix. | |
| Iterator | get_it () const |
| Get an iterator positioned at the first element. | |
| template<class Operation > | |
| bool | traverse (Operation &operation) const |
| Traverse all elements in row-major order. | |
| template<class Operation > | |
| bool | traverse (Operation &operation) |
| template<class Operation > | |
| bool | traverse (Operation &&operation) const |
| template<class Operation > | |
| bool | traverse (Operation &&operation) |
| template<class Operation > | |
| bool | traverse_allocated (Operation &&operation) |
| Traverse entries in allocated memory blocks. | |
| template<class Operation > | |
| bool | traverse_allocated (Operation &&operation) const |
Public Member Functions inherited from LocateFunctions< DynMatrix< T >, T > | |
| auto | get_it () const |
| Return a properly initialized iterator positioned at the first item on the container. | |
| auto | get_it (const size_t pos) const |
Return a properly initialized iterator positioned at the pos item on the container. | |
| auto | get_itor () const |
Alias of get_it(). | |
| T & | nth_ne (const size_t n) noexcept |
| Return the n‑th element without bounds checking. | |
| const T & | nth_ne (const size_t n) const noexcept |
Const overload of nth_ne(size_t). | |
| T & | nth (const size_t n) |
| Return the n-th item of container. | |
| const T & | nth (const size_t n) const |
Const overload of nth(size_t). | |
| T * | find_ptr (Operation &operation) noexcept(operation_is_noexcept< Operation >()) |
| Find a pointer to an item in the container according to a searching criteria. | |
| const T * | find_ptr (Operation &operation) const noexcept(operation_is_noexcept< Operation >()) |
Const overload of find_ptr(Operation&). | |
| const T * | find_ptr (Operation &&operation) const noexcept(operation_is_noexcept< Operation >()) |
Overload of find_ptr(Operation&) const that accepts rvalues. | |
| T * | find_ptr (Operation &&operation) noexcept(operation_is_noexcept< Operation >()) |
Overload of find_ptr(Operation&) that accepts rvalues. | |
| size_t | find_index (Operation &operation) const noexcept(operation_is_noexcept< Operation >()) |
| Find the position of an item in the container according to a searching criteria. | |
| size_t | find_index (Operation &&operation) const noexcept(operation_is_noexcept< Operation >()) |
Overload of find_index(Operation&) that accepts rvalues. | |
| std::tuple< bool, T > | find_item (Operation &operation) noexcept(operation_is_noexcept< Operation >()) |
| Safe sequential searching of an item matching a criteria. | |
| std::tuple< bool, T > | find_item (Operation &operation) const noexcept(operation_is_noexcept< Operation >()) |
| std::tuple< bool, T > | find_item (Operation &&operation) noexcept(operation_is_noexcept< Operation >()) |
| std::tuple< bool, T > | find_item (Operation &&operation) const noexcept(operation_is_noexcept< Operation >()) |
Public Member Functions inherited from FunctionalMethods< DynMatrix< T >, T > | |
| void | emplace (Args &&... args) |
| Appends a new element into the container by constructing it in-place with the given args. | |
| void | emplace_end (Args &&... args) |
| void | emplace_ins (Args &&... args) |
| Insert a new element into the container by constructing it in-place with the given args. | |
| size_t | ninsert (Args ... args) |
| Insert n variadic items. | |
| size_t | nappend (Args ... args) |
| Append n variadic items. | |
| void | for_each (Operation &operation) |
| Traverse all the container and performs an operation on each element. | |
| void | for_each (Operation &operation) const |
Const overload of for_each(Operation&). | |
| void | for_each (Operation &&operation) const |
Overload of for_each(Operation&) const that accepts rvalues. | |
| void | for_each (Operation &&operation) |
Overload of for_each(Operation&) that accepts rvalues. | |
| void | each (Operation &operation) |
Alias of for_each(Operation&). | |
| void | each (Operation &operation) const |
Const alias of for_each(Operation&). | |
| void | each (Operation &&operation) const |
Const alias of for_each(Operation&) that accepts rvalues. | |
| void | each (Operation &&operation) |
Alias of for_each(Operation&) that accepts rvalues. | |
| void | each (size_t pos, const size_t slice, Operation &operation) const |
Traverse the container starting at pos taking one item every slice, performing a mutable operation on each visited element. | |
| void | each (const size_t pos, const size_t slice, Operation &&operation) const |
| void | mutable_for_each (Operation &operation) |
| void | mutable_for_each (Operation &&operation) |
| bool | all (Operation &operation) const |
| Check if all the elements of container satisfy a condition. | |
| bool | all (Operation &&operation) const |
Overload of all(Operation&) that accepts rvalues. | |
| bool | exists (Operation &op) const |
| Test for existence in the container of an element satisfying a criteria. | |
| bool | exists (Operation &&op) const |
Overload of exists(Operation&) that accepts rvalues. | |
| Aleph::DynList< __T > | maps (Operation &op) const |
| Map the elements of the container. | |
| Aleph::DynList< __T > | maps (Operation &&op) const |
Overload of maps(Operation&) that accepts rvalues. | |
| Aleph::DynList< __T > | maps_if (Prop prop, Operation &op) const |
| Conditional mapping of the elements of the container. | |
| Aleph::DynList< __T > | maps_if (Prop prop, Operation &&op) const |
Overload of maps_if(Prop, Operation&) that accepts rvalues. | |
| Aleph::DynList< T > | to_dynlist () const |
| Convert container to DynList. | |
| std::vector< T > | to_vector () const |
| Convert container to std::vector. | |
| __T | foldl (const __T &init, Op &op) const |
| Fold the elements of the container to a specific result. | |
| __T | foldl (const __T &init, Op &&op=Op()) const |
Overload of foldl(const __T&, Op&) that accepts rvalues. | |
| __T | fold_left (const __T &init, Op &op) const |
| Alias for foldl with the same accumulator type. | |
| __T | fold_left (const __T &init, Op &&op=Op()) const |
Overload of fold_left(const __T&, Op&) that accepts rvalues. | |
| T | fold (const T &init, Operation &operation) const |
| Simplified version of foldl() where the folded type is the same type of elements stored in the container. | |
| T | fold (const T &init, Operation &&operation) const |
Overload of fold(const T&, Operation&) that accepts rvalues. | |
| Aleph::DynList< T > | filter (Operation &operation) const |
| Filter the elements of a container according to a matching criteria. | |
| Aleph::DynList< T > | filter (Operation &&operation) const |
Overload of filter(Operation&) that accepts rvalues. | |
| Aleph::DynList< const T * > | ptr_filter (Operation &operation) const |
| Filter the elements of a container according to a matching criteria and return a pointer to the matched items in the container. | |
| Aleph::DynList< const T * > | ptr_filter (Operation &&operation) const |
Overload of ptr_filter(Operation&) that accepts rvalues. | |
| Aleph::DynList< std::tuple< T, size_t > > | pfilter (Operation &operation) const |
| Filter the elements of a container according to a matching criteria and determine its positions respect to the traversal of container. | |
| Aleph::DynList< std::tuple< T, size_t > > | pfilter (Operation &&operation) const |
Overload of pfilter(Operation&) that accepts rvalues. | |
| std::pair< Aleph::DynList< T >, Aleph::DynList< T > > | partition (Operation &op) const |
| Exclusive partition of container according to a filter criteria. | |
| std::pair< Aleph::DynList< T >, Aleph::DynList< T > > | partition (Operation &&op) const |
Overload of partition(Operation&) that accepts rvalues. | |
| std::pair< Aleph::DynList< T >, Aleph::DynList< T > > | partition (size_t n) const |
| Exclusive partition of container in the nth item. | |
| std::pair< Aleph::DynList< T >, Aleph::DynList< T > > | split_half () const |
| Split the container into two halves by alternating elements. | |
| std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > | tpartition (Operation &op) const |
| Exclusive partition of container according to a filter criteria. | |
| std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > | tpartition (Operation &&op) const |
Overload of tpartition(Operation&) that accepts rvalues. | |
| size_t | length () const noexcept |
| Count the number of elements of a container. | |
| Aleph::DynList< T > | rev () const |
| Return a list with the elements of container in reverse order respect to its traversal order. | |
| Aleph::DynList< T > | take (const size_t n) const |
| Return a list with the first n elements seen in the container during its traversal. | |
| Aleph::DynList< T > | take (size_t i, const size_t j, const size_t step=1) const |
| Return a list with elements seen in the container between i and j position respect to its traversal. | |
| Aleph::DynList< T > | drop (const size_t n) const |
| Drop the first n elements seen in the container during its traversal. | |
| void | mutable_drop (const size_t n) |
| Drop the first n elements seen from container. | |
Private Member Functions | |
| const T & | read_array_entry (const size_t i) const noexcept |
| T & | write_array_entry (const size_t i, const T &data) |
| T & | write_array_entry (const size_t i, T &&data) |
| constexpr size_t | get_index (const size_t i, const size_t j) const noexcept |
| void | check_indices (const size_t i, const size_t j) const |
Private Attributes | |
| size_t | n = 0 |
| Number of rows. | |
| size_t | m = 0 |
| Number of columns. | |
| DynArray< T > * | array_ptr = nullptr |
| T | default_value = T() |
Additional Inherited Members | |
Related Symbols inherited from FunctionalMethods< DynMatrix< T >, T > | |
| each | |
| each | |
| each | |
Dynamic matrix with sparse storage.
DynMatrix<T> implements a two-dimensional matrix of generic type T with dynamic, sparse storage. Only entries that are explicitly written consume memory; unwritten entries return the default "zero" value.
The matrix uses a DynArray<T> internally, which provides:
This class is not thread-safe. External synchronization is required for concurrent access from multiple threads.
| T | Type of elements stored in the matrix. Must be default-constructible. |
Definition at line 117 of file tpl_dynMat.H.
The type of elements stored in the matrix.
Definition at line 166 of file tpl_dynMat.H.
Alias for Item_Type, required by functional mixins.
Definition at line 169 of file tpl_dynMat.H.
The container type (self-reference for generic programming).
Definition at line 163 of file tpl_dynMat.H.
|
inline |
Construct a matrix with specified dimensions.
Creates a matrix with num_rows rows and num_cols columns. All entries are initialized to zero (default: T()).
| [in] | num_rows | Number of rows (must be > 0). |
| [in] | num_cols | Number of columns (must be > 0). |
| [in] | zero | Default value for unwritten entries. |
| std::bad_alloc | If memory allocation fails. |
| std::invalid_argument | If num_rows or num_cols is zero. |
Definition at line 266 of file tpl_dynMat.H.
References ah_invalid_argument_if, Aleph::DynMatrix< T >::m, FunctionalMethods< DynMatrix< T >, T >::maps(), Aleph::DynMatrix< T >::n, and Aleph::DynMatrix< T >::set_dimension().
|
defaultnoexcept |
Default constructor - creates an invalid matrix.
Creates a matrix with zero dimensions. The matrix must be initialized with set_dimension() before use.
|
inline |
Destructor - releases all allocated memory.
Definition at line 286 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr.
|
inline |
Copy constructor.
Creates a deep copy of mat.
| [in] | mat | The matrix to copy. |
| std::bad_alloc | If memory allocation fails. |
Definition at line 299 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, Aleph::DynMatrix< T >::m, Aleph::DynMatrix< T >::n, and Aleph::DynMatrix< T >::set_dimension().
|
inlinenoexcept |
Move constructor.
Transfers ownership of resources from mat to this matrix. After this operation, mat is left in a valid but unspecified state.
| [in,out] | mat | The matrix to move from. |
Definition at line 316 of file tpl_dynMat.H.
Direct access to an allocated entry.
Returns a reference to the entry at position (i, j). The entry must have been previously written or the matrix must have been allocated with allocate().
Time complexity: O(1).
| [in] | i | Row index (0-based). |
| [in] | j | Column index (0-based). |
Definition at line 514 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, and Aleph::DynMatrix< T >::get_index().
Referenced by Aleph::DynMatrix< T >::operator()(), Aleph::DynMatrix< T >::operator()(), and Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::print().
Direct const access to an allocated entry.
| [in] | i | Row index. |
| [in] | j | Column index. |
Definition at line 525 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, and Aleph::DynMatrix< T >::get_index().
|
inline |
Pre-allocate memory for the entire matrix.
Allocates memory for all n*m entries, allowing O(1) access via operator() without triggering additional allocations.
| std::bad_alloc | If there is not enough memory. |
Definition at line 249 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, Aleph::DynMatrix< T >::m, and Aleph::DynMatrix< T >::n.
Referenced by Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Floyd_All_Shortest_Paths(), Aleph::DynMatrix< T >::fill(), TEST(), and TEST().
Definition at line 152 of file tpl_dynMat.H.
References ah_out_of_range_error_if, Aleph::DynMatrix< T >::m, and Aleph::DynMatrix< T >::n.
Referenced by Aleph::DynMatrix< T >::read(), Aleph::DynMatrix< T >::write(), and Aleph::DynMatrix< T >::write().
|
inlineconstexprnoexcept |
Get the number of columns.
Definition at line 419 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::m.
Fill all entries with a value.
Sets all entries to value. This allocates memory for all entries.
| [in] | value | The value to fill with. |
| std::bad_alloc | If memory allocation fails. |
Definition at line 562 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::allocate(), Aleph::DynMatrix< T >::array_ptr, Aleph::DynMatrix< T >::m, and Aleph::DynMatrix< T >::n.
Referenced by TEST().
Get the default value for unwritten entries.
Definition at line 192 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::default_value.
Referenced by TEST().
|
inlineconstexprprivatenoexcept |
Definition at line 146 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::m.
Referenced by Aleph::DynMatrix< T >::access(), Aleph::DynMatrix< T >::access(), Aleph::DynMatrix< T >::read(), Aleph::DynMatrix< T >::read_ne(), Aleph::DynMatrix< T >::transpose(), Aleph::DynMatrix< T >::write(), and Aleph::DynMatrix< T >::write().
|
inline |
Get an iterator positioned at the first element.
Definition at line 687 of file tpl_dynMat.H.
|
inlineconstexprnoexcept |
Check if the matrix is empty (uninitialized).
Definition at line 437 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::m, and Aleph::DynMatrix< T >::n.
|
inlineconstexprnoexcept |
Check if the matrix is square.
Definition at line 431 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::m, and Aleph::DynMatrix< T >::n.
|
inline |
Inequality comparison.
| [in] | mat | The matrix to compare with. |
Definition at line 404 of file tpl_dynMat.H.
|
inline |
Subscript operator for allocated entries.
Equivalent to access(i, j).
| [in] | i | Row index. |
| [in] | j | Column index. |
Definition at line 538 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::access().
|
inline |
Const subscript operator for allocated entries.
| [in] | i | Row index. |
| [in] | j | Column index. |
Definition at line 549 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::access().
|
inline |
Copy assignment operator.
Replaces the contents of this matrix with a copy of mat.
| [in] | mat | The matrix to copy. |
| std::bad_alloc | If memory allocation fails. |
Definition at line 336 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, Aleph::DynMatrix< T >::default_value, Aleph::DynMatrix< T >::m, Aleph::DynMatrix< T >::n, and Aleph::DynMatrix< T >::set_dimension().
|
inlinenoexcept |
Move assignment operator.
Transfers ownership of resources from mat to this matrix.
| [in,out] | mat | The matrix to move from. |
Definition at line 359 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, Aleph::DynMatrix< T >::default_value, Aleph::DynMatrix< T >::m, and Aleph::DynMatrix< T >::n.
|
inline |
Equality comparison.
Returns true if this matrix has the same dimensions as mat and all corresponding entries are equal (using T::operator==).
| [in] | mat | The matrix to compare with. |
Definition at line 386 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::m, N, Aleph::DynMatrix< T >::n, and Aleph::DynMatrix< T >::read_array_entry().
Read the entry at position (i, j).
Returns the value at row i and column j. If the entry has not been written, returns the default value.
Time complexity: O(1) amortized.
| [in] | i | Row index (0-based). |
| [in] | j | Column index (0-based). |
Definition at line 452 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::check_indices(), Aleph::DynMatrix< T >::get_index(), and Aleph::DynMatrix< T >::read_array_entry().
Referenced by main(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
Definition at line 128 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, and Aleph::DynMatrix< T >::default_value.
Referenced by Aleph::DynMatrix< T >::Iterator::get_curr_ne(), Aleph::DynMatrix< T >::operator==(), Aleph::DynMatrix< T >::read(), Aleph::DynMatrix< T >::read_ne(), Aleph::DynMatrix< T >::transpose(), and Aleph::DynMatrix< T >::traverse().
Read entry without bounds checking.
| [in] | i | Row index. |
| [in] | j | Column index. |
Definition at line 466 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::get_index(), and Aleph::DynMatrix< T >::read_array_entry().
|
inlineconstexprnoexcept |
Get the number of rows.
Definition at line 413 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::n.
Referenced by Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::print(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Set the default value for unwritten entries.
Changes the value returned for entries that have not been explicitly written. This also affects new entries created by touch().
| [in] | value | The new default value. |
Definition at line 181 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, and Aleph::DynMatrix< T >::default_value.
Referenced by TEST().
Change the matrix dimensions.
Resizes the matrix to have num_rows rows and num_cols columns. All existing data is discarded.
| [in] | num_rows | The new number of rows. |
| [in] | num_cols | The new number of columns. |
| std::bad_alloc | If memory allocation fails. |
Definition at line 225 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, Aleph::DynArray< T >::compute_sizes(), Aleph::DynMatrix< T >::default_value, Aleph::DynMatrix< T >::m, FunctionalMethods< DynMatrix< T >, T >::maps(), N, and Aleph::DynMatrix< T >::n.
Referenced by Aleph::DynMatrix< T >::DynMatrix(), Aleph::DynMatrix< T >::DynMatrix(), and Aleph::DynMatrix< T >::operator=().
|
inlineconstexprnoexcept |
Get the total number of entries.
Definition at line 425 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::m, and Aleph::DynMatrix< T >::n.
Referenced by Aleph::DynMatrix< T >::Iterator::has_curr(), TEST(), TEST(), and TEST().
Swap the contents of this matrix with another.
Exchanges the contents of this matrix with those of mat in constant time O(1). No elements are copied or moved individually.
| [in,out] | mat | The matrix to swap with. |
Definition at line 204 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, Aleph::DynMatrix< T >::default_value, Aleph::DynMatrix< T >::m, and Aleph::DynMatrix< T >::n.
Create a transposed copy of the matrix.
Returns a new matrix where entry (i,j) contains this->read(j,i).
| std::bad_alloc | If memory allocation fails. |
Definition at line 577 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::default_value, Aleph::DynMatrix< T >::get_index(), Aleph::DynMatrix< T >::m, Aleph::DynMatrix< T >::n, Aleph::DynMatrix< T >::read_array_entry(), and Aleph::DynMatrix< T >::write().
Referenced by TEST().
|
inline |
Definition at line 723 of file tpl_dynMat.H.
References FunctionalMethods< DynMatrix< T >, T >::maps().
|
inline |
Definition at line 716 of file tpl_dynMat.H.
References FunctionalMethods< DynMatrix< T >, T >::maps().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 709 of file tpl_dynMat.H.
References FunctionalMethods< DynMatrix< T >, T >::maps(), and Aleph::DynMatrix< T >::traverse().
|
inline |
Traverse all elements in row-major order.
Executes operation on each element. The traversal stops early if operation returns false.
| Operation | A callable with signature bool(const T&). |
| [in] | operation | The operation to perform. |
Definition at line 699 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::m, FunctionalMethods< DynMatrix< T >, T >::maps(), Aleph::DynMatrix< T >::n, and Aleph::DynMatrix< T >::read_array_entry().
Referenced by Aleph::DynMatrix< T >::traverse().
|
inline |
Traverse entries in allocated memory blocks.
Visits all entries within allocated memory blocks. This is more efficient than traverse() when the matrix is very sparse, but note that it visits all entries in each allocated block, not just those that were explicitly written.
| Operation | A callable with signature bool(T&). |
| [in] | operation | The operation to perform. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 744 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, Aleph::DynMatrix< T >::m, FunctionalMethods< DynMatrix< T >, T >::maps(), and Aleph::DynMatrix< T >::n.
|
inline |
Definition at line 762 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, Aleph::DynMatrix< T >::m, FunctionalMethods< DynMatrix< T >, T >::maps(), and Aleph::DynMatrix< T >::n.
Write a value to position (i, j).
Sets the value at row i and column j. Allocates memory for the entry if not already allocated.
Time complexity: O(1) amortized.
| [in] | i | Row index (0-based). |
| [in] | j | Column index (0-based). |
| [in] | data | The value to write. |
| std::out_of_range | If i >= rows() or j >= cols(). |
| std::bad_alloc | If memory allocation fails. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 486 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::check_indices(), Aleph::DynMatrix< T >::get_index(), and Aleph::DynMatrix< T >::write_array_entry().
Referenced by FilledMatrix::FilledMatrix(), SquareMatrix::SquareMatrix(), main(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and Aleph::DynMatrix< T >::transpose().
Definition at line 493 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::check_indices(), Aleph::DynMatrix< T >::get_index(), and Aleph::DynMatrix< T >::write_array_entry().
Definition at line 134 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, and FunctionalMethods< DynMatrix< T >, T >::maps().
Referenced by Aleph::DynMatrix< T >::write(), and Aleph::DynMatrix< T >::write().
Definition at line 140 of file tpl_dynMat.H.
References Aleph::DynMatrix< T >::array_ptr, and FunctionalMethods< DynMatrix< T >, T >::maps().
Definition at line 124 of file tpl_dynMat.H.
Referenced by Aleph::DynMatrix< T >::DynMatrix(), Aleph::DynMatrix< T >::~DynMatrix(), Aleph::DynMatrix< T >::access(), Aleph::DynMatrix< T >::access(), Aleph::DynMatrix< T >::allocate(), Aleph::DynMatrix< T >::fill(), Aleph::DynMatrix< T >::operator=(), Aleph::DynMatrix< T >::operator=(), Aleph::DynMatrix< T >::read_array_entry(), Aleph::DynMatrix< T >::set_default_initial_value(), Aleph::DynMatrix< T >::set_dimension(), Aleph::DynMatrix< T >::swap(), Aleph::DynMatrix< T >::traverse_allocated(), Aleph::DynMatrix< T >::traverse_allocated(), Aleph::DynMatrix< T >::write_array_entry(), and Aleph::DynMatrix< T >::write_array_entry().
Definition at line 126 of file tpl_dynMat.H.
Referenced by Aleph::DynMatrix< T >::get_default_value(), Aleph::DynMatrix< T >::operator=(), Aleph::DynMatrix< T >::operator=(), Aleph::DynMatrix< T >::read_array_entry(), Aleph::DynMatrix< T >::set_default_initial_value(), Aleph::DynMatrix< T >::set_dimension(), Aleph::DynMatrix< T >::swap(), and Aleph::DynMatrix< T >::transpose().
|
private |
Number of columns.
Definition at line 122 of file tpl_dynMat.H.
Referenced by Aleph::DynMatrix< T >::DynMatrix(), Aleph::DynMatrix< T >::DynMatrix(), Aleph::DynMatrix< T >::allocate(), Aleph::DynMatrix< T >::check_indices(), Aleph::DynMatrix< T >::cols(), Aleph::DynMatrix< T >::fill(), Aleph::DynMatrix< T >::Iterator::get_col(), Aleph::DynMatrix< T >::get_index(), Aleph::DynMatrix< T >::Iterator::get_row(), Aleph::DynMatrix< T >::is_empty(), Aleph::DynMatrix< T >::is_square(), Aleph::DynMatrix< T >::operator=(), Aleph::DynMatrix< T >::operator=(), Aleph::DynMatrix< T >::operator==(), Aleph::DynMatrix< T >::set_dimension(), Aleph::DynMatrix< T >::size(), Aleph::DynMatrix< T >::swap(), Aleph::DynMatrix< T >::transpose(), Aleph::DynMatrix< T >::traverse(), Aleph::DynMatrix< T >::traverse_allocated(), and Aleph::DynMatrix< T >::traverse_allocated().
|
private |
Number of rows.
Definition at line 121 of file tpl_dynMat.H.
Referenced by Aleph::DynMatrix< T >::DynMatrix(), Aleph::DynMatrix< T >::DynMatrix(), Aleph::DynMatrix< T >::allocate(), Aleph::DynMatrix< T >::check_indices(), Aleph::DynMatrix< T >::fill(), Aleph::DynMatrix< T >::is_empty(), Aleph::DynMatrix< T >::is_square(), Aleph::DynMatrix< T >::operator=(), Aleph::DynMatrix< T >::operator=(), Aleph::DynMatrix< T >::operator==(), Aleph::DynMatrix< T >::rows(), Aleph::DynMatrix< T >::set_dimension(), Aleph::DynMatrix< T >::size(), Aleph::DynMatrix< T >::swap(), Aleph::DynMatrix< T >::transpose(), Aleph::DynMatrix< T >::traverse(), Aleph::DynMatrix< T >::traverse_allocated(), and Aleph::DynMatrix< T >::traverse_allocated().