Skip to main content

UnitCallable

Struct UnitCallable 

Source
pub struct UnitCallable<M: Matrix> { /* private fields */ }
Expand description

A dummy operator that returns the input vector. Can be used either as a NonLinearOp or LinearOp.

Implementations§

Source§

impl<M: Matrix> UnitCallable<M>

Source

pub fn new(n: usize, ctx: M::C) -> Self

Trait Implementations§

Source§

impl<M: Matrix> BuilderOp for UnitCallable<M>

Source§

fn calculate_sparsity(&mut self, _y0: &Self::V, _t0: Self::T, _p: &Self::V)

Source§

fn set_nout(&mut self, nout: usize)

Source§

fn set_nparams(&mut self, _nparams: usize)

Source§

fn set_nstates(&mut self, nstates: usize)

Source§

impl<M: Matrix> Default for UnitCallable<M>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<M: Matrix> LinearOp for UnitCallable<M>

Source§

fn gemv_inplace(&self, x: &Self::V, _t: Self::T, beta: Self::T, y: &mut Self::V)

Compute the operator via a GEMV operation (i.e. y = A(t) * x + beta * y)
Source§

fn call_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::V)

Compute the operator y = A(t) * x at a given state and time, the default implementation uses Self::gemv_inplace.
Source§

fn matrix(&self, t: Self::T) -> Self::M

Compute the matrix representation of the operator A(t) and return it. See Self::matrix_inplace for a non-allocating version.
Source§

fn matrix_inplace(&self, t: Self::T, y: &mut Self::M)

Compute the matrix representation of the operator A(t) and store it in the matrix y. The default implementation of this method computes the matrix using Self::gemv_inplace, but it can be overriden for more efficient implementations.
Source§

fn _default_matrix_inplace(&self, t: Self::T, y: &mut Self::M)

Default implementation of the matrix computation, see Self::matrix_inplace.
Source§

fn sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity>

Source§

impl<M: Matrix> LinearOpSens for UnitCallable<M>

Source§

fn sens_mul_inplace( &self, _x: &Self::V, _t: Self::T, _v: &Self::V, y: &mut Self::V, )

Compute the product of the gradient of F wrt a parameter vector p with a given vector J_p(t) * x * v. Note that the vector v is of size nparams() and the result is of size nstates(). Default implementation returns zero and panics if nparams() is not zero.
Source§

fn sens_mul(&self, x: &Self::V, t: Self::T, v: &Self::V) -> Self::V

Compute the product of the partial gradient of F wrt a parameter vector p with a given vector \parial F/\partial p(x, t) * v, and return the result. Use [Self::sens_mul_inplace] to for a non-allocating version.
Source§

fn sens_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::M)

Compute the gradient of the operator wrt a parameter vector p and store it in the matrix y. y should have been previously initialised using the output of Self::sens_sparsity. The default implementation of this method computes the gradient using Self::sens_mul_inplace, but it can be overriden for more efficient implementations.
Source§

fn _default_sens_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::M)

Default implementation of the gradient computation (this is the default for Self::sens_inplace).
Source§

fn sens(&self, x: &Self::V, t: Self::T) -> Self::M

Compute the gradient of the operator wrt a parameter vector p and return it. See Self::sens_inplace for a non-allocating version.
Source§

fn sens_sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity>

Source§

impl<M: Matrix> LinearOpTranspose for UnitCallable<M>

Source§

fn gemv_transpose_inplace( &self, x: &Self::V, _t: Self::T, beta: Self::T, y: &mut Self::V, )

Compute the transpose of the operator via a GEMV operation (i.e. y = A(t)^T * x + beta * y)
Source§

fn call_transpose_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::V)

Compute the transpose of the operator y = A(t)^T * x at a given state and time, the default implementation uses Self::gemv_transpose_inplace.
Source§

fn transpose_inplace(&self, t: Self::T, y: &mut Self::M)

Compute the matrix representation of the transpose of the operator A(t)^T and store it in the matrix y. The default implementation of this method computes the matrix using Self::gemv_transpose_inplace, but it can be overriden for more efficient implementations.
Source§

fn _default_transpose_inplace(&self, t: Self::T, y: &mut Self::M)

Default implementation of the tranpose computation, see Self::transpose_inplace.
Source§

fn transpose_sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity>

Source§

impl<M: Matrix> NonLinearOp for UnitCallable<M>

Source§

fn call_inplace(&self, x: &Self::V, _t: Self::T, y: &mut Self::V)

Compute the operator F(x, t) at a given state and time.
Source§

fn call(&self, x: &Self::V, t: Self::T) -> Self::V

Compute the operator F(x, t) at a given state and time, and return the result. Use [Self::call_inplace] to for a non-allocating version.
Source§

impl<M: Matrix> NonLinearOpAdjoint for UnitCallable<M>

Source§

fn jac_transpose_mul_inplace( &self, _x: &Self::V, _t: Self::T, v: &Self::V, y: &mut Self::V, )

Compute the product of the transpose of the Jacobian with a given vector -J(x, t)^T * v. The default implementation fails with a panic, as this method is not implemented by default and should be implemented by the user if needed.
Source§

fn adjoint_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::M)

Compute the Adjoint matrix -J^T(x, t) of the operator and store it in the matrix y. y should have been previously initialised using the output of Self::adjoint_sparsity. The default implementation of this method computes the Jacobian using Self::jac_transpose_mul_inplace, but it can be overriden for more efficient implementations.
Source§

fn _default_adjoint_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::M)

Default implementation of the Adjoint computation (this is the default for Self::adjoint_inplace).
Source§

