#include // searches for zero crossings in a given vector of floats // for zero crossings in falling edge // give edge = -1 // // // returns pointer to vetctor of ints vector *zerosearch(vector &input, int edge =-1 , int pre=10, int post=30 ){ vector * zeroPositions = new vector; for (int sl =pre ; sl < input.size()-post; sl++){ //cout << "sl:" << sl << endl; if (input[sl] * input[sl-1] < 0 || input[sl]==0.0 ){ // sign change --> zero crossing OR really zero if ( (input[sl-1] - input[sl]) * edge < 0){ // this is the crossing the user wanted // check if we go lower than a certain limit in the next few slices for ( int lala=0; lalapush_back(sl); sl += lala; break; } } } else if ( (input[sl-1] - input[sl]) * edge > 0){ // this is the zero x-ing the user did not want // do nothing } else { // sl and sl-1 are equal .. don't know waht do to... } } } // end of loop over slices - between pre and post return zeroPositions; }