147 const size_t j)
const noexcept
155 <<
"DynMatrix: row index " << i <<
" out of range [0, " <<
n <<
")";
157 <<
"DynMatrix: column index " << j <<
" out of range [0, " <<
m <<
")";
185 array_ptr->set_default_initial_value(value);
232 const size_t N =
n *
m;
270 <<
"DynMatrix dimensions must be > 0";
323 mat.array_ptr =
nullptr;
324 mat.default_value =
T();
343 if (
n != mat.
n ||
m != mat.
m)
372 mat.array_ptr =
nullptr;
373 mat.default_value =
T();
388 if (
n != mat.
n ||
m != mat.
m)
391 const size_t N =
n *
m;
392 for (
size_t i = 0; i <
N; ++i)
406 return !(*
this == mat);
486 T &
write(
const size_t i,
const size_t j,
const T & data)
493 T &
write(
const size_t i,
const size_t j,
T && data)
565 for (
size_t idx = 0; idx <
n *
m; ++idx)
580 for (
size_t i = 0; i <
n; ++i)
581 for (
size_t j = 0; j <
m; ++j)
585 result.
write(j, i, val);
641 <<
"DynMatrix::Iterator: no current element";
656 <<
"DynMatrix::Iterator: no more elements";
698 template <
class Operation>
701 for (
size_t i = 0; i <
n *
m; ++i)
708 template <
class Operation>
715 template <
class Operation>
722 template <
class Operation>
743 template <
class Operation>
750 for (
size_t idx = 0; idx <
total; ++idx)
761 template <
class Operation>
768 for (
size_t idx = 0; idx <
total; ++idx)
Exception handling system with formatted messages for Aleph-w.
#define ah_overflow_error_unless(C)
Throws std::overflow_error if condition does NOT hold.
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
DRY (Don't Repeat Yourself) utilities and macros.
static void compute_sizes(const size_t n, size_t &d, size_t &s, size_t &b) noexcept
Given a dimension n, it proposes values for the directory, segment and block sizes.
Iterator for traversing matrix elements.
Iterator(const DynMatrix< T > &mat) noexcept
Construct an iterator for a matrix.
size_t get_row() const noexcept
Get the current row index.
const T & get_curr() const
Get the current element.
const T & get_curr_ne() const noexcept
Get the current element without bounds checking.
const DynMatrix * mat_ptr
void next_ne() noexcept
Advance to the next element without bounds checking.
bool has_curr() const noexcept
Check if iterator has a current element.
size_t get_col() const noexcept
Get the current column index.
void next()
Advance to the next element.
void reset() noexcept
Reset iterator to the beginning.
Dynamic matrix with sparse storage.
bool traverse_allocated(Operation &&operation)
Traverse entries in allocated memory blocks.
T & write(const size_t i, const size_t j, T &&data)
void set_dimension(const size_t num_rows, const size_t num_cols)
Change the matrix dimensions.
bool operator==(const DynMatrix< T > &mat) const
Equality comparison.
DynMatrix() noexcept=default
Default constructor - creates an invalid matrix.
T & write_array_entry(const size_t i, const T &data)
DynArray< T > * array_ptr
DynMatrix(DynMatrix< T > &&mat) noexcept
Move constructor.
T & operator()(const size_t i, const size_t j)
Subscript operator for allocated entries.
bool operator!=(const DynMatrix< T > &mat) const
Inequality comparison.
const T & read(const size_t i, const size_t j) const
Read the entry at position (i, j).
bool traverse(Operation &operation) const
Traverse all elements in row-major order.
constexpr bool is_empty() const noexcept
Check if the matrix is empty (uninitialized).
constexpr size_t cols() const noexcept
Get the number of columns.
Iterator get_it() const
Get an iterator positioned at the first element.
void swap(DynMatrix &mat) noexcept
Swap the contents of this matrix with another.
DynMatrix(const DynMatrix< T > &mat)
Copy constructor.
T & write(const size_t i, const size_t j, const T &data)
Write a value to position (i, j).
void check_indices(const size_t i, const size_t j) const
void allocate()
Pre-allocate memory for the entire matrix.
bool traverse(Operation &operation)
bool traverse_allocated(Operation &&operation) const
const T & get_default_value() const noexcept
Get the default value for unwritten entries.
constexpr size_t rows() const noexcept
Get the number of rows.
void set_default_initial_value(const T &value)
Set the default value for unwritten entries.
const T & read_ne(const size_t i, const size_t j) const noexcept
Read entry without bounds checking.
constexpr size_t size() const noexcept
Get the total number of entries.
bool traverse(Operation &&operation)
T Key_Type
Alias for Item_Type, required by functional mixins.
constexpr bool is_square() const noexcept
Check if the matrix is square.
T & access(const size_t i, const size_t j)
Direct access to an allocated entry.
DynMatrix(const size_t num_rows, const size_t num_cols, const T &zero=T())
Construct a matrix with specified dimensions.
DynMatrix< T > transpose() const
Create a transposed copy of the matrix.
DynMatrix< T > & operator=(const DynMatrix< T > &mat)
Copy assignment operator.
T Item_Type
The type of elements stored in the matrix.
void fill(const T &value)
Fill all entries with a value.
const T & read_array_entry(const size_t i) const noexcept
size_t m
Number of columns.
T & write_array_entry(const size_t i, T &&data)
bool traverse(Operation &&operation) const
constexpr size_t get_index(const size_t i, const size_t j) const noexcept
const T & access(const size_t i, const size_t j) const
Direct const access to an allocated entry.
Common methods to the Aleph-w ( ) containers.
Aleph::DynList< __T > maps(Operation &op) const
Map the elements of the container.
Common sequential searching methods on containers.
Main namespace for Aleph-w library functions.
std::decay_t< typename HeadC::Item_Type > T
Lazy and scalable dynamic array implementation.