src/norms.rs

branch
dev
changeset 151
402d717bb5c0
parent 150
c4e394a9c84c
child 163
b4a47e8e80d1
equal deleted inserted replaced
150:c4e394a9c84c 151:402d717bb5c0
2 Norms, projections, etc. 2 Norms, projections, etc.
3 */ 3 */
4 4
5 use crate::euclidean::*; 5 use crate::euclidean::*;
6 use crate::instance::Ownable; 6 use crate::instance::Ownable;
7 use crate::linops::VectorSpace; 7 use crate::linops::{ClosedVectorSpace, VectorSpace};
8 use crate::mapping::{Instance, Mapping, Space}; 8 use crate::mapping::{Instance, Mapping, Space};
9 use crate::types::*; 9 use crate::types::*;
10 use serde::{Deserialize, Serialize}; 10 use serde::{Deserialize, Serialize};
11 use std::marker::PhantomData; 11 use std::marker::PhantomData;
12 12
227 self.norm_() == F::ZERO 227 self.norm_() == F::ZERO
228 } 228 }
229 } 229 }
230 230
231 pub trait HasDual<F: Num = f64>: Normed<F> + VectorSpace<Field = F> { 231 pub trait HasDual<F: Num = f64>: Normed<F> + VectorSpace<Field = F> {
232 type DualSpace: Normed<F> + VectorSpace<Field = F>; 232 type DualSpace: Normed<F> + ClosedVectorSpace<Field = F>;
233 233
234 fn dual_origin(&self) -> <Self::DualSpace as VectorSpace>::Owned; 234 fn dual_origin(&self) -> <Self::DualSpace as VectorSpace>::Owned;
235 } 235 }
236 236
237 /// Automatically implemented trait for reflexive spaces 237 /// Automatically implemented trait for reflexive spaces
238 pub trait Reflexive<F: Num = f64>: HasDual<F> 238 pub trait Reflexive<F: Num = f64>: HasDual<F>
239 where 239 where
240 Self::DualSpace: HasDual<F, DualSpace = Self>, 240 Self::DualSpace: HasDual<F, DualSpace = Self::OwnedSpace>,
241 { 241 {
242 } 242 }
243 243
244 impl<F: Num, X: HasDual<F>> Reflexive<F> for X where X::DualSpace: HasDual<F, DualSpace = X> {} 244 impl<F: Num, X: HasDual<F>> Reflexive<F> for X where
245 X::DualSpace: HasDual<F, DualSpace = Self::OwnedSpace>
246 {
247 }
245 248
246 pub trait HasDualExponent: NormExponent { 249 pub trait HasDualExponent: NormExponent {
247 type DualExp: NormExponent; 250 type DualExp: NormExponent;
248 251
249 fn dual_exponent(&self) -> Self::DualExp; 252 fn dual_exponent(&self) -> Self::DualExp;

mercurial