[−][src]Struct diffgeom::tensors::Tensor
Struct representing a tensor.
A tensor is anchored at a given point and has coordinates
represented in the system defined by the generic parameter
T. The variance of the tensor (meaning its rank and types
of its indices) is defined by V. This allows Rust
to decide at compile time whether two tensors are legal
to be added / multiplied / etc.
It is only OK to perform an operation on two tensors if they belong to the same coordinate system.
Methods
impl<T, V> Tensor<T, V> where
T: CoordinateSystem,
V: Variance,
T::Dimension: Pow<V::Rank>,
Exp<T::Dimension, V::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
V: Variance,
T::Dimension: Pow<V::Rank>,
Exp<T::Dimension, V::Rank>: ArrayLength<f64>,
pub fn get_point(&self) -> &Point<T>[src]
Returns the point at which the tensor is defined.
pub fn set_point(&mut self, p: Point<T>)[src]
Sets the point at which the tensor is defined.
pub fn get_coord(i: &[usize]) -> usize[src]
Converts a set of tensor indices passed as a slice into a single index for the internal array.
The length of the slice (the number of indices) has to be compatible with the rank of the tensor.
pub fn get_variance() -> Vec<IndexType>[src]
Returns the variance of the tensor, that is, the list of the index types. A vector would return vec![Contravariant], a metric tensor: vec![Covariant, Covariant].
pub fn get_rank() -> usize[src]
Returns the rank of the tensor
pub fn get_num_coords() -> usize[src]
Returns the number of coordinates of the tensor (equal to [Dimension]^[Rank])
pub fn zero(point: Point<T>) -> Tensor<T, V>[src]
Creates a new, zero tensor at a given point
pub fn new(
point: Point<T>,
coords: GenericArray<f64, Exp<T::Dimension, V::Rank>>
) -> Tensor<T, V>[src]
point: Point<T>,
coords: GenericArray<f64, Exp<T::Dimension, V::Rank>>
) -> Tensor<T, V>
Creates a tensor at a given point with the coordinates defined by the array.
The number of elements in the array must be equal to the number of coordinates of the tensor.
One-dimensional array represents an n-dimensional tensor in such a way, that the last index is the one that is changing the most often, i.e. the sequence is as follows: (0,0,...,0), (0,0,...,1), (0,0,...,2), ..., (0,0,...,1,0), (0,0,...,1,1), ... etc.
pub fn from_slice(point: Point<T>, slice: &[f64]) -> Tensor<T, V>[src]
Creates a tensor at a given point with the coordinates defined by the slice.
The number of elements in the slice must be equal to the number of coordinates of the tensor.
One-dimensional slice represents an n-dimensional tensor in such a way, that the last index is the one that is changing the most often, i.e. the sequence is as follows: (0,0,...,0), (0,0,...,1), (0,0,...,2), ..., (0,0,...,1,0), (0,0,...,1,1), ... etc.
pub fn trace<Ul, Uh>(&self) -> Tensor<T, Contracted<V, Ul, Uh>> where
Ul: Unsigned,
Uh: Unsigned,
V: Contract<Ul, Uh>,
<Contracted<V, Ul, Uh> as Variance>::Rank: ArrayLength<usize>,
T::Dimension: Pow<<Contracted<V, Ul, Uh> as Variance>::Rank>,
Exp<T::Dimension, <Contracted<V, Ul, Uh> as Variance>::Rank>: ArrayLength<f64>, [src]
Ul: Unsigned,
Uh: Unsigned,
V: Contract<Ul, Uh>,
<Contracted<V, Ul, Uh> as Variance>::Rank: ArrayLength<usize>,
T::Dimension: Pow<<Contracted<V, Ul, Uh> as Variance>::Rank>,
Exp<T::Dimension, <Contracted<V, Ul, Uh> as Variance>::Rank>: ArrayLength<f64>,
Contracts two indices
The indices must be of opposite types. This is checked at compile time.
impl<T, U> Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
U::Rank: ArrayLength<usize>,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
U::Rank: ArrayLength<usize>,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
pub fn iter_coords(&self) -> CoordIterator<U>[src]
Returns an iterator over the coordinates of the tensor.
impl<T, Ul, Ur> Tensor<T, (Ul, Ur)> where
T: CoordinateSystem,
Ul: TensorIndex + OtherIndex,
Ur: TensorIndex + OtherIndex,
Add1<Ul::Rank>: Unsigned + Add<B1>,
Add1<Ur::Rank>: Unsigned + Add<B1>,
Add1<<<Ul as OtherIndex>::Output as Variance>::Rank>: Unsigned + Add<B1>,
Add1<<<Ur as OtherIndex>::Output as Variance>::Rank>: Unsigned + Add<B1>,
<(Ul, Ur) as Variance>::Rank: ArrayLength<usize>,
T::Dimension: Pow<Add1<Ul::Rank>> + Pow<Add1<Ur::Rank>> + ArrayLength<usize>,
T::Dimension: Pow<Add1<<<Ul as OtherIndex>::Output as Variance>::Rank>>,
T::Dimension: Pow<Add1<<<Ur as OtherIndex>::Output as Variance>::Rank>>,
Exp<T::Dimension, Add1<Ul::Rank>>: ArrayLength<f64>,
Exp<T::Dimension, Add1<Ur::Rank>>: ArrayLength<f64>,
Exp<T::Dimension, Add1<<<Ul as OtherIndex>::Output as Variance>::Rank>>: ArrayLength<f64>,
Exp<T::Dimension, Add1<<<Ur as OtherIndex>::Output as Variance>::Rank>>: ArrayLength<f64>, [src]
T: CoordinateSystem,
Ul: TensorIndex + OtherIndex,
Ur: TensorIndex + OtherIndex,
Add1<Ul::Rank>: Unsigned + Add<B1>,
Add1<Ur::Rank>: Unsigned + Add<B1>,
Add1<<<Ul as OtherIndex>::Output as Variance>::Rank>: Unsigned + Add<B1>,
Add1<<<Ur as OtherIndex>::Output as Variance>::Rank>: Unsigned + Add<B1>,
<(Ul, Ur) as Variance>::Rank: ArrayLength<usize>,
T::Dimension: Pow<Add1<Ul::Rank>> + Pow<Add1<Ur::Rank>> + ArrayLength<usize>,
T::Dimension: Pow<Add1<<<Ul as OtherIndex>::Output as Variance>::Rank>>,
T::Dimension: Pow<Add1<<<Ur as OtherIndex>::Output as Variance>::Rank>>,
Exp<T::Dimension, Add1<Ul::Rank>>: ArrayLength<f64>,
Exp<T::Dimension, Add1<Ur::Rank>>: ArrayLength<f64>,
Exp<T::Dimension, Add1<<<Ul as OtherIndex>::Output as Variance>::Rank>>: ArrayLength<f64>,
Exp<T::Dimension, Add1<<<Ur as OtherIndex>::Output as Variance>::Rank>>: ArrayLength<f64>,
pub fn unit(p: Point<T>) -> Tensor<T, (Ul, Ur)>[src]
Returns a unit matrix (1 on the diagonal, 0 everywhere else)
pub fn transpose(&self) -> Tensor<T, (Ur, Ul)>[src]
Transposes the matrix
pub fn inverse(
&self
) -> Option<Tensor<T, (<Ul as OtherIndex>::Output, <Ur as OtherIndex>::Output)>>[src]
&self
) -> Option<Tensor<T, (<Ul as OtherIndex>::Output, <Ur as OtherIndex>::Output)>>
Function calculating the inverse of self using the LU ddecomposition.
The return value is an Option, since self may be non-invertible -
in such a case, None is returned
impl<T, U> Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
U::Rank: ArrayLength<usize>,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
U::Rank: ArrayLength<usize>,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
pub fn convert<T2>(&self) -> Tensor<T2, U> where
T2: CoordinateSystem + 'static,
T2::Dimension: Pow<U::Rank> + Pow<U2> + Same<T::Dimension>,
Exp<T2::Dimension, U::Rank>: ArrayLength<f64>,
Exp<T2::Dimension, U2>: ArrayLength<f64>,
T: ConversionTo<T2>, [src]
T2: CoordinateSystem + 'static,
T2::Dimension: Pow<U::Rank> + Pow<U2> + Same<T::Dimension>,
Exp<T2::Dimension, U::Rank>: ArrayLength<f64>,
Exp<T2::Dimension, U2>: ArrayLength<f64>,
T: ConversionTo<T2>,
Trait Implementations
impl<T, U, V, Ul, Uh> InnerProduct<Tensor<T, V>, Ul, Uh> for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
V: Variance,
Ul: Unsigned,
Uh: Unsigned,
T::Dimension: Pow<U::Rank> + Pow<V::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
Exp<T::Dimension, V::Rank>: ArrayLength<f64>,
U: Concat<V>,
Joined<U, V>: Contract<Ul, Uh>,
<Contracted<Joined<U, V>, Ul, Uh> as Variance>::Rank: ArrayLength<usize>,
T::Dimension: Pow<<Contracted<Joined<U, V>, Ul, Uh> as Variance>::Rank>,
Exp<T::Dimension, <Contracted<Joined<U, V>, Ul, Uh> as Variance>::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
V: Variance,
Ul: Unsigned,
Uh: Unsigned,
T::Dimension: Pow<U::Rank> + Pow<V::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
Exp<T::Dimension, V::Rank>: ArrayLength<f64>,
U: Concat<V>,
Joined<U, V>: Contract<Ul, Uh>,
<Contracted<Joined<U, V>, Ul, Uh> as Variance>::Rank: ArrayLength<usize>,
T::Dimension: Pow<<Contracted<Joined<U, V>, Ul, Uh> as Variance>::Rank>,
Exp<T::Dimension, <Contracted<Joined<U, V>, Ul, Uh> as Variance>::Rank>: ArrayLength<f64>,
type Output = Tensor<T, Contracted<Joined<U, V>, Ul, Uh>>
fn inner_product(
self,
rhs: Tensor<T, V>
) -> Tensor<T, Contracted<Joined<U, V>, Ul, Uh>>[src]
self,
rhs: Tensor<T, V>
) -> Tensor<T, Contracted<Joined<U, V>, Ul, Uh>>
impl<T, U> Copy for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
<T::Dimension as ArrayLength<f64>>::ArrayType: Copy,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
<Exp<T::Dimension, U::Rank> as ArrayLength<f64>>::ArrayType: Copy, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
<T::Dimension as ArrayLength<f64>>::ArrayType: Copy,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
<Exp<T::Dimension, U::Rank> as ArrayLength<f64>>::ArrayType: Copy,
impl<T, U> Clone for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
fn clone(&self) -> Tensor<T, U>[src]
default fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl<T, U> Add<Tensor<T, U>> for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
type Output = Tensor<T, U>
The resulting type after applying the + operator.
fn add(self, rhs: Tensor<T, U>) -> Tensor<T, U>[src]
impl<T, U> Sub<Tensor<T, U>> for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
type Output = Tensor<T, U>
The resulting type after applying the - operator.
fn sub(self, rhs: Tensor<T, U>) -> Tensor<T, U>[src]
impl<T, U> Mul<f64> for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
type Output = Tensor<T, U>
The resulting type after applying the * operator.
fn mul(self, rhs: f64) -> Tensor<T, U>[src]
impl<T, U> Mul<Tensor<T, U>> for f64 where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
type Output = Tensor<T, U>
The resulting type after applying the * operator.
fn mul(self, rhs: Tensor<T, U>) -> Tensor<T, U>[src]
impl<T, U, V> Mul<Tensor<T, V>> for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
V: Variance,
U::Rank: ArrayLength<usize>,
V::Rank: ArrayLength<usize>,
T::Dimension: Pow<U::Rank> + Pow<V::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
Exp<T::Dimension, V::Rank>: ArrayLength<f64>,
U: Concat<V>,
Joined<U, V>: Variance,
T::Dimension: Pow<<Joined<U, V> as Variance>::Rank>,
Exp<T::Dimension, <Joined<U, V> as Variance>::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
V: Variance,
U::Rank: ArrayLength<usize>,
V::Rank: ArrayLength<usize>,
T::Dimension: Pow<U::Rank> + Pow<V::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
Exp<T::Dimension, V::Rank>: ArrayLength<f64>,
U: Concat<V>,
Joined<U, V>: Variance,
T::Dimension: Pow<<Joined<U, V> as Variance>::Rank>,
Exp<T::Dimension, <Joined<U, V> as Variance>::Rank>: ArrayLength<f64>,
type Output = Tensor<T, Joined<U, V>>
The resulting type after applying the * operator.
fn mul(self, rhs: Tensor<T, V>) -> Tensor<T, Joined<U, V>>[src]
impl<T, U> Div<f64> for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
type Output = Tensor<T, U>
The resulting type after applying the / operator.
fn div(self, rhs: f64) -> Tensor<T, U>[src]
impl<'a, T, U> Index<&'a [usize]> for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
impl<'a, T, U> Index<usize> for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
impl<'a, T, U> IndexMut<&'a [usize]> for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
impl<'a, T, U> IndexMut<usize> for Tensor<T, U> where
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>, [src]
T: CoordinateSystem,
U: Variance,
T::Dimension: Pow<U::Rank>,
Exp<T::Dimension, U::Rank>: ArrayLength<f64>,
Auto Trait Implementations
impl<T, U> Send for Tensor<T, U> where
<T as CoordinateSystem>::Dimension: ArrayLength<f64>,
<T as CoordinateSystem>::Dimension: ArrayLength<f64>,
impl<T, U> Sync for Tensor<T, U> where
<T as CoordinateSystem>::Dimension: ArrayLength<f64>,
<T as CoordinateSystem>::Dimension: ArrayLength<f64>,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
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>,
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> Same for T
type Output = T
Should always be Self