1pub mod matrix2x2;
2pub mod matrix3x3;
3pub mod matrix4x4;
4
5use crate::vector::{Vector, VectorError};
10
11pub enum MatrixError {
12 ZeroDeterminantError,
13 NonSquareMatrixError,
14}
15
16impl std::fmt::Debug for MatrixError {
17 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
18 write!(f, "{:?}", self)
19 }
20}
21
22pub trait Matrix {
23 type Data;
25
26 fn new() -> Self;
27 fn from(value: Self::Data) -> Self;
28 fn from_slice(values: &[Self::Data]) -> Self;
29 fn scale(&self, scale: Self::Data) -> Self;
30 fn determinant(&self) -> Result<Self::Data, MatrixError>;
31 fn transpose(&self) -> Self;
32 fn cofactor(&self) -> Result<Self, MatrixError>
33 where
34 Self: Sized;
35 fn adjugate(&self) -> Result<Self, MatrixError>
36 where
37 Self: Sized;
38 fn inverse(&self) -> Result<Self, MatrixError>
39 where
40 Self: Sized;
41}
42
43pub trait TransformVector<T: Vector> {
44 fn transform_vector(&self, _other: T) -> Result<T, VectorError> {
45 Err(crate::vector::VectorError::NonExistingTransformError)
46 }
47}