From 8cf0cb5811bf5a9461f3455e5fd0195f5ef3d287 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 20 Sep 2016 07:30:21 +0200 Subject: filter/accela: make more readable progn is similar to one in CLHS cf. http://clhs.lisp.se/Body/s_progn.htm --- filter-accela/ftnoir_filter_accela.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index 697f6d8b..c0f355a4 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -61,9 +61,17 @@ void FTNoIR_Filter::filter(const double* input, double *output) const double vec_ = std::max(0., fabs(vec) - dz); const double thres = i >= 3 ? rot_t : trans_t; const double out_ = vec_ / thres; - const double out = i >= 3 && std::fabs(rot_nl - 1) > 5e-3 && vec_ < rot_nl_.max() - ? (std::pow(out_/rot_nl_.max(), rot_nl)) - : out_; + const double out = progn( + const bool should_apply_rot_nonlinearity = + i >= 3 && + std::fabs(rot_nl - 1) > 5e-3 && + vec_ < rot_nl_.max(); + + if (should_apply_rot_nonlinearity) + return std::pow(out_/rot_nl_.max(), rot_nl); + else + return out_; + ); const double val = double(m.getValue(out)); last_output[i] = output[i] = last_output[i] + signum(vec) * dt * val; } -- cgit v1.2.3