src/fb.rs

changeset 22
cecdde4ff5c9
parent 13
f67949050a32
child 46
90cc221eb52b
equal deleted inserted replaced
21:5f2b65738e66 22:cecdde4ff5c9
74 ) -> M 74 ) -> M
75 where M : ManifoldPoint + EmbeddedManifoldPoint, 75 where M : ManifoldPoint + EmbeddedManifoldPoint,
76 F : Desc<M> + Mapping<M, Codomain = f64>, 76 F : Desc<M> + Mapping<M, Codomain = f64>,
77 G : Prox<M> + Mapping<M, Codomain = f64>, 77 G : Prox<M> + Mapping<M, Codomain = f64>,
78 I : AlgIteratorFactory<IterInfo<M>> { 78 I : AlgIteratorFactory<IterInfo<M>> {
79
80 // Closure that calculates current status
81 let status = |x : &M| IterInfo {
82 value : f.apply(x) + g.apply(x),
83 point : x.clone(),
84 };
79 85
80 // Perform as many iterations as requested by `iterator`. 86 // Perform as many iterations as requested by `iterator`.
81 for i in iterator.iter() { 87 for i in iterator.iter_init(|| status(&x)) {
82 // Forward-backward step 88 // Forward-backward step
83 x = g.prox(τ, f.desc(τ, x)); 89 x = g.prox(τ, f.desc(τ, x));
84 90
85 // If requested by `iterator`, calculate function value and store iterate. 91 // If requested by `iterator`, calculate function value and store iterate.
86 i.if_verbose(|| { 92 i.if_verbose(|| status(&x))
87 IterInfo {
88 value : f.apply(&x) + g.apply(&x),
89 point : x.clone(),
90 }
91 })
92 } 93 }
93 94
94 // Return final iterate. 95 // Return final iterate.
95 x 96 x
96 } 97 }

mercurial