pub trait MatrixOperations {
Show 13 methods
// Required methods
fn matrix_add(&self, other: &Expression) -> Expression;
fn matrix_subtract(&self, other: &Expression) -> Expression;
fn matrix_multiply(&self, other: &Expression) -> Expression;
fn matrix_scalar_multiply(&self, scalar: &Expression) -> Expression;
fn matrix_determinant(&self) -> Expression;
fn matrix_transpose(&self) -> Expression;
fn matrix_inverse(&self) -> Expression;
fn matrix_trace(&self) -> Expression;
fn matrix_power(&self, exponent: &Expression) -> Expression;
fn is_identity_matrix(&self) -> bool;
fn is_zero_matrix(&self) -> bool;
fn is_diagonal(&self) -> bool;
fn simplify_matrix(&self) -> Expression;
}Expand description
High-level matrix operations trait for Expression
Provides mathematical operations for matrices including addition, multiplication, transpose, inverse, and other linear algebra operations.
Required Methods§
Sourcefn matrix_add(&self, other: &Expression) -> Expression
fn matrix_add(&self, other: &Expression) -> Expression
Add two matrices
§Examples
use mathhook_core::Expression;
use mathhook_core::matrices::operations::MatrixOperations;
let a = Expression::matrix(vec![
vec![Expression::integer(1), Expression::integer(2)],
vec![Expression::integer(3), Expression::integer(4)]
]);
let b = Expression::matrix(vec![
vec![Expression::integer(5), Expression::integer(6)],
vec![Expression::integer(7), Expression::integer(8)]
]);
let result = a.matrix_add(&b);
// Result: [[6, 8], [10, 12]]Sourcefn matrix_subtract(&self, other: &Expression) -> Expression
fn matrix_subtract(&self, other: &Expression) -> Expression
Subtract two matrices
Sourcefn matrix_multiply(&self, other: &Expression) -> Expression
fn matrix_multiply(&self, other: &Expression) -> Expression
Multiply two matrices
Sourcefn matrix_scalar_multiply(&self, scalar: &Expression) -> Expression
fn matrix_scalar_multiply(&self, scalar: &Expression) -> Expression
Multiply matrix by scalar
Sourcefn matrix_determinant(&self) -> Expression
fn matrix_determinant(&self) -> Expression
Get matrix determinant
Sourcefn matrix_transpose(&self) -> Expression
fn matrix_transpose(&self) -> Expression
Get matrix transpose
Sourcefn matrix_inverse(&self) -> Expression
fn matrix_inverse(&self) -> Expression
Get matrix inverse
Sourcefn matrix_trace(&self) -> Expression
fn matrix_trace(&self) -> Expression
Get matrix trace (sum of diagonal elements)
Sourcefn matrix_power(&self, exponent: &Expression) -> Expression
fn matrix_power(&self, exponent: &Expression) -> Expression
Raise matrix to a power
Sourcefn is_identity_matrix(&self) -> bool
fn is_identity_matrix(&self) -> bool
Check if matrix is identity matrix
Sourcefn is_zero_matrix(&self) -> bool
fn is_zero_matrix(&self) -> bool
Check if matrix is zero matrix
Sourcefn is_diagonal(&self) -> bool
fn is_diagonal(&self) -> bool
Check if matrix is diagonal
Sourcefn simplify_matrix(&self) -> Expression
fn simplify_matrix(&self) -> Expression
Simplify matrix expression