src/mapping.rs

branch
dev
changeset 75
e9f4550cfa18
parent 69
e5fab0125a8e
equal deleted inserted replaced
74:2c76df38d02b 75:e9f4550cfa18
6 use std::borrow::Cow; 6 use std::borrow::Cow;
7 use crate::types::{Num, Float, ClosedMul}; 7 use crate::types::{Num, Float, ClosedMul};
8 use crate::loc::Loc; 8 use crate::loc::Loc;
9 pub use crate::instance::{Instance, Decomposition, BasicDecomposition, Space}; 9 pub use crate::instance::{Instance, Decomposition, BasicDecomposition, Space};
10 use crate::norms::{Norm, NormExponent}; 10 use crate::norms::{Norm, NormExponent};
11 11 use crate::operator_arithmetic::{Weighted, Constant};
12 /// A mapping from `Domain` to `Codomain`. 12
13 /// 13 /// A mapping from `Domain` to `Self::Codomain`.
14 /// This is automatically implemented when the relevant [`Apply`] are implemented.
15 pub trait Mapping<Domain : Space> { 14 pub trait Mapping<Domain : Space> {
16 type Codomain : Space; 15 type Codomain : Space;
17 16
18 /// Compute the value of `self` at `x`. 17 /// Compute the value of `self` at `x`.
19 fn apply<I : Instance<Domain>>(&self, x : I) -> Self::Codomain; 18 fn apply<I : Instance<Domain>>(&self, x : I) -> Self::Codomain;
126 Differential{ g : Cow::Borrowed(self), _space : PhantomData } 125 Differential{ g : Cow::Borrowed(self), _space : PhantomData }
127 } 126 }
128 } 127 }
129 128
130 129
131 /// Container for the differential [`Mapping`] of a [`Differentiable`] mapping. 130 /// Container for the differential [`Mapping`] of a [`DifferentiableMapping`].
132 pub struct Differential<'a, X, G : Clone> { 131 pub struct Differential<'a, X, G : Clone> {
133 g : Cow<'a, G>, 132 g : Cow<'a, G>,
134 _space : PhantomData<X> 133 _space : PhantomData<X>
135 } 134 }
136 135

mercurial