pub struct Matrix2 {
pub m11: f64,
pub m12: f64,
pub m21: f64,
pub m22: f64,
}Expand description
A 2×2 matrix stored in row-major order.
Fields§
§m11: f64Row 1, column 1.
m12: f64Row 1, column 2.
m21: f64Row 2, column 1.
m22: f64Row 2, column 2.
Implementations§
Source§impl Matrix2
impl Matrix2
Sourcepub const fn new(m11: f64, m12: f64, m21: f64, m22: f64) -> Self
pub const fn new(m11: f64, m12: f64, m21: f64, m22: f64) -> Self
Creates a 2×2 matrix from row-major entries.
Sourcepub const fn determinant(self) -> f64
pub const fn determinant(self) -> f64
Returns the determinant.
Sourcepub const fn mul_vector(self, vector: Vector2) -> Vector2
pub const fn mul_vector(self, vector: Vector2) -> Vector2
Returns the matrix-vector product.
Sourcepub const fn mul_matrix(self, rhs: Self) -> Self
pub const fn mul_matrix(self, rhs: Self) -> Self
Returns the matrix-matrix product.
Sourcepub fn solve(self, rhs: Vector2) -> Result<Vector2, LinearError>
pub fn solve(self, rhs: Vector2) -> Result<Vector2, LinearError>
Solves self * x = rhs for x.
§Errors
Returns LinearError::SingularMatrix when the determinant is zero.
Trait Implementations§
impl Copy for Matrix2
impl StructuralPartialEq for Matrix2
Auto Trait Implementations§
impl Freeze for Matrix2
impl RefUnwindSafe for Matrix2
impl Send for Matrix2
impl Sync for Matrix2
impl Unpin for Matrix2
impl UnsafeUnpin for Matrix2
impl UnwindSafe for Matrix2
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more