Skip to content

Commit

Permalink
Set C++17 standard
Browse files Browse the repository at this point in the history
  • Loading branch information
anilbey committed Oct 18, 2023
1 parent 8ce1476 commit 8bfe7a4
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 114 deletions.
46 changes: 22 additions & 24 deletions efel/cppcore/LibV1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <sstream>
#include <iomanip>

using std::bind2nd;
using std::find_if;
using std::greater;
using std::greater_equal;
Expand Down Expand Up @@ -378,7 +377,7 @@ static int __AHP_depth_abs_slow_indices(const vector<double>& t,
distance(t.begin(),
find_if(t.begin() + peakindices[i + 1],
t.begin() + peakindices[i + 2],
bind2nd(greater_equal<double>(), t_start))),
[t_start](double val) { return val >= t_start; })),
v.begin() + peakindices[i + 2]));
}
return adas_indices.size();
Expand Down Expand Up @@ -983,10 +982,11 @@ static int __time_constant(const vector<double>& v, const vector<double>& t,
// int stimendindex;
// for(stimendindex = 0; t[stimendindex] < stimEnd; stimendindex++) ;
// int stimmiddleindex = (stimstartindex + stimendindex) / 2;
int stimmiddleindex = distance(
t.begin(),
find_if(t.begin() + stimstartindex, t.end(),
bind2nd(greater_equal<double>(), (stimStart + stimEnd) / 2.)));
double mid_stim = (stimStart + stimEnd) / 2.;
auto it_mid_stim = find_if(t.begin() + stimstartindex, t.end(),
[mid_stim](double val) { return val >= mid_stim; });
int stimmiddleindex = distance(t.begin(), it_mid_stim);

if (stimstartindex >= v.size() || stimmiddleindex < 0 ||
static_cast<size_t>(stimmiddleindex) >= v.size()) {
return -1;
Expand All @@ -1006,13 +1006,13 @@ static int __time_constant(const vector<double>& v, const vector<double>& t,
// find start of the decay
int i_start = 0;
while (find_if(dvdt.begin() + i_start, dvdt.begin() + i_start + 5,
bind2nd(greater<double>(), -min_derivative)) !=
dvdt.begin() + i_start + 5) {
if (dvdt.begin() + i_start + 5 == dvdt.end()) {
GErrorStr += "Could not find the decay.\n";
return -1;
}
i_start++;
[min_derivative](double val) { return val > -min_derivative; }) !=
dvdt.begin() + i_start + 5) {
if (dvdt.begin() + i_start + 5 == dvdt.end()) {
GErrorStr += "Could not find the decay.\n";
return -1;
}
i_start++;
}
// find the flat
// bool foundflat = false;
Expand Down Expand Up @@ -1441,11 +1441,9 @@ static int __AP_width(const vector<double>& t, const vector<double>& v,
if (strict_stiminterval){
int start_index = distance(
t.begin(),
find_if(t.begin(), t.end(), bind2nd(greater_equal<double>(), stimstart)));
int end_index =
distance(t.begin(),
find_if(t.begin(), t.end(),
std::bind2nd(std::greater_equal<double>(), stimend)));
find_if(t.begin(), t.end(), [stimstart](double x){ return x >= stimstart; }));
int end_index = distance(t.begin(), find_if(t.begin(), t.end(),
[stimend](double x){ return x >= stimend; }));
indices.push_back(start_index);
for (size_t i = 0; i < minahpindices.size(); i++) {
if (start_index < minahpindices[i] && minahpindices[i] < end_index) {
Expand All @@ -1470,14 +1468,14 @@ static int __AP_width(const vector<double>& t, const vector<double>& v,
v.begin() + indices[i + 1], bind2nd(less_equal<double>(), v_hm)));
apwidth.push_back(t[hm_index2] - t[hm_index1]);
*/
int onset_index = distance(
v.begin(), find_if(v.begin() + indices[i], v.begin() + indices[i + 1],
bind2nd(greater_equal<double>(), threshold)));
auto onset_index = std::distance(
v.begin(), std::find_if(v.begin() + indices[i], v.begin() + indices[i + 1],
[threshold](double x){ return x >= threshold; }));
// int end_index = distance(v.begin(), find_if(v.begin() + peakindices[i],
// v.begin() + indices[i + 1], bind2nd(less_equal<double>(), threshold)));
int end_index = distance(
v.begin(), find_if(v.begin() + onset_index, v.begin() + indices[i + 1],
bind2nd(less_equal<double>(), threshold)));
auto end_index = std::distance(
v.begin(), std::find_if(v.begin() + onset_index, v.begin() + indices[i + 1],
[threshold](double x){ return x <= threshold; }));
apwidth.push_back(t[end_index] - t[onset_index]);
}
return apwidth.size();
Expand Down
20 changes: 9 additions & 11 deletions efel/cppcore/LibV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <iostream>
#include <math.h>

using std::bind2nd;
using std::find_if;
using std::greater_equal;
using std::min_element;
Expand All @@ -48,9 +47,7 @@ static int __AP_rise_indices(const vector<double>& v, const vector<int>& apbi,
}
vpeak.resize(pi[i] - apbi[i]);
transform(v.begin() + apbi[i], v.begin() + pi[i], vpeak.begin(),
bind2nd(std::minus<double>(), halfheight));
transform(vpeak.begin(), vpeak.end(), vpeak.begin(),
static_cast<double(*)(double)>(fabs));
[halfheight](double val) { return fabs(val - halfheight); });
apri[i] = distance(vpeak.begin(), min_element(vpeak.begin(), vpeak.end())) +
apbi[i];
}
Expand Down Expand Up @@ -87,9 +84,7 @@ static int __AP_fall_indices(const vector<double>& v, const vector<int>& apbi,
double halfheight = (v[pi[i]] + v[apbi[i]]) / 2.;
vector<double> vpeak(&v[pi[i]], &v[apei[i]]);
transform(vpeak.begin(), vpeak.end(), vpeak.begin(),
bind2nd(std::minus<double>(), halfheight));
transform(vpeak.begin(), vpeak.end(), vpeak.begin(),
static_cast<double(*)(double)>(fabs));
[halfheight](double val) { return fabs(val - halfheight); });
apfi[i] = distance(vpeak.begin(), min_element(vpeak.begin(), vpeak.end())) +
pi[i];
}
Expand Down Expand Up @@ -1264,10 +1259,13 @@ int LibV2::E27(mapStr2intVec& IntFeatureData,
static int __steady_state_hyper(const vector<double>& v,
const vector<double>& t, double stimend,
vector<double>& steady_state_hyper) {
int i_end =
distance(t.begin(), find_if(t.begin(), t.end(),
bind2nd(greater_equal<double>(), stimend))) -
5;
// Find the iterator pointing to the first time value greater than or equal to stimend
auto it_stimend = find_if(t.begin(), t.end(),
[stimend](double t_val) { return t_val >= stimend; });

// Calculate the index, ensuring you account for the offset of -5
int i_end = distance(t.begin(), it_stimend) - 5;


const int offset = 30;
if (i_end < 0 || i_end < offset) {
Expand Down
1 change: 0 additions & 1 deletion efel/cppcore/LibV3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <list>
#include <math.h>

using std::bind2nd;
using std::find_if;
using std::greater_equal;
using std::less_equal;
Expand Down
Loading

0 comments on commit 8bfe7a4

Please sign in to comment.