pub struct ExprAdd<const N: usize, L: ExprTrait<N>, R: ExprTrait<N>> { /* private fields */ }Implementations§
Source§impl<const N: usize, L, R> ExprAdd<N, L, R>
impl<const N: usize, L, R> ExprAdd<N, L, R>
Trait Implementations§
Source§impl<const N: usize, L, R> ExprAddRecTrait for ExprAdd<N, L, R>
impl<const N: usize, L, R> ExprAddRecTrait for ExprAdd<N, L, R>
Source§impl<const N: usize, L, R> ExprTrait<N> for ExprAdd<N, L, R>
impl<const N: usize, L, R> ExprTrait<N> for ExprAdd<N, L, R>
Source§fn eval(
&self,
rs: &mut WorkStack,
ws: &mut WorkStack,
xs: &mut WorkStack,
) -> Result<(), ExprEvalError>
fn eval( &self, rs: &mut WorkStack, ws: &mut WorkStack, xs: &mut WorkStack, ) -> Result<(), ExprEvalError>
Evaluate the expression and put the result on the
rs stack,
using the ws to evaluate sub-expressions and xs for
general storage. The job of eval is to evaluate all sub-expressions and compute the
flattened expression from this (basically, coefficients and subscripts of the expression).
Upon return, the rs stack must hold the result of the evaluation.Source§fn eval_finalize(
&self,
rs: &mut WorkStack,
ws: &mut WorkStack,
xs: &mut WorkStack,
) -> Result<(), ExprEvalError>
fn eval_finalize( &self, rs: &mut WorkStack, ws: &mut WorkStack, xs: &mut WorkStack, ) -> Result<(), ExprEvalError>
Evaluate the expression, then clean it up and put
it on the
rs stack. The result will guarantee that Read moreSource§fn dynamic<'a>(self) -> ExprDynamic<'a, N>where
Self: Sized + 'a,
fn dynamic<'a>(self) -> ExprDynamic<'a, N>where
Self: Sized + 'a,
Create a dynamic expression from an expression. Expression types generally depend on the
types of all the sub-expressions, so it is not possible to make e.g. an array of
expressions unless they are exactly the same types. Wrapping each expression in a dynamic
expression allows us to create structures like arrays that requires all elements to have
the same type. The down-side is heap-allocated objects and that
eval() calls are dynamic. Read moreSource§fn axispermute(self, perm: &[usize; N]) -> ExprPermuteAxes<N, Self>where
Self: Sized,
fn axispermute(self, perm: &[usize; N]) -> ExprPermuteAxes<N, Self>where
Self: Sized,
Permute axes of the expression. Permute the index coordinates of each entry in the
expression, and similarly permute the shape. This is a generalized transpose operation, so
in two dimensions this is just a regular transpose. Read more
Source§fn sum(self) -> ExprSum<N, Self>where
Self: Sized,
fn sum(self) -> ExprSum<N, Self>where
Self: Sized,
Sum all elements in an expression producing a scalar expression.
Source§fn neg(self) -> ExprMulScalar<N, Self>where
Self: Sized,
fn neg(self) -> ExprMulScalar<N, Self>where
Self: Sized,
Negate coefficients of all elements in the expression.
Source§fn sum_on<const K: usize>(
self,
axes: &[usize; K],
) -> ExprReduceShape<N, K, ExprSumLastDims<N, ExprPermuteAxes<N, Self>>>where
Self: Sized,
fn sum_on<const K: usize>(
self,
axes: &[usize; K],
) -> ExprReduceShape<N, K, ExprSumLastDims<N, ExprPermuteAxes<N, Self>>>where
Self: Sized,
Sum over a number of axes, reducing the dimensionality of the expression. Read more
Source§fn add<RHS>(self, rhs: RHS) -> ExprAdd<N, Self, RHS::Result>
fn add<RHS>(self, rhs: RHS) -> ExprAdd<N, Self, RHS::Result>
Add an expression and an item that is addable to an expression, e.g. constants or other
expressions. Read more
Source§fn sub<RHS>(self, rhs: RHS) -> ExprAdd<N, Self, RHS::Result>
fn sub<RHS>(self, rhs: RHS) -> ExprAdd<N, Self, RHS::Result>
Subtract expression and an item that is addable to an expression, e.g. constants or other
expressions. Read more
fn dot<RHS>(self, rhs: RHS) -> RHS::Resultwhere
RHS: RightDottable<N, Self>,
Self: Sized,
Source§fn mul_elem<RHS>(self, other: RHS) -> RHS::Resultwhere
Self: Sized,
RHS: ExprRightElmMultipliable<N, Self>,
fn mul_elem<RHS>(self, other: RHS) -> RHS::Resultwhere
Self: Sized,
RHS: ExprRightElmMultipliable<N, Self>,
Element-wise multiplication of two operands. The operand shapes must be the same. Read more
Source§fn dot_rows<M>(self, other: M) -> ExprDotRows<Self>
fn dot_rows<M>(self, other: M) -> ExprDotRows<Self>
An expression that produces a vector of dot-products of the rows of the operands,
specifically,
[r_0,r_1,...] = [dot(e_{0,*},m_{0,*},dot(e_{1,*},m_{1,*},...], where e if
an expression and m is a matrix. The shapes of the operands must be identical. Read moreSource§fn vstack<E>(self, other: E) -> ExprStack<N, Self, E::Result>
fn vstack<E>(self, other: E) -> ExprStack<N, Self, E::Result>
Stack vertically, i.e. in first dimension. The two operands have the same number of
dimensions, and must have the same shapes except in the first dimension.
N must be
at least 1. Read moreSource§fn hstack<E>(self, other: E) -> ExprStack<N, Self, E::Result>
fn hstack<E>(self, other: E) -> ExprStack<N, Self, E::Result>
Stack horizontally, i.e. stack in second dimension. The two operands have the same number of
dimensions, and must have the same shapes except in the second dimension.
N must be at
least 2. Read moreSource§fn stack<E>(self, dim: usize, other: E) -> ExprStack<N, Self, E::Result>
fn stack<E>(self, dim: usize, other: E) -> ExprStack<N, Self, E::Result>
Stack in arbitrary dimension. The two operands have the same number of
dimensions, and must have the same shapes except in dimension
dim. N must be larger
than or equal to dim Read moreSource§fn repeat(self, dim: usize, num: usize) -> ExprRepeat<N, Self>where
Self: Sized,
fn repeat(self, dim: usize, num: usize) -> ExprRepeat<N, Self>where
Self: Sized,
Repeat a fixed number of times in the given dimension. Read more
Source§fn index<I>(self, idx: I) -> I::Outputwhere
I: ModelExprIndex<Self>,
Self: Sized,
fn index<I>(self, idx: I) -> I::Outputwhere
I: ModelExprIndex<Self>,
Self: Sized,
Indexing or slicing an expression. This is not compatible with
std::ops::Index since we
need to return a new object rather than a reference to an object, so sugary syntax is not
possible here. Read moreSource§fn reshape<const M: usize>(self, shape: &[usize; M]) -> ExprReshape<N, M, Self>where
Self: Sized,
fn reshape<const M: usize>(self, shape: &[usize; M]) -> ExprReshape<N, M, Self>where
Self: Sized,
Reshape the experssion. The new shape must match the old
shape, meaning that the product of the dimensions are the
same. The function will panic if operand shapes do not match. Read more
Source§fn into_symmetric(self, dim: usize) -> ExprIntoSymmetric<N, Self>where
Self: Sized,
fn into_symmetric(self, dim: usize) -> ExprIntoSymmetric<N, Self>where
Self: Sized,
Create an expression that is symmetric in dimension
dim and dim+1. The shape must
satisfy the following: Read moreSource§fn flatten(self) -> ExprReshapeOneRow<N, 1, Self>where
Self: Sized,
fn flatten(self) -> ExprReshapeOneRow<N, 1, Self>where
Self: Sized,
Flatten the expression into a vector. Preserve sparsity. Read more
Source§fn into_column(self) -> ExprReshapeOneRow<N, 2, Self>where
Self: Sized,
fn into_column(self) -> ExprReshapeOneRow<N, 2, Self>where
Self: Sized,
Flatten expression into a column, i.e. an expression of size
[n,1] where
n=shape.iter().product(). Read moreSource§fn into_vec<const M: usize>(self, i: usize) -> ExprReshapeOneRow<N, M, Self>
fn into_vec<const M: usize>(self, i: usize) -> ExprReshapeOneRow<N, M, Self>
Reshape an expression into a vector expression, where all but (at most) one dimension are
of size 1. Read more
Source§fn gather(self) -> ExprGatherToVec<N, Self>where
Self: Sized,
fn gather(self) -> ExprGatherToVec<N, Self>where
Self: Sized,
Reshape a sparse expression into a dense expression vector. The length of the vector
cannot be known until the expression is evaluated.
Source§fn map<const M: usize, F>(
self,
shape: &[usize; M],
f: F,
) -> ExprMap<N, M, F, Self>
fn map<const M: usize, F>( self, shape: &[usize; M], f: F, ) -> ExprMap<N, M, F, Self>
Map each nonzero to a new position in an expression with a new shape. Read more
Source§fn flip(self, dims: &[bool; N]) -> ExprFlip<N, Self>where
Self: Sized,
fn flip(self, dims: &[bool; N]) -> ExprFlip<N, Self>where
Self: Sized,
Flip elements in a subset of dimensions. Read more
Source§fn mul<RHS>(self, other: RHS) -> RHS::Resultwhere
Self: Sized,
RHS: ExprRightMultipliable<N, Self>,
fn mul<RHS>(self, other: RHS) -> RHS::Resultwhere
Self: Sized,
RHS: ExprRightMultipliable<N, Self>,
Source§fn rev_mul<LHS>(self, lhs: LHS) -> LHS::Resultwhere
Self: Sized,
LHS: ExprLeftMultipliable<N, Self>,
fn rev_mul<LHS>(self, lhs: LHS) -> LHS::Resultwhere
Self: Sized,
LHS: ExprLeftMultipliable<N, Self>,
Source§fn transpose(self) -> ExprPermuteAxes<2, Self>
fn transpose(self) -> ExprPermuteAxes<2, Self>
Transpose a two-dimensional expression. Read more
Source§fn tril(self, with_diag: bool) -> ExprTriangularPart<Self>
fn tril(self, with_diag: bool) -> ExprTriangularPart<Self>
Create a new expression with only lower triangular nonzeros from the operand. Read more
Source§fn triu(self, with_diag: bool) -> ExprTriangularPart<Self>
fn triu(self, with_diag: bool) -> ExprTriangularPart<Self>
Create a new expression with only upper triangular nonzeros from the operand. Read more
Source§fn trilvec(
self,
with_diag: bool,
) -> ExprGatherToVec<2, ExprTriangularPart<Self>>
fn trilvec( self, with_diag: bool, ) -> ExprGatherToVec<2, ExprTriangularPart<Self>>
create a new expression with only lower triangular nonzeros from the operand put into a
vector in row-order. Read more
Source§fn triuvec(
self,
with_diag: bool,
) -> ExprGatherToVec<2, ExprTriangularPart<Self>>
fn triuvec( self, with_diag: bool, ) -> ExprGatherToVec<2, ExprTriangularPart<Self>>
Create a new expression with only upper triangular nonzeros from the operand. Read more
Source§fn diag(self) -> ExprDiag<Self>
fn diag(self) -> ExprDiag<Self>
Take the diagonal elements if a square matrix and return it as a new vector expression.
Source§fn square_diag(self) -> ExprSquareDiag<Self>
fn square_diag(self) -> ExprSquareDiag<Self>
Create a sparse square matrix with the vector expression elements as diagonal.
Source§fn mul_any_scalar(self, c: f64) -> ExprMulScalar<N, Self>where
Self: Sized,
fn mul_any_scalar(self, c: f64) -> ExprMulScalar<N, Self>where
Self: Sized,
Internal. Should normally not be called directly. Read more
Source§fn mul_matrix_const_matrix<M>(self, m: &M) -> ExprMulRight<Self>
fn mul_matrix_const_matrix<M>(self, m: &M) -> ExprMulRight<Self>
Internal. Should normally not be called directly. Read more
Source§fn mul_rev_matrix_const_matrix<M>(self, m: &M) -> ExprMulLeft<Self>
fn mul_rev_matrix_const_matrix<M>(self, m: &M) -> ExprMulLeft<Self>
Internal. Should normally not be called directly. Read more
Source§fn mul_matrix_vec(
self,
v: Vec<f64>,
) -> ExprReshapeOneRow<2, 1, ExprMulRight<Self>>
fn mul_matrix_vec( self, v: Vec<f64>, ) -> ExprReshapeOneRow<2, 1, ExprMulRight<Self>>
Internal. Should normally not be called directly. Read more
Source§fn mul_rev_matrix_vec(
self,
v: Vec<f64>,
) -> ExprReshapeOneRow<2, 1, ExprMulLeft<Self>>
fn mul_rev_matrix_vec( self, v: Vec<f64>, ) -> ExprReshapeOneRow<2, 1, ExprMulLeft<Self>>
Internal. Should normally not be called directly. Read more
Source§fn mul_vec_matrix<M>(
self,
m: &M,
) -> ExprReshapeOneRow<2, 1, ExprMulRight<ExprReshapeOneRow<1, 2, Self>>>
fn mul_vec_matrix<M>( self, m: &M, ) -> ExprReshapeOneRow<2, 1, ExprMulRight<ExprReshapeOneRow<1, 2, Self>>>
Internal. Should normally not be called directly.
Source§fn mul_rev_vec_matrix<M>(
self,
m: &M,
) -> ExprReshapeOneRow<2, 1, ExprMulRight<ExprReshapeOneRow<1, 2, Self>>>
fn mul_rev_vec_matrix<M>( self, m: &M, ) -> ExprReshapeOneRow<2, 1, ExprMulRight<ExprReshapeOneRow<1, 2, Self>>>
Internal. Should normally not be called directly.
Source§fn mul_scalar_matrix<M>(
self,
m: &M,
) -> ExprReshape<1, 2, ExprMulElm<1, ExprRepeat<1, ExprReshape<0, 1, Self>>>>
fn mul_scalar_matrix<M>( self, m: &M, ) -> ExprReshape<1, 2, ExprMulElm<1, ExprRepeat<1, ExprReshape<0, 1, Self>>>>
Internal. Should normally not be called directly.
Auto Trait Implementations§
impl<const N: usize, L, R> Freeze for ExprAdd<N, L, R>
impl<const N: usize, L, R> RefUnwindSafe for ExprAdd<N, L, R>where
L: RefUnwindSafe,
R: RefUnwindSafe,
impl<const N: usize, L, R> Send for ExprAdd<N, L, R>
impl<const N: usize, L, R> Sync for ExprAdd<N, L, R>
impl<const N: usize, L, R> Unpin for ExprAdd<N, L, R>
impl<const N: usize, L, R> UnwindSafe for ExprAdd<N, L, R>where
L: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more