[−][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);
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: Debug> Debug for Matrix<T>
[src]
impl<T> Index<usize> for Matrix<T>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
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> 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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?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>,