[−][src]Struct crabsformer::Vector
Vector elements structure
TODO: add overview about vector here.
- how to create a vector
- Vector operation
- Indexing, etc.
Methods
impl<T> Vector<T>
[src]
pub fn len(&self) -> usize
[src]
The total number of elements of the numeric vector.
Examples
let v = vector![3.0, 1.0, 4.0, 1.0, 5.0]; assert_eq!(v.len(), 5);
impl<T> Vector<T> where
T: FromPrimitive + Num + Copy,
[src]
T: FromPrimitive + Num + Copy,
pub fn full(len: usize, value: T) -> Vector<T>
[src]
Create a new numeric vector of given length len
and type T
,
filled with value
.
Examples
let v = Vector::full(5, 2.5);
pub fn full_like(v: &Vector<T>, value: T) -> Vector<T>
[src]
Create a new numeric vector that have the same length and type
as vector v
, filled with value
.
Examples
let v1 = vector![3.0, 1.0, 4.0, 1.0, 5.0]; let v2 = Vector::full_like(&v1, 3.1415);
pub fn zeros(len: usize) -> Vector<T>
[src]
Create a new numeric vector of given length len
and type T
,
filled with zeros. You need to explicitly annotate the
numeric type.
Examples
let v: Vector<i32> = Vector::zeros(5);
pub fn zeros_like(v: &Vector<T>) -> Vector<T>
[src]
Create a new numeric vector that have the same length and type
as vector v
, filled with zeros.
Examples
let v1 = vector![3, 1, 4, 1, 5]; let v2 = Vector::zeros_like(&v1);
pub fn ones(len: usize) -> Vector<T>
[src]
Create a new numeric vector of given length len
and type T
,
filled with ones. You need to explicitly annotate the
numeric type.
Examples
let v: Vector<i32> = Vector::ones(10);
pub fn ones_like(v: &Vector<T>) -> Vector<T>
[src]
Create a new numeric vector that have the same length and type
as vector v
, filled with ones.
Examples
let v1 = vector![3, 1, 4, 1, 5]; let v2 = Vector::ones_like(&v1);
pub fn power(&self, exp: usize) -> Vector<T>
[src]
Raises each elements of vector to the power of exp
,
using exponentiation by squaring.
Examples
let x = vector![3, 1, 4, 1]; let y = x.power(2); assert_eq!(y, vector![9, 1, 16, 1]);
pub fn filter(&self, criteria: impl Fn(T) -> bool) -> Vector<T>
[src]
Filter out the elements that doesn't match the criteria.
Examples
let x = vector![3, 1, 4, 1]; let y = x.filter(|x| x >= 2); assert_eq!(y, vector![3, 4]);
impl<U> Vector<U> where
U: SampleUniform,
[src]
U: SampleUniform,
pub fn uniform(len: usize, low: U, high: U) -> Vector<U>
[src]
Create a new numeric vector of the given length len
and
populate it with random samples from a uniform distribution
over the half-open interval [low, high)
(includes low
,
but excludes high
).
Examples
let v = Vector::uniform(5, 0.0, 1.0);
impl Vector<f64>
[src]
pub fn normal(len: usize, mean: f64, std_dev: f64) -> Vector<f64>
[src]
Create a new numeric vector of the given length len
and
populate it with random samples from a normal distribution
N(mean, std_dev**2)
.
Examples
let v = Vector::normal(5, 0.0, 1.0); // Gaussian mean=0.0 std_dev=1.0
impl<T> Vector<T> where
T: Num + FromPrimitive + Copy + PartialOrd + AddAssign + Display,
[src]
T: Num + FromPrimitive + Copy + PartialOrd + AddAssign + Display,
pub fn range(start: T, stop: T, step: T) -> Vector<T>
[src]
Create a new numeric vector of evenly spaced values
within a given half-open interval [start, stop)
and
spacing value step
. Values are generated within the
half-open interval [start, stop)
(in other words, the
interval including start
but excluding stop
).
Examples
let v = Vector::range(0.0, 3.0, 0.5); // v = vector![0.0, 0.5, 1.0, 1.5, 2.0, 2.5]
Panics
Panics if start >= stop
.
impl<F> Vector<F> where
F: Float + FromPrimitive + Copy + PartialOrd + AddAssign + Display,
[src]
F: Float + FromPrimitive + Copy + PartialOrd + AddAssign + Display,
Trait Implementations
impl<T> PartialEq<Vector<T>> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
impl<T> From<Vec<T>> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
impl<T> Clone for Vector<T> where
T: Copy,
[src]
T: Copy,
fn clone(&self) -> Vector<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Debug for Vector<T> where
T: Debug,
[src]
T: Debug,
impl<T> Add<Vector<T>> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Vector<T>
The resulting type after applying the +
operator.
fn add(self, other: Vector<T>) -> Vector<T>
[src]
impl<T> Add<T> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Vector<T>
The resulting type after applying the +
operator.
fn add(self, value: T) -> Vector<T>
[src]
impl Add<Vector<usize>> for usize
[src]
type Output = Vector<usize>
The resulting type after applying the +
operator.
fn add(self, v: Vector<usize>) -> Vector<usize>
[src]
impl Add<Vector<i8>> for i8
[src]
type Output = Vector<i8>
The resulting type after applying the +
operator.
fn add(self, v: Vector<i8>) -> Vector<i8>
[src]
impl Add<Vector<i16>> for i16
[src]
type Output = Vector<i16>
The resulting type after applying the +
operator.
fn add(self, v: Vector<i16>) -> Vector<i16>
[src]
impl Add<Vector<i32>> for i32
[src]
type Output = Vector<i32>
The resulting type after applying the +
operator.
fn add(self, v: Vector<i32>) -> Vector<i32>
[src]
impl Add<Vector<i64>> for i64
[src]
type Output = Vector<i64>
The resulting type after applying the +
operator.
fn add(self, v: Vector<i64>) -> Vector<i64>
[src]
impl Add<Vector<i128>> for i128
[src]
type Output = Vector<i128>
The resulting type after applying the +
operator.
fn add(self, v: Vector<i128>) -> Vector<i128>
[src]
impl Add<Vector<u8>> for u8
[src]
type Output = Vector<u8>
The resulting type after applying the +
operator.
fn add(self, v: Vector<u8>) -> Vector<u8>
[src]
impl Add<Vector<u16>> for u16
[src]
type Output = Vector<u16>
The resulting type after applying the +
operator.
fn add(self, v: Vector<u16>) -> Vector<u16>
[src]
impl Add<Vector<u32>> for u32
[src]
type Output = Vector<u32>
The resulting type after applying the +
operator.
fn add(self, v: Vector<u32>) -> Vector<u32>
[src]
impl Add<Vector<u64>> for u64
[src]
type Output = Vector<u64>
The resulting type after applying the +
operator.
fn add(self, v: Vector<u64>) -> Vector<u64>
[src]
impl Add<Vector<u128>> for u128
[src]
type Output = Vector<u128>
The resulting type after applying the +
operator.
fn add(self, v: Vector<u128>) -> Vector<u128>
[src]
impl Add<Vector<f32>> for f32
[src]
type Output = Vector<f32>
The resulting type after applying the +
operator.
fn add(self, v: Vector<f32>) -> Vector<f32>
[src]
impl Add<Vector<f64>> for f64
[src]
type Output = Vector<f64>
The resulting type after applying the +
operator.
fn add(self, v: Vector<f64>) -> Vector<f64>
[src]
impl<T> Sub<Vector<T>> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Vector<T>
The resulting type after applying the -
operator.
fn sub(self, other: Vector<T>) -> Vector<T>
[src]
impl<T> Sub<T> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Vector<T>
The resulting type after applying the -
operator.
fn sub(self, value: T) -> Vector<T>
[src]
impl Sub<Vector<usize>> for usize
[src]
type Output = Vector<usize>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<usize>) -> Vector<usize>
[src]
impl Sub<Vector<i8>> for i8
[src]
type Output = Vector<i8>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<i8>) -> Vector<i8>
[src]
impl Sub<Vector<i16>> for i16
[src]
type Output = Vector<i16>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<i16>) -> Vector<i16>
[src]
impl Sub<Vector<i32>> for i32
[src]
type Output = Vector<i32>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<i32>) -> Vector<i32>
[src]
impl Sub<Vector<i64>> for i64
[src]
type Output = Vector<i64>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<i64>) -> Vector<i64>
[src]
impl Sub<Vector<i128>> for i128
[src]
type Output = Vector<i128>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<i128>) -> Vector<i128>
[src]
impl Sub<Vector<u8>> for u8
[src]
type Output = Vector<u8>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<u8>) -> Vector<u8>
[src]
impl Sub<Vector<u16>> for u16
[src]
type Output = Vector<u16>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<u16>) -> Vector<u16>
[src]
impl Sub<Vector<u32>> for u32
[src]
type Output = Vector<u32>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<u32>) -> Vector<u32>
[src]
impl Sub<Vector<u64>> for u64
[src]
type Output = Vector<u64>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<u64>) -> Vector<u64>
[src]
impl Sub<Vector<u128>> for u128
[src]
type Output = Vector<u128>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<u128>) -> Vector<u128>
[src]
impl Sub<Vector<f32>> for f32
[src]
type Output = Vector<f32>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<f32>) -> Vector<f32>
[src]
impl Sub<Vector<f64>> for f64
[src]
type Output = Vector<f64>
The resulting type after applying the -
operator.
fn sub(self, v: Vector<f64>) -> Vector<f64>
[src]
impl<T> Mul<Vector<T>> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, other: Vector<T>) -> Vector<T>
[src]
impl<T> Mul<T> for Vector<T> where
T: Num + Copy,
[src]
T: Num + Copy,
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, value: T) -> Vector<T>
[src]
impl Mul<Vector<usize>> for usize
[src]
type Output = Vector<usize>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<usize>) -> Vector<usize>
[src]
impl Mul<Vector<i8>> for i8
[src]
type Output = Vector<i8>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<i8>) -> Vector<i8>
[src]
impl Mul<Vector<i16>> for i16
[src]
type Output = Vector<i16>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<i16>) -> Vector<i16>
[src]
impl Mul<Vector<i32>> for i32
[src]
type Output = Vector<i32>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<i32>) -> Vector<i32>
[src]
impl Mul<Vector<i64>> for i64
[src]
type Output = Vector<i64>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<i64>) -> Vector<i64>
[src]
impl Mul<Vector<i128>> for i128
[src]
type Output = Vector<i128>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<i128>) -> Vector<i128>
[src]
impl Mul<Vector<u8>> for u8
[src]
type Output = Vector<u8>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<u8>) -> Vector<u8>
[src]
impl Mul<Vector<u16>> for u16
[src]
type Output = Vector<u16>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<u16>) -> Vector<u16>
[src]
impl Mul<Vector<u32>> for u32
[src]
type Output = Vector<u32>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<u32>) -> Vector<u32>
[src]
impl Mul<Vector<u64>> for u64
[src]
type Output = Vector<u64>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<u64>) -> Vector<u64>
[src]
impl Mul<Vector<u128>> for u128
[src]
type Output = Vector<u128>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<u128>) -> Vector<u128>
[src]
impl Mul<Vector<f32>> for f32
[src]
type Output = Vector<f32>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<f32>) -> Vector<f32>
[src]
impl Mul<Vector<f64>> for f64
[src]
type Output = Vector<f64>
The resulting type after applying the *
operator.
fn mul(self, v: Vector<f64>) -> Vector<f64>
[src]
impl<T> AddAssign<Vector<T>> for Vector<T> where
T: Num + Copy + AddAssign,
[src]
T: Num + Copy + AddAssign,
fn add_assign(&mut self, other: Vector<T>)
[src]
impl<T> AddAssign<T> for Vector<T> where
T: Num + Copy + AddAssign,
[src]
T: Num + Copy + AddAssign,
fn add_assign(&mut self, value: T)
[src]
impl<T> SubAssign<Vector<T>> for Vector<T> where
T: Num + Copy + SubAssign,
[src]
T: Num + Copy + SubAssign,
fn sub_assign(&mut self, other: Vector<T>)
[src]
impl<T> SubAssign<T> for Vector<T> where
T: Num + Copy + SubAssign,
[src]
T: Num + Copy + SubAssign,
fn sub_assign(&mut self, value: T)
[src]
impl<T> MulAssign<Vector<T>> for Vector<T> where
T: Num + Copy + MulAssign,
[src]
T: Num + Copy + MulAssign,
fn mul_assign(&mut self, other: Vector<T>)
[src]
impl<T> MulAssign<T> for Vector<T> where
T: Num + Copy + MulAssign,
[src]
T: Num + Copy + MulAssign,
fn mul_assign(&mut self, value: T)
[src]
impl<T> Index<usize> for Vector<T>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
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,