| 357 pub fn new() -> Self { |
357 pub fn new() -> Self { |
| 358 Norm222(PhantomData) |
358 Norm222(PhantomData) |
| 359 } |
359 } |
| 360 } |
360 } |
| 361 |
361 |
| 362 impl<X: Euclidean<F>, F: Float> Mapping<X> for Norm222<F> { |
362 impl<X: Euclidean<Field = F>, F: Float> Mapping<X> for Norm222<F> { |
| 363 type Codomain = F; |
363 type Codomain = F; |
| 364 |
364 |
| 365 /// Compute the value of `self` at `x`. |
365 /// Compute the value of `self` at `x`. |
| 366 fn apply<I: Instance<X>>(&self, x: I) -> Self::Codomain { |
366 fn apply<I: Instance<X>>(&self, x: I) -> Self::Codomain { |
| 367 x.eval(|z| z.norm2_squared() / F::TWO) |
367 x.eval(|z| z.norm2_squared() / F::TWO) |
| 368 } |
368 } |
| 369 } |
369 } |
| 370 |
370 |
| 371 impl<X: Euclidean<F>, F: Float> ConvexMapping<X, F> for Norm222<F> { |
371 impl<X: Euclidean<Field = F>, F: Float> ConvexMapping<X, F> for Norm222<F> { |
| 372 fn factor_of_strong_convexity(&self) -> F { |
372 fn factor_of_strong_convexity(&self) -> F { |
| 373 F::ONE |
373 F::ONE |
| 374 } |
374 } |
| 375 } |
375 } |
| 376 |
376 |
| 377 impl<X: Euclidean<F>, F: Float> Conjugable<X, F> for Norm222<F> { |
377 impl<X: Euclidean<Field = F>, F: Float> Conjugable<X, F> for Norm222<F> { |
| 378 type Conjugate<'a> |
378 type Conjugate<'a> |
| 379 = Self |
379 = Self |
| 380 where |
380 where |
| 381 Self: 'a; |
381 Self: 'a; |
| 382 |
382 |
| 426 } |
426 } |
| 427 |
427 |
| 428 impl<X, F> LipschitzDifferentiableImpl<X, L2> for Norm222<F> |
428 impl<X, F> LipschitzDifferentiableImpl<X, L2> for Norm222<F> |
| 429 where |
429 where |
| 430 F: Float, |
430 F: Float, |
| 431 X: Euclidean<F, Output = X>, |
431 X: Euclidean<Field = F, Output = X>, |
| 432 { |
432 { |
| 433 type FloatType = F; |
433 type FloatType = F; |
| 434 |
434 |
| 435 fn diff_lipschitz_factor(&self, _: L2) -> DynResult<Self::FloatType> { |
435 fn diff_lipschitz_factor(&self, _: L2) -> DynResult<Self::FloatType> { |
| 436 Ok(F::ONE) |
436 Ok(F::ONE) |