pub type Tensor5<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> = Tensor<Dim5<X, Y, Z, W, V>>;
Expand description
A 5-th order tensor.
Aliased Type§
pub struct Tensor5<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> {
pub inner: <Dim5<X, Y, Z, W, V> as Dimension>::ArrayForm,
}
Fields§
§inner: <Dim5<X, Y, Z, W, V> as Dimension>::ArrayForm
Implementations§
Source§impl<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> Tensor5<X, Y, Z, W, V>
impl<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> Tensor5<X, Y, Z, W, V>
Sourcepub fn convolution<const KX: usize, const BX: usize, const KY: usize, const BY: usize, const KZ: usize, const BZ: usize, const KW: usize, const BW: usize, const KV: usize, const BV: usize>(
&self,
kernel: &Tensor5<KX, KY, KZ, KW, KV>,
stride: &[usize],
) -> Tensor5<BX, BY, BZ, BW, BV>
pub fn convolution<const KX: usize, const BX: usize, const KY: usize, const BY: usize, const KZ: usize, const BZ: usize, const KW: usize, const BW: usize, const KV: usize, const BV: usize>( &self, kernel: &Tensor5<KX, KY, KZ, KW, KV>, stride: &[usize], ) -> Tensor5<BX, BY, BZ, BW, BV>
Computes the convolution with padded 0.
§Stride
The stride
parameter controls the amount that kernel
moves in each iteration.
Note that it panics when any elememt in stride[..5]
is 0
or stride.len() < 5
. If unsure, use &[1; 5]
§Note
Each dimension of the output must be ceil((self + kernel) / stride) - 1
or else
there will be a runtime panic. It is not checked during compile time due to Rust
type bound limits.
Source§impl<D: Dimension> Tensor<D>
impl<D: Dimension> Tensor<D>
Sourcepub fn new_filled(value: f32) -> Self
pub fn new_filled(value: f32) -> Self
Create a new Tensor
with values filled from value
.
pub fn map_each<F: Fn(f32) -> f32>(self, f: F) -> Self
pub fn map_zip_ref<F: Fn(f32, f32) -> f32>(self, r: &Self, f: F) -> Self
pub fn map_each_in_place<F: Fn(f32) -> f32>(&mut self, f: F)
pub fn map_zip_ref_in_place<F: Fn(f32, f32) -> f32>(&mut self, r: &Self, f: F)
pub fn reshape<E>(self) -> Tensor<E>
Source§impl<D: Dimension> Tensor<D>
impl<D: Dimension> Tensor<D>
Sourcepub fn hadamard_product(self, rhs: &Self) -> Self
pub fn hadamard_product(self, rhs: &Self) -> Self
Computes the Hadamard product (aka. element-wise multiplication)
Source§impl<D: VectorDim> Tensor<D>
impl<D: VectorDim> Tensor<D>
Sourcepub fn length_squared(&self) -> f32
pub fn length_squared(&self) -> f32
Computes the squared length from self
to [0, …]
.
Sourcepub fn unit(self) -> Self
pub fn unit(self) -> Self
Computes the normalized vector of self
where Self::length
is ≈1.
Source§impl<D: VectorDim3> Tensor<D>
impl<D: VectorDim3> Tensor<D>
Source§impl<const X: usize, const Y: usize, const Z: usize, const W: usize> Tensor<Dim5<X, Y, Z, W, 1>>
impl<const X: usize, const Y: usize, const Z: usize, const W: usize> Tensor<Dim5<X, Y, Z, W, 1>>
Source§impl<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> Tensor<Dim5<X, Y, Z, W, V>>
impl<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> Tensor<Dim5<X, Y, Z, W, V>>
Sourcepub fn join<const N: usize>(list: [&Self; N]) -> Tensor<Dim6<X, Y, Z, W, V, N>>
pub fn join<const N: usize>(list: [&Self; N]) -> Tensor<Dim6<X, Y, Z, W, V, N>>
Join multiple tensors into a tensor with an order higher by copying each element.
§Example
ⓘ
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
use smolmatrix::*;
let a = HVector::join([
&hvector!(3 [1.0, 2.0, 3.0]),
&hvector!(3 [4.0, 5.0, 6.0]),
&hvector!(3 [7.0, 8.0, 9.0]),
]);
assert_eq!(a, matrix!(3 x 3
[1.0, 2.0, 3.0]
[4.0, 5.0, 6.0]
[7.0, 8.0, 9.0]
));
Trait Implementations
Source§impl<D: Dimension> AddAssign<&Tensor<D>> for Tensor<D>
impl<D: Dimension> AddAssign<&Tensor<D>> for Tensor<D>
Source§fn add_assign(&mut self, rhs: &Self)
fn add_assign(&mut self, rhs: &Self)
Performs the
+=
operation. Read moreSource§impl<D: Dimension> AddAssign<f32> for Tensor<D>
impl<D: Dimension> AddAssign<f32> for Tensor<D>
Source§fn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
Performs the
+=
operation. Read moreSource§impl<D: Dimension> DivAssign<&Tensor<D>> for Tensor<D>
impl<D: Dimension> DivAssign<&Tensor<D>> for Tensor<D>
Source§fn div_assign(&mut self, rhs: &Self)
fn div_assign(&mut self, rhs: &Self)
Performs the
/=
operation. Read moreSource§impl<D: Dimension> DivAssign<f32> for Tensor<D>
impl<D: Dimension> DivAssign<f32> for Tensor<D>
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
Performs the
/=
operation. Read moreSource§impl<const X: usize, const Y: usize, const Z: usize, const W: usize> From<Tensor<Dim4<X, Y, Z, W>>> for Tensor<Dim5<X, Y, Z, W, 1>>
impl<const X: usize, const Y: usize, const Z: usize, const W: usize> From<Tensor<Dim4<X, Y, Z, W>>> for Tensor<Dim5<X, Y, Z, W, 1>>
Source§impl<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> From<Tensor<Dim6<X, Y, Z, W, V, 1>>> for Tensor<Dim5<X, Y, Z, W, V>>
impl<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> From<Tensor<Dim6<X, Y, Z, W, V, 1>>> for Tensor<Dim5<X, Y, Z, W, V>>
Source§impl<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> Index<[usize; 5]> for Tensor<Dim5<X, Y, Z, W, V>>
impl<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> Index<[usize; 5]> for Tensor<Dim5<X, Y, Z, W, V>>
Source§impl<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> IndexMut<[usize; 5]> for Tensor<Dim5<X, Y, Z, W, V>>
impl<const X: usize, const Y: usize, const Z: usize, const W: usize, const V: usize> IndexMut<[usize; 5]> for Tensor<Dim5<X, Y, Z, W, V>>
Source§impl<D: Dimension> MulAssign<f32> for Tensor<D>
impl<D: Dimension> MulAssign<f32> for Tensor<D>
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
Performs the
*=
operation. Read moreSource§impl<D: Dimension> SubAssign<&Tensor<D>> for Tensor<D>
impl<D: Dimension> SubAssign<&Tensor<D>> for Tensor<D>
Source§fn sub_assign(&mut self, rhs: &Self)
fn sub_assign(&mut self, rhs: &Self)
Performs the
-=
operation. Read moreSource§impl<D: Dimension> SubAssign<f32> for Tensor<D>
impl<D: Dimension> SubAssign<f32> for Tensor<D>
Source§fn sub_assign(&mut self, rhs: f32)
fn sub_assign(&mut self, rhs: f32)
Performs the
-=
operation. Read more