src/mapping.rs

branch
dev
changeset 68
c5f70e767511
parent 61
05089fbc0310
child 69
e5fab0125a8e
child 80
f802ddbabcfc
equal deleted inserted replaced
67:d7c0f431cbd6 68:c5f70e767511
2 Traits for mathematical functions. 2 Traits for mathematical functions.
3 */ 3 */
4 4
5 use std::marker::PhantomData; 5 use std::marker::PhantomData;
6 use std::borrow::Cow; 6 use std::borrow::Cow;
7 use crate::types::{Num, Float}; 7 use crate::types::{Num, Float, ClosedMul};
8 use serde::Serialize;
9 use crate::loc::Loc; 8 use crate::loc::Loc;
10 pub use crate::instance::{Instance, Decomposition, BasicDecomposition, Space}; 9 pub use crate::instance::{Instance, Decomposition, BasicDecomposition, Space};
11 use crate::norms::{Norm, NormExponent}; 10 use crate::norms::{Norm, NormExponent};
12 11
13 /// A mapping from `Domain` to `Codomain`. 12 /// A mapping from `Domain` to `Codomain`.
43 Domain : Norm<F, E>, 42 Domain : Norm<F, E>,
44 F : Num 43 F : Num
45 { 44 {
46 Composition{ outer : self, inner : other, intermediate_norm_exponent : norm } 45 Composition{ outer : self, inner : other, intermediate_norm_exponent : norm }
47 } 46 }
47
48 /// Multiply `self` by the scalar `a`.
49 #[inline]
50 fn weigh<C>(self, a : C) -> Weighted<Self, C>
51 where
52 Self : Sized,
53 C : Constant,
54 Self::Codomain : ClosedMul<C::Type>,
55 {
56 Weighted { weight : a, base_fn : self }
57 }
48 } 58 }
49 59
50 /// Automatically implemented shorthand for referring to [`Mapping`]s from [`Loc<F, N>`] to `F`. 60 /// Automatically implemented shorthand for referring to [`Mapping`]s from [`Loc<F, N>`] to `F`.
51 pub trait RealMapping<F : Float, const N : usize> 61 pub trait RealMapping<F : Float, const N : usize>
52 : Mapping<Loc<F, N>, Codomain = F> {} 62 : Mapping<Loc<F, N>, Codomain = F> {}

mercurial