[−][src]Struct crabsformer::Matrix
Matrix.
TODO: add overview about matrix here.
- how to create a matrix
- Matrix operation
- Indexing, etc.
Methods
impl<T> Matrix<T>
[src]
pub fn shape(&self) -> [usize; 2]
[src]
The shape of the matrix [nrows, ncols]
.
Examples
let W = matrix![ 3.0, 1.0; 4.0, 1.0; 5.0, 9.0; ]; assert_eq!(W.shape(), [3, 2]);
pub fn full(shape: [usize; 2], value: T) -> Matrix<T> where
T: FromPrimitive + Num + Copy,
[src]
T: FromPrimitive + Num + Copy,
Create a new matrix of given shape shape
and type T
,
filled with value
.
Examples
let W = Matrix::full([5, 5], 2.5);
pub fn full_like(m: &Matrix<T>, value: T) -> Matrix<T> where
T: FromPrimitive + Num + Copy,
[src]
T: FromPrimitive + Num + Copy,
Create a new matrix that have the same shape and type
as matrix m
, filled with value
.
Examples
let w1 = matrix![ 3.0, 1.0; 4.0, 1.0; ]; let w2 = Matrix::full_like(&w1, 3.1415);
pub fn zeros(shape: [usize; 2]) -> Matrix<T> where
T: FromPrimitive + Num + Copy,
[src]
T: FromPrimitive + Num + Copy,
Create a new matrix of given shape shape
and type T
,
filled with zeros. You need to explicitly annotate the
numeric type.
Examples
let W: Matrix<i32> = Matrix::zeros([5, 5]);
pub fn zeros_like(m: &Matrix<T>) -> Matrix<T> where
T: FromPrimitive + Num + Copy,
[src]
T: FromPrimitive + Num + Copy,
Create a new matrix that have the same shape and type
as matrix m
, filled with zeros.
Examples
let W1 = matrix![3.0, 1.0; 4.0, 1.0]; let W2 = Matrix::zeros_like(&W1);
pub fn ones(shape: [usize; 2]) -> Matrix<T> where
T: FromPrimitive + Num + Copy,
[src]
T: FromPrimitive + Num + Copy,
Create a new matrix of given shaoe shape
and type T
,
filled with ones. You need to explicitly annotate the
numeric type.
Examples
let W: Matrix<i32> = Matrix::ones([3, 5]);
pub fn ones_like(m: &Matrix<T>) -> Matrix<T> where
T: FromPrimitive + Num + Copy,
[src]
T: FromPrimitive + Num + Copy,
Create a new matrix that have the same shape and type
as matrix m
, filled with ones.
Examples
let W1 = matrix![3, 1; 4, 1; 5, 9]; let W2 = Matrix::ones_like(&W1);
pub fn power(&self, exp: usize) -> Matrix<T> where
T: FromPrimitive + Num + Copy,
[src]
T: FromPrimitive + Num + Copy,
Raises each elements of matrix to the power of exp
,
using exponentiation by squaring.
Examples
let W1 = matrix![3, 1, 4; 1, 5, 9]; let W2 = W1.power(2); assert_eq!(W2, matrix![9, 1, 16; 1, 25, 81]);
pub fn uniform(shape: [usize; 2], low: T, high: T) -> Matrix<T> where
T: Num + SampleUniform + Copy,
[src]
T: Num + SampleUniform + Copy,
Create a new matrix of the given shape shape
and
populate it with random samples from a uniform distribution
over the half-open interval [low, high)
(includes low
,
but excludes high
).
Examples
let W = Matrix::uniform([5, 5], 0.0, 1.0);
pub fn from_csv<P>(file_path: P) -> MatrixLoaderForCSV<T, P> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Load Matrix from CSV file. You need to explicitly annotate the numeric type.
Examples
use crabsformer::*; let dataset: Matrix<f32> = Matrix::from("tests/weight.csv").load().unwrap();
impl Matrix<f64>
[src]
pub fn normal(shape: [usize; 2], mean: f64, std_dev: f64) -> Matrix<f64>
[src]
Create a new matrix of the given shape shape
and
populate it with random samples from a normal distribution
N(mean, std_dev**2)
.
Examples
let W = Matrix::normal([5, 5], 0.0, 1.0); // Gaussian mean=0.0 std_dev=1.0
Trait Implementations
impl<T> PartialEq<Matrix<T>> for Matrix<T> where
T: Num + Copy,
[src]
T: Num + Copy,
impl<T> IntoIterator for Matrix<T>
[src]
type Item = Vector<T>
The type of the elements being iterated over.
type IntoIter = IntoIter<Vector<T>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<T> From<Vec<Vec<T>>> for Matrix<T> where
T: Num + Copy,
[src]
T: Num + Copy,
impl<T> Add<Matrix<T>> for Matrix<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Matrix<T>
The resulting type after applying the +
operator.
fn add(self, other: Matrix<T>) -> Matrix<T>
[src]
impl<T> Add<T> for Matrix<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Matrix<T>
The resulting type after applying the +
operator.
fn add(self, value: T) -> Matrix<T>
[src]
impl Add<Matrix<usize>> for usize
[src]
type Output = Matrix<usize>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<usize>) -> Matrix<usize>
[src]
impl Add<Matrix<i8>> for i8
[src]
type Output = Matrix<i8>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<i8>) -> Matrix<i8>
[src]
impl Add<Matrix<i16>> for i16
[src]
type Output = Matrix<i16>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<i16>) -> Matrix<i16>
[src]
impl Add<Matrix<i32>> for i32
[src]
type Output = Matrix<i32>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<i32>) -> Matrix<i32>
[src]
impl Add<Matrix<i64>> for i64
[src]
type Output = Matrix<i64>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<i64>) -> Matrix<i64>
[src]
impl Add<Matrix<i128>> for i128
[src]
type Output = Matrix<i128>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<i128>) -> Matrix<i128>
[src]
impl Add<Matrix<u8>> for u8
[src]
type Output = Matrix<u8>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<u8>) -> Matrix<u8>
[src]
impl Add<Matrix<u16>> for u16
[src]
type Output = Matrix<u16>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<u16>) -> Matrix<u16>
[src]
impl Add<Matrix<u32>> for u32
[src]
type Output = Matrix<u32>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<u32>) -> Matrix<u32>
[src]
impl Add<Matrix<u64>> for u64
[src]
type Output = Matrix<u64>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<u64>) -> Matrix<u64>
[src]
impl Add<Matrix<u128>> for u128
[src]
type Output = Matrix<u128>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<u128>) -> Matrix<u128>
[src]
impl Add<Matrix<f32>> for f32
[src]
type Output = Matrix<f32>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<f32>) -> Matrix<f32>
[src]
impl Add<Matrix<f64>> for f64
[src]
type Output = Matrix<f64>
The resulting type after applying the +
operator.
fn add(self, m: Matrix<f64>) -> Matrix<f64>
[src]
impl<T> Sub<Matrix<T>> for Matrix<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Matrix<T>
The resulting type after applying the -
operator.
fn sub(self, other: Matrix<T>) -> Matrix<T>
[src]
impl<T> Sub<T> for Matrix<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Matrix<T>
The resulting type after applying the -
operator.
fn sub(self, value: T) -> Matrix<T>
[src]
impl Sub<Matrix<usize>> for usize
[src]
type Output = Matrix<usize>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<usize>) -> Matrix<usize>
[src]
impl Sub<Matrix<i8>> for i8
[src]
type Output = Matrix<i8>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<i8>) -> Matrix<i8>
[src]
impl Sub<Matrix<i16>> for i16
[src]
type Output = Matrix<i16>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<i16>) -> Matrix<i16>
[src]
impl Sub<Matrix<i32>> for i32
[src]
type Output = Matrix<i32>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<i32>) -> Matrix<i32>
[src]
impl Sub<Matrix<i64>> for i64
[src]
type Output = Matrix<i64>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<i64>) -> Matrix<i64>
[src]
impl Sub<Matrix<i128>> for i128
[src]
type Output = Matrix<i128>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<i128>) -> Matrix<i128>
[src]
impl Sub<Matrix<u8>> for u8
[src]
type Output = Matrix<u8>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<u8>) -> Matrix<u8>
[src]
impl Sub<Matrix<u16>> for u16
[src]
type Output = Matrix<u16>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<u16>) -> Matrix<u16>
[src]
impl Sub<Matrix<u32>> for u32
[src]
type Output = Matrix<u32>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<u32>) -> Matrix<u32>
[src]
impl Sub<Matrix<u64>> for u64
[src]
type Output = Matrix<u64>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<u64>) -> Matrix<u64>
[src]
impl Sub<Matrix<u128>> for u128
[src]
type Output = Matrix<u128>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<u128>) -> Matrix<u128>
[src]
impl Sub<Matrix<f32>> for f32
[src]
type Output = Matrix<f32>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<f32>) -> Matrix<f32>
[src]
impl Sub<Matrix<f64>> for f64
[src]
type Output = Matrix<f64>
The resulting type after applying the -
operator.
fn sub(self, m: Matrix<f64>) -> Matrix<f64>
[src]
impl<T> Mul<Matrix<T>> for Matrix<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Matrix<T>
The resulting type after applying the *
operator.
fn mul(self, other: Matrix<T>) -> Matrix<T>
[src]
impl<T> Mul<T> for Matrix<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Matrix<T>
The resulting type after applying the *
operator.
fn mul(self, value: T) -> Matrix<T>
[src]
impl Mul<Matrix<usize>> for usize
[src]
type Output = Matrix<usize>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<usize>) -> Matrix<usize>
[src]
impl Mul<Matrix<i8>> for i8
[src]
type Output = Matrix<i8>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<i8>) -> Matrix<i8>
[src]
impl Mul<Matrix<i16>> for i16
[src]
type Output = Matrix<i16>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<i16>) -> Matrix<i16>
[src]
impl Mul<Matrix<i32>> for i32
[src]
type Output = Matrix<i32>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<i32>) -> Matrix<i32>
[src]
impl Mul<Matrix<i64>> for i64
[src]
type Output = Matrix<i64>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<i64>) -> Matrix<i64>
[src]
impl Mul<Matrix<i128>> for i128
[src]
type Output = Matrix<i128>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<i128>) -> Matrix<i128>
[src]
impl Mul<Matrix<u8>> for u8
[src]
type Output = Matrix<u8>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<u8>) -> Matrix<u8>
[src]
impl Mul<Matrix<u16>> for u16
[src]
type Output = Matrix<u16>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<u16>) -> Matrix<u16>
[src]
impl Mul<Matrix<u32>> for u32
[src]
type Output = Matrix<u32>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<u32>) -> Matrix<u32>
[src]
impl Mul<Matrix<u64>> for u64
[src]
type Output = Matrix<u64>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<u64>) -> Matrix<u64>
[src]
impl Mul<Matrix<u128>> for u128
[src]
type Output = Matrix<u128>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<u128>) -> Matrix<u128>
[src]
impl Mul<Matrix<f32>> for f32
[src]
type Output = Matrix<f32>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<f32>) -> Matrix<f32>
[src]
impl Mul<Matrix<f64>> for f64
[src]
type Output = Matrix<f64>
The resulting type after applying the *
operator.
fn mul(self, m: Matrix<f64>) -> Matrix<f64>
[src]
impl<T> AddAssign<Matrix<T>> for Matrix<T> where
T: Num + Copy + AddAssign,
[src]
T: Num + Copy + AddAssign,
fn add_assign(&mut self, other: Matrix<T>)
[src]
impl<T> AddAssign<T> for Matrix<T> where
T: Num + Copy + AddAssign,
[src]
T: Num + Copy + AddAssign,
fn add_assign(&mut self, value: T)
[src]
impl<T> SubAssign<Matrix<T>> for Matrix<T> where
T: Num + Copy + SubAssign,
[src]
T: Num + Copy + SubAssign,
fn sub_assign(&mut self, other: Matrix<T>)
[src]
impl<T> SubAssign<T> for Matrix<T> where
T: Num + Copy + SubAssign,
[src]
T: Num + Copy + SubAssign,
fn sub_assign(&mut self, value: T)
[src]
impl<T> MulAssign<Matrix<T>> for Matrix<T> where
T: Num + Copy + MulAssign,
[src]
T: Num + Copy + MulAssign,
fn mul_assign(&mut self, other: Matrix<T>)
[src]
impl<T> MulAssign<T> for Matrix<T> where
T: Num + Copy + MulAssign,
[src]
T: Num + Copy + MulAssign,
fn mul_assign(&mut self, value: T)
[src]
impl<T> Index<usize> for Matrix<T>
[src]
type Output = Vector<T>
The returned type after indexing.
fn index(&self, i: usize) -> &Vector<T>
[src]
impl<T: Debug> Debug for Matrix<T>
[src]
Auto Trait Implementations
Blanket Implementations
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,