#[cfg(feature = "mem_dbg")]
use alloc::{string::String, vec::Vec};
use core::fmt::Debug;
use super::MutabilityError;
use crate::traits::SquareMatrix;
mod lower_bounded_sparse_row;
mod matrix;
mod sparse_matrix;
#[cfg_attr(feature = "mem_size", derive(mem_dbg::MemSize))]
#[cfg_attr(feature = "mem_size", mem_size(rec))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemDbg))]
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct LowerBoundedSquareMatrix<M: SquareMatrix> {
matrix: M,
index: M::Index,
}
impl<M: SquareMatrix + Debug> Debug for LowerBoundedSquareMatrix<M> {
#[inline]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("LowerBoundedSquareMatrix")
.field("matrix", &self.matrix)
.field("index", &self.index)
.finish()
}
}
impl<M: SquareMatrix> LowerBoundedSquareMatrix<M> {
#[inline]
pub fn new(matrix: M, index: M::Index) -> Result<Self, MutabilityError<M>> {
if index >= matrix.order() {
return Err(MutabilityError::OutOfBounds(
(index, index),
(matrix.order(), matrix.order()),
"The provided index is larger than the number of rows/columns of the matrix.",
));
}
Ok(Self { matrix, index })
}
}