i'm working on a project where program have to find patterns in a stream of number, here is my code:-
vector <double> vals={1.4,0.2,-0.2,0.0,-0.05,-0.05,0.35,0.1,-0.2,-0.4,-0.15,-0.35,0,0.15,-0.1,0.25,0.1,-0.2, -0.2,0.0,-0.05,-0.05.......nth };
using Range = std::pair<double, double>;
vector<Range> pattern{ { -0.5, 1.0 },{ -0.1, 0.3 },{ -0.1, 0.1 },{ -0.1, 0.01 } };
auto match = std::search(begin(vals), end(vals),
begin(pattern), end(pattern),
[](double d, Range r) -> int {
return (r.first < d) && (d < r.second);
});
well, my function does works but I have a total of 63 patterns, and it is time taking to write the same function 60+ times for each pattern to work. Is there any way to write this pattern finding function for other 60 pattern without making it more resource heavy.
Aucun commentaire:
Enregistrer un commentaire