Struct little_matrix::Matrix [−][src]
pub struct Matrix { /* fields omitted */ }
Implementations
impl Matrix
[src]
A Matrix is represented here by 3 fields named: nrows: i16, ncols: i16, data: Vec<Vec
pub fn nrows(&self) -> i16
[src]
Returns the number of rows as i16.
Examples
use nn::Matrix;
let matrix: Matrix = Matrix::create_random_matrix(6, 6);
println!(“The matrix has {} rows and {} cols”, matrix.nrows(), matrix.ncols());
pub fn ncols(&self) -> i16
[src]
Returns the number of cols as i16.
Examples
use nn::Matrix;
let matrix: Matrix = Matrix::create_random_matrix(6, 6);
println!(“The matrix has {} rows and {} cols”, matrix.nrows(), matrix.ncols());
pub fn set(&mut self, x: i16, y: i16, v: f64)
[src]
Sets one value in the Vector.
Arguments
x
- A i16 Integer that holds the row, in which the variable is set.y
- A i16 Integer that holds the col, in which the variable is set.v
- A f64 Float that holds the new variable value.
Examples
use nn::Matrix;
let matrix: Matrix = Matrix::create_random_matrix(6, 6);
matrix.print();
matrix.set(0, 0, 5.3);
matrix.print();
pub fn get(&self, x: i16, y: i16) -> f64
[src]
Returns one value in the Vector by a given row and col as f64.
Arguments
x
- A i16 Integer that holds the row, in which the variable is set.y
- A i16 Integer that holds the col, in which the variable is set.
Examples
use nn::Matrix;
let matrix: Matrix = Matrix::create_random_matrix(6, 6);
println!(“Value at row 0 and col 0 has the value {}”, matrix.get(0, 0));
pub fn add(a: &Matrix, b: &Matrix) -> Matrix
[src]
Returns two matrices added together one by one as a Matrix.
Arguments
a
- A &Matrix.b
- A &Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
let matrix_sum: Matrix = Matrix::add(&matrixa, &matrixb);
pub fn sub(a: &Matrix, b: &Matrix) -> Matrix
[src]
Returns two matrices subtracted one by one as a Matrix.
Arguments
a
- A &Matrix.b
- A &Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
let matrix_sub: Matrix = Matrix::sub(&matrixa, &matrixb);
pub fn mul(a: &Matrix, b: &Matrix) -> Matrix
[src]
Returns two matrices multiplied one by one as a Matrix.
Arguments
a
- A &Matrix.b
- A &Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
let matrix_mul: Matrix = Matrix::mul(&matrixa, &matrixb);
pub fn div(a: &Matrix, b: &Matrix) -> Matrix
[src]
Returns two matrices divided one by one as a Matrix.
Arguments
a
- A &Matrix.b
- A &Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
let matrix_div: Matrix = Matrix::div(&matrixa, &matrixb);
pub fn dot(a: &Matrix, b: &Matrix) -> Matrix
[src]
Returns the dot product of two matrices as a Matrix.
Arguments
a
- A &Matrix.b
- A &Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(1, 2);
let matrixb: Matrix = Matrix::create_random_matrix(2, 1);
let matrix_dot: Matrix = Matrix::dot(&matrixa, &matrixb);
pub fn transpose(a: &Matrix) -> Matrix
[src]
Returns the transposed Matrix as a Matrix.
Arguments
a
- A &Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrix_t: Matrix = Matrix::transpose(&matrixa);
pub fn map(&self, f: fn(_: f64) -> f64) -> Matrix
[src]
Applies a given function fn(f64) -> f64 to every value in the Matrix and returns the new Matrix as a Matrix.
Arguments
a
- A &Matrix.f
- A fn(f64) -> f64.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6); let closure = |i: f64| -> f64 { i+10.0 }; let matrixb = matrixa.map(closure);
pub fn scalar_add(a: &Matrix, v: f64) -> Matrix
[src]
Adds a single f64 float to every value in a given Matrix and returns it as a Matrix.
Arguments
a
- A &Matrix.v
- A f64.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let scalar_add: Matrix = Matrix::scalar_add(&matrixa, 10.0);
pub fn scalar_sub(a: &Matrix, v: f64) -> Matrix
[src]
Subtracts a single f64 float from every value in a given Matrix and returns it as a Matrix.
Arguments
a
- A &Matrix.v
- A f64.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let scalar_sub: Matrix = Matrix::scalar_sub(&matrixa, 10.0);
pub fn scalar_sub_first(a: &Matrix, v: f64) -> Matrix
[src]
Subtracts every value of the Matrix from a given float f64 and returns it as a Matrix.
Arguments
a
- A &Matrix.v
- A f64.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let scalar_sub: Matrix = Matrix::scalar_sub_first(&matrixa, 10.0);
pub fn scalar_mult(a: &Matrix, v: f64) -> Matrix
[src]
Multiplies every value of the Matrix by a given float f64 and returns it as a Matrix.
Arguments
a
- A &Matrix.v
- A f64.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let scalar_sub: Matrix = Matrix::scalar_mult(&matrixa, 10.0);
pub fn scalar_div(a: &Matrix, v: f64) -> Matrix
[src]
Divides every value of the Matrix by a given float f64 and returns it as a Matrix.
Arguments
a
- A &Matrix.v
- A f64.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let scalar_sub: Matrix = Matrix::scalar_div(&matrixa, 10.0);
pub fn inverse(a: &Matrix) -> Matrix
[src]
Returns a Matrix where every value has the opposite sign as a Matrix.
Arguments
a
- A &Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixa_inverse: Matrix = Matrix::inverse(&matrixa);
pub fn sum_rows(a: &Matrix) -> Matrix
[src]
Sums every row together and returns a Matrix with the same number of rows and 1 column.
Arguments
a
- A &Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixa_rows_sum: = Matrix::sum_rows(&matrixa);
pub fn pow(a: &Matrix, v: f64) -> Matrix
[src]
Every value in the Matrix is raised to a given power and returned as a Matrix.
Arguments
a
- A &Matrix.v
- A f64.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixa_pow_2 = Matrix::pow(&matrixa, 2.0);
pub fn filter_by_function(a: &Matrix, f: fn(_: f64) -> bool, v: f64) -> Matrix
[src]
Filters every value in the Matrix by a given function fn(f64) -> bool. If the output of the function is true, the value stays the same. If the output of the function is false, the value is replaced by a given float f64. It returns a Matrix.
Arguments
a
- A &Matrix.f
- A fn(f64) -> bool.v
- A f64.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let closure = |v: f64| -> bool { v < 10.0 };
let matrixb = Matrix::filter_by_function(&matrixa, closure, 0.0);
pub fn get_shape_string(&self) -> String
[src]
Returns the shape of a Matrix as a string formatted with Shape:({}, {}) as a String.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
println!(“Matrix has {}”, matrixa.get_shape_string());
pub fn print(&self)
[src]
Pretty prints the Matrix to the console using print!().
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
matrixa.print();
pub fn create_matrix(nrows: i16, ncols: i16) -> Matrix
[src]
Creates a Matrix by a given number of rows as i16 and cols as i16 where every value is zero and returns it as a Matrix.
Arguments
nrows
- A i16.ncols
- A i16.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_matrix(6, 6);
pub fn create_random_matrix(nrows: i16, ncols: i16) -> Matrix
[src]
Creates a Matrix by a given number of rows as i16 and cols as i16 where every value is random between 0 and 1 and returns it as a Matrix.
Arguments
nrows
- A i16.ncols
- A i16.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_matrix(6, 6);
pub fn create_matrix_by_float(nrows: i16, ncols: i16, v: f64) -> Matrix
[src]
Creates a Matrix by a given number of rows as i16 and cols as i16 where every value is a given float and returns it as a Matrix.
Arguments
nrows
- A i16.ncols
- A i16.v
- A f64.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_matrix_by_float(6, 6, 10.0);
pub fn create_matrix_from_nested_float_array(v: &[&[f64]]) -> Matrix
[src]
Trait Implementations
impl Add<Matrix> for Matrix
[src]
Returns two matrices added together one by one as a Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
let matrix_sum: Matrix = matrixa.clone() + matrixb.clone();
type Output = Matrix
The resulting type after applying the +
operator.
fn add(self, _rhs: Matrix) -> Matrix
[src]
impl AddAssign<Matrix> for Matrix
[src]
Adds a Matrix to a given Matrix one by one.
Examples
use nn::Matrix;
let mut matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
matrixa += matrixb;
fn add_assign(&mut self, _rhs: Matrix)
[src]
impl BitOr<Matrix> for Matrix
[src]
Returns the dot product of two matrices as a Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(1, 2);
let matrixb: Matrix = Matrix::create_random_matrix(2, 1);
let matrix_dot: Matrix = matrixa.clone() | matrixb.clone();
type Output = Matrix
The resulting type after applying the |
operator.
fn bitor(self, rhs: Matrix) -> Matrix
[src]
impl Clone for Matrix
[src]
impl Div<Matrix> for Matrix
[src]
Returns two matrices divided one by one as a Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
let matrix_div: Matrix = matrixa.clone() / matrixb.clone();
type Output = Matrix
The resulting type after applying the /
operator.
fn div(self, _rhs: Matrix) -> Matrix
[src]
impl DivAssign<Matrix> for Matrix
[src]
Divides a Matrix by a given Matrix one by one.
Examples
use nn::Matrix;
let mut matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
matrixa /= matrixb;
fn div_assign(&mut self, _rhs: Matrix)
[src]
impl Index<Range<usize>> for Matrix
[src]
Creates a Matrix by nested float array &[&f64] and returns it as a Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(2, 2);
println!(“The value at Row 0 and Col 0 has the value {}”, matrixa[0..0]);
impl Mul<Matrix> for Matrix
[src]
Returns two matrices multiplied one by one as a Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
let matrix_mul: Matrix = matrixa.clone() * matrixb.clone();
type Output = Matrix
The resulting type after applying the *
operator.
fn mul(self, _rhs: Matrix) -> Matrix
[src]
impl MulAssign<Matrix> for Matrix
[src]
Multiplies a Matrix with a given Matrix one by one.
Examples
use nn::Matrix;
let mut matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
matrixa *= matrixb;
fn mul_assign(&mut self, _rhs: Matrix)
[src]
impl Not for Matrix
[src]
Returns a Matrix where every value has the opposite sign as a Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixa_inverse: Matrix = Matrix::inverse(&matrixa);
type Output = Matrix
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
impl Sub<Matrix> for Matrix
[src]
Returns two matrices subtracted one by one as a Matrix.
Examples
use nn::Matrix;
let matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
let matrix_sub: Matrix = matrixa.clone() - matrixb.clone();
type Output = Matrix
The resulting type after applying the -
operator.
fn sub(self, _rhs: Matrix) -> Matrix
[src]
impl SubAssign<Matrix> for Matrix
[src]
Subtracts a Matrix with a given Matrix one by one.
Examples
use nn::Matrix;
let mut matrixa: Matrix = Matrix::create_random_matrix(6, 6);
let matrixb: Matrix = Matrix::create_random_matrix(6, 6);
matrixa -= matrixb;
fn sub_assign(&mut self, _rhs: Matrix)
[src]
Auto Trait Implementations
impl RefUnwindSafe for Matrix
impl Send for Matrix
impl Sync for Matrix
impl Unpin for Matrix
impl UnwindSafe for Matrix
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,