| 14 use alg_tools::convex::{Conjugable, Prox, Zero}; |
14 use alg_tools::convex::{Conjugable, Prox, Zero}; |
| 15 use alg_tools::direct_product::Pair; |
15 use alg_tools::direct_product::Pair; |
| 16 use alg_tools::error::DynResult; |
16 use alg_tools::error::DynResult; |
| 17 use alg_tools::euclidean::ClosedEuclidean; |
17 use alg_tools::euclidean::ClosedEuclidean; |
| 18 use alg_tools::iterate::AlgIteratorFactory; |
18 use alg_tools::iterate::AlgIteratorFactory; |
| 19 use alg_tools::linops::{BoundedLinear, IdOp, SimplyAdjointable, Space, ZeroOp, AXPY, GEMV}; |
19 use alg_tools::linops::{ |
| |
20 BoundedLinear, IdOp, SimplyAdjointable, Space, StaticEuclideanOriginGenerator, ZeroOp, AXPY, |
| |
21 GEMV, |
| |
22 }; |
| 20 use alg_tools::mapping::{DifferentiableMapping, Instance}; |
23 use alg_tools::mapping::{DifferentiableMapping, Instance}; |
| 21 use alg_tools::nalgebra_support::ToNalgebraRealField; |
24 use alg_tools::nalgebra_support::ToNalgebraRealField; |
| 22 use alg_tools::norms::L2; |
25 use alg_tools::norms::L2; |
| 23 use anyhow::ensure; |
26 use anyhow::ensure; |
| 24 use measures::DeltaMeasure; |
27 use measures::DeltaMeasure; |
| 114 fnR: &R, |
117 fnR: &R, |
| 115 fnH: &H, |
118 fnH: &H, |
| 116 domain: &mut impl AdmissibleDomain<U>, |
119 domain: &mut impl AdmissibleDomain<U>, |
| 117 ) -> DynResult<MeasureZ<F, Z, U>> |
120 ) -> DynResult<MeasureZ<F, Z, U>> |
| 118 where |
121 where |
| |
122 F: Float + ToNalgebraRealField, |
| 119 U: Space + Clone, |
123 U: Space + Clone, |
| 120 F: Float + ToNalgebraRealField, |
|
| 121 I: AlgIteratorFactory<IterInfo<F>>, |
124 I: AlgIteratorFactory<IterInfo<F>>, |
| 122 Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
125 Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
| 123 //Pair<S, Z>: ClosedMul<F>, // Doesn't really need to be closed, if make this signature more complex… |
|
| 124 S: ClosedMul<F>, |
126 S: ClosedMul<F>, |
| |
127 for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
| 125 DiscreteMeasure<U, F>: SpikeMerging<F>, |
128 DiscreteMeasure<U, F>: SpikeMerging<F>, |
| 126 Reg: RegTerm<U, F>, |
129 Reg: RegTerm<U, F>, |
| 127 P: ProxPenalty<U, S, Reg, F>, |
130 P: ProxPenalty<U, S, Reg, F>, |
| 128 for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
| 129 KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
131 KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
| 130 + GEMV<F, Z, Y> |
132 + GEMV<F, Z> |
| 131 + SimplyAdjointable<Z, Y, Codomain = Y, AdjointCodomain = Z>, |
133 + SimplyAdjointable<Z, Y, AdjointCodomain = Z>, |
| 132 KOpZ::SimpleAdjoint: GEMV<F, Y, Z>, |
134 KOpZ::SimpleAdjoint: GEMV<F, Y>, |
| 133 Y: ClosedEuclidean<F>, |
135 Y: ClosedEuclidean<F>, |
| 134 for<'b> &'b Y: Instance<Y>, |
136 for<'b> &'b Y: Instance<Y>, |
| 135 Z: ClosedEuclidean<F> + AXPY, |
137 Z: ClosedEuclidean<F> + AXPY, |
| 136 for<'b> &'b Z: Instance<Z>, |
138 for<'b> &'b Z: Instance<Z>, |
| 137 R: Prox<Z, Codomain = F>, |
139 R: Prox<Z, Codomain = F>, |
| 345 opKz: &KOpZ, |
347 opKz: &KOpZ, |
| 346 fnR: &R, |
348 fnR: &R, |
| 347 fnH: &H, |
349 fnH: &H, |
| 348 ) -> DynResult<MeasureZ<F, Z, U>> |
350 ) -> DynResult<MeasureZ<F, Z, U>> |
| 349 where |
351 where |
| |
352 F: Float + ToNalgebraRealField, |
| 350 U: Space + Clone, |
353 U: Space + Clone, |
| 351 F: Float + ToNalgebraRealField, |
354 //for<'a> &'a U: Instance<U>, |
| 352 I: AlgIteratorFactory<IterInfo<F>>, |
355 I: AlgIteratorFactory<IterInfo<F>>, |
| 353 Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
356 Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
| 354 //Pair<S, Z>: ClosedMul<F>, // Doesn't really need to be closed, if make this signature more complex… |
|
| 355 S: ClosedMul<F>, |
357 S: ClosedMul<F>, |
| |
358 for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
| |
359 //Pair<S, Z>: ClosedMul<F>, |
| 356 DiscreteMeasure<U, F>: SpikeMerging<F>, |
360 DiscreteMeasure<U, F>: SpikeMerging<F>, |
| 357 Reg: RegTerm<U, F>, |
361 Reg: RegTerm<U, F>, |
| 358 P: ProxPenalty<U, S, Reg, F>, |
362 P: ProxPenalty<U, S, Reg, F>, |
| 359 for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
| 360 KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
363 KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
| 361 + GEMV<F, Z, Y> |
364 + GEMV<F, Z> |
| 362 + SimplyAdjointable<Z, Y, Codomain = Y, AdjointCodomain = Z>, |
365 + SimplyAdjointable<Z, Y, AdjointCodomain = Z>, |
| 363 KOpZ::SimpleAdjoint: GEMV<F, Y, Z>, |
366 KOpZ::SimpleAdjoint: GEMV<F, Y>, |
| 364 Y: ClosedEuclidean<F>, |
367 Y: ClosedEuclidean<F>, |
| 365 for<'b> &'b Y: Instance<Y>, |
368 for<'b> &'b Y: Instance<Y>, |
| 366 Z: ClosedEuclidean<F> + AXPY, |
369 Z: ClosedEuclidean<F> + AXPY, |
| 367 for<'b> &'b Z: Instance<Z>, |
370 for<'b> &'b Z: Instance<Z>, |
| 368 R: Prox<Z, Codomain = F>, |
371 R: Prox<Z, Codomain = F>, |
| 402 //opKμ : KOpM, |
405 //opKμ : KOpM, |
| 403 fnR: &R, |
406 fnR: &R, |
| 404 domain: &mut impl AdmissibleDomain<U>, |
407 domain: &mut impl AdmissibleDomain<U>, |
| 405 ) -> DynResult<MeasureZ<F, Z, U>> |
408 ) -> DynResult<MeasureZ<F, Z, U>> |
| 406 where |
409 where |
| |
410 F: Float + ToNalgebraRealField, |
| 407 U: Space + Clone, |
411 U: Space + Clone, |
| 408 F: Float + ToNalgebraRealField, |
412 for<'a> &'a U: Instance<U>, |
| 409 I: AlgIteratorFactory<IterInfo<F>>, |
413 I: AlgIteratorFactory<IterInfo<F>>, |
| 410 Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
414 Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
| 411 S: ClosedMul<F>, |
415 S: ClosedMul<F>, |
| 412 DiscreteMeasure<U, F>: SpikeMerging<F>, |
416 DiscreteMeasure<U, F>: SpikeMerging<F>, |
| 413 Reg: RegTerm<U, F>, |
417 Reg: RegTerm<U, F>, |
| 414 P: ProxPenalty<U, S, Reg, F>, |
418 P: ProxPenalty<U, S, Reg, F>, |
| 415 for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
419 for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
| 416 Z: ClosedEuclidean<F> + AXPY<Field = F> + Clone, |
420 Z: ClosedEuclidean<F> + AXPY + Clone, |
| 417 for<'b> &'b Z: Instance<Z>, |
421 for<'b> &'b Z: Instance<Z>, |
| 418 R: Prox<Z, Codomain = F>, |
422 R: Prox<Z, Codomain = F>, |
| 419 Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
423 Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
| 420 // We should not need to explicitly require this: |
|
| 421 for<'b> &'b Loc<0, F>: Instance<Loc<0, F>>, |
|
| 422 { |
424 { |
| 423 let opKz = ZeroOp::new_dualisable(Loc([]), z.dual_origin()); |
425 let opKz: ZeroOp<Z, Loc<0, F>, _, _, F> = |
| |
426 ZeroOp::new_dualisable(StaticEuclideanOriginGenerator, z.dual_origin()); |
| 424 let fnH = Zero::new(); |
427 let fnH = Zero::new(); |
| 425 // Convert config. We don't implement From (that could be done with the o2o crate), as σd0 |
428 // Convert config. We don't implement From (that could be done with the o2o crate), as σd0 |
| 426 // needs to be chosen in a general case; for the problem of this fucntion, anything is valid. |
429 // needs to be chosen in a general case; for the problem of this fucntion, anything is valid. |
| 427 let &FBConfig { τ0, σp0, insertion } = config; |
430 let &FBConfig { τ0, σp0, insertion } = config; |
| 428 let pdps_config = ForwardPDPSConfig { τ0, σp0, insertion, σd0: 0.0 }; |
431 let pdps_config = ForwardPDPSConfig { τ0, σp0, insertion, σd0: 0.0 }; |
| 454 init: (Option<DiscreteMeasure<U, F>>, Z), |
457 init: (Option<DiscreteMeasure<U, F>>, Z), |
| 455 //opKμ : KOpM, |
458 //opKμ : KOpM, |
| 456 fnR: &R, |
459 fnR: &R, |
| 457 ) -> DynResult<MeasureZ<F, Z, U>> |
460 ) -> DynResult<MeasureZ<F, Z, U>> |
| 458 where |
461 where |
| |
462 F: Float + ToNalgebraRealField, |
| 459 U: Space + Clone, |
463 U: Space + Clone, |
| 460 F: Float + ToNalgebraRealField, |
464 for<'a> &'a U: Instance<U>, |
| 461 I: AlgIteratorFactory<IterInfo<F>>, |
465 I: AlgIteratorFactory<IterInfo<F>>, |
| 462 Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
466 Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
| 463 S: DifferentiableMapping<U, Codomain = F> + ClosedMul<F>, |
467 S: ClosedMul<F>, |
| 464 DiscreteMeasure<U, F>: SpikeMerging<F>, |
468 DiscreteMeasure<U, F>: SpikeMerging<F>, |
| 465 Reg: RegTerm<U, F>, |
469 Reg: RegTerm<U, F>, |
| 466 P: ProxPenalty<U, S, Reg, F>, |
470 P: ProxPenalty<U, S, Reg, F>, |
| 467 for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
471 for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
| 468 Z: ClosedEuclidean<F> + AXPY<Field = F> + Clone, |
472 Z: ClosedEuclidean<F> + AXPY + Clone, |
| 469 for<'b> &'b Z: Instance<Z>, |
473 for<'b> &'b Z: Instance<Z>, |
| 470 R: Prox<Z, Codomain = F>, |
474 R: Prox<Z, Codomain = F>, |
| 471 Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
475 Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
| 472 // We should not need to explicitly require this: |
|
| 473 for<'b> &'b Loc<0, F>: Instance<Loc<0, F>>, |
|
| 474 { |
476 { |
| 475 pointsource_fb_pair_dom( |
477 pointsource_fb_pair_dom( |
| 476 f, |
478 f, |
| 477 reg, |
479 reg, |
| 478 prox_penalty, |
480 prox_penalty, |