[][src]Struct crabsformer::Matrix

pub struct Matrix<T> { /* fields omitted */ }

Matrix

TODO: add overview about matrix here.

  1. how to create a matrix
  2. Matrix operation
  3. 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]

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]

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]

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]

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]

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]

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]

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]

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);

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]

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?

impl<T> From<Vec<Vec<T>>> for Matrix<T> where
    T: Num + Copy
[src]

impl<T: Debug> Debug for Matrix<T>[src]

impl<T> Index<usize> for Matrix<T>[src]

type Output = Vector<T>

The returned type after indexing.

Auto Trait Implementations

impl<T> Send for Matrix<T> where
    T: Send

impl<T> Sync for Matrix<T> where
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

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?

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.