pub trait GeneralMatrix:
Add<Self, Output = Self>
+ AddAssign<Self>
+ Index<(usize, usize), Output = f64>
+ Mul<f64, Output = Self>
+ MulAssign<f64>
+ Neg<Output = Self>
+ Sized
+ Sub<Self, Output = Self>
+ SubAssign<Self> {
// Required methods
fn zeros() -> Self;
fn shape(&self) -> (usize, usize);
}Expand description
Common operations for all matrices.
Matrices can be added:
use hoomd_linear_algebra::{Full, GeneralMatrix, matrix::Matrix};
let a = Matrix {
rows: [[1.0, -3.0], [-2.0, 4.0]],
};
let b = Matrix {
rows: [[4.0, -8.0], [6.0, 7.0]],
};
let mut c = a + b;
c += a;subtracted:
use hoomd_linear_algebra::{Full, GeneralMatrix, matrix::Matrix};
let a = Matrix {
rows: [[1.0, -3.0], [-2.0, 4.0]],
};
let b = Matrix {
rows: [[4.0, -8.0], [6.0, 7.0]],
};
let mut c = a - b;
c += a;multiplied by a scalar:
use hoomd_linear_algebra::{Full, GeneralMatrix, matrix::Matrix};
let a = Matrix {
rows: [[4.0, -8.0], [6.0, 7.0]],
};
let b = -2.0;
let mut c = a * b;
c *= b;negated:
use hoomd_linear_algebra::{Full, GeneralMatrix, matrix::Matrix};
let a = Matrix {
rows: [[1.0, -3.0], [-2.0, 4.0]],
};
let b = -a;and indexed (in row,column ordering):
use hoomd_linear_algebra::{Full, GeneralMatrix, matrix::Matrix};
let a = Matrix {
rows: [[1.0, -3.0], [-2.0, 4.0]],
};
let element = a[(1, 0)];Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.