150 dcomplex lambda = 2e3*
PI/k0;
151 if (solver->recompute_integrals) {
155 glambda = (solver->always_recompute_gain)? lambda : lam;
157 lam = glambda = lambda;
159 size_t nlayers = solver->lcount;
160 std::exception_ptr error;
161 beforeLayersIntegrals(lam, glambda);
166 layerIntegrals(l,
real(lam),
real(glambda));
169 error = std::current_exception();
172 afterLayersIntegrals();
173 if (error) std::rethrow_exception(error);
174 solver->recompute_integrals =
false;
175 solver->recompute_gain_integrals =
false;
176 }
else if (solver->recompute_gain_integrals ||
177 (solver->always_recompute_gain && !
is_zero(lambda - glambda))) {
178 dcomplex lam =
isnan(lam0)? lambda : solver->lam0;
179 glambda = solver->always_recompute_gain? lambda : lam;
180 std::vector<size_t> recomputed_layers;
181 size_t nlayers = solver->lcount;
182 recomputed_layers.reserve(nlayers);
183 for (
size_t l = 0; l != nlayers; ++l)
if (solver->lgained[l] || solver->lcomputed[l])
184 recomputed_layers.push_back(l);
185 std::exception_ptr error;
186 beforeLayersIntegrals(lam, glambda);
191 layerIntegrals(recomputed_layers[l],
real(lam),
real(glambda));
194 error = std::current_exception();
197 afterLayersIntegrals();
198 if (error) std::rethrow_exception(error);
199 solver->recompute_gain_integrals =
false;