fn adjoint(&self, x: &Self::V, t: Self::T) -> Self::M

Compute the Adjoint matrix -J^T(x, t) of the operator and return it. See Self::adjoint_inplace for a non-allocating version.
Source§

fn adjoint_sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity>

Return sparsity information (if available)
Source§

impl<M: Matrix> NonLinearOpJacobian for UnitCallable<M>

Source§

fn jac_mul_inplace( &self, _x: &Self::V, _t: Self::T, v: &Self::V, y: &mut Self::V, )

Compute the product of the Jacobian with a given vector J(x, t) * v.
Source§

fn jac_mul(&self, x: &Self::V, t: Self::T, v: &Self::V) -> Self::V

Compute the product of the Jacobian with a given vector J(x, t) * v, and return the result. Use [Self::jac_mul_inplace] to for a non-allocating version.
Source§

fn jacobian(&self, x: &Self::V, t: Self::T) -> Self::M

Compute the Jacobian matrix J(x, t) of the operator and return it. See Self::jacobian_inplace for a non-allocating version.
Source§

fn jacobian_sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity>

Return sparsity information (if available)
Source§

fn jacobian_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::M)

Compute the Jacobian matrix J(x, t) of the operator and store it in the matrix y. y should have been previously initialised using the output of Self::jacobian_sparsity. The default implementation of this method computes the Jacobian using Self::jac_mul_inplace, but it can be overriden for more efficient implementations.
Source§

fn _default_jacobian_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::M)

Default implementation of the Jacobian computation (this is the default for Self::jacobian_inplace).
Source§

impl<M: Matrix> NonLinearOpSens for UnitCallable<M>

Source§

fn sens_mul_inplace( &self, _x: &Self::V, _t: Self::T, _v: &Self::V, y: &mut Self::V, )

Compute the product of the gradient of F wrt a parameter vector p with a given vector J_p(x, t) * v. Note that the vector v is of size nparams() and the result is of size nstates().
Source§

fn sens_mul(&self, x: &Self::V, t: Self::T, v: &Self::V) -> Self::V

Compute the product of the partial gradient of F wrt a parameter vector p with a given vector \parial F/\partial p(x, t) * v, and return the result. Use [Self::sens_mul_inplace] to for a non-allocating version.
Source§

fn sens_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::M)

Compute the gradient of the operator wrt a parameter vector p and store it in the matrix y. y should have been previously initialised using the output of Self::sens_sparsity. The default implementation of this method computes the gradient using Self::sens_mul_inplace, but it can be overriden for more efficient implementations.
Source§

fn _default_sens_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::M)

Default implementation of the gradient computation (this is the default for Self::sens_inplace).
Source§

fn sens(&self, x: &Self::V, t: Self::T) -> Self::M

Compute the gradient of the operator wrt a parameter vector p and return it. See Self::sens_inplace for a non-allocating version.
Source§

fn sens_sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity>

Source§

impl<M: Matrix> NonLinearOpSensAdjoint for UnitCallable<M>

Source§

fn sens_transpose_mul_inplace( &self, _x: &Self::V, _t: Self::T, _v: &Self::V, y: &mut Self::V, )

Compute the product of the negative tramspose of the gradient of F wrt a parameter vector p with a given vector -J_p(x, t)^T * v.
Source§

fn sens_adjoint(&self, x: &Self::V, t: Self::T) -> Self::M

Compute the negative transpose of the gradient of the operator wrt a parameter vector p and return it. See Self::sens_adjoint_inplace for a non-allocating version.
Source§

fn sens_adjoint_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::M)

Compute the negative transpose of the gradient of the operator wrt a parameter vector p and store it in the matrix y. y should have been previously initialised using the output of Self::sens_adjoint_sparsity. The default implementation of this method computes the gradient using Self::sens_transpose_mul_inplace, but it can be overriden for more efficient implementations.
Source§

fn _default_sens_adjoint_inplace( &self, x: &Self::V, t: Self::T, y: &mut Self::M, )

Default implementation of the gradient computation (this is the default for Self::sens_adjoint_inplace).
Source§

fn sens_adjoint_sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity>

Source§

impl<M: Matrix> Op for UnitCallable<M>

Source§

type T = <M as MatrixCommon>::T

Source§

type V = <M as MatrixCommon>::V

Source§

type M = M

Source§

type C = <M as MatrixCommon>::C

Source§

fn nstates(&self) -> usize

Return the number of input states of the operator.
Source§

fn nout(&self) -> usize

Return the number of outputs of the operator.
Source§

fn nparams(&self) -> usize

Return the number of parameters of the operator.
Source§

fn context(&self) -> &Self::C

return the context of the operator
Source§

fn statistics(&self) -> OpStatistics

Return statistics about the operator (e.g. how many times it was called, how many times the jacobian was computed, etc.)

Auto Trait Implementations§

§

impl<M> Freeze for UnitCallable<M>
where <M as MatrixCommon>::C: Freeze,

§

impl<M> RefUnwindSafe for UnitCallable<M>
where <M as MatrixCommon>::C: RefUnwindSafe,

§

impl<M> Send for UnitCallable<M>
where <M as MatrixCommon>::C: Send,

§

impl<M> Sync for UnitCallable<M>
where <M as MatrixCommon>::C: Sync,

§

impl<M> Unpin for UnitCallable<M>
where <M as MatrixCommon>::C: Unpin,

§

impl<M> UnsafeUnpin for UnitCallable<M>
where <M as MatrixCommon>::C: UnsafeUnpin,

§

impl<M> UnwindSafe for UnitCallable<M>
where <M as MatrixCommon>::C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,