C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html

This commit is contained in:
Arash Partow
2014-06-08 19:24:53 +10:00
parent 4aa02953f8
commit 751226b946
6 changed files with 2464 additions and 544 deletions

View File

@ -31,35 +31,36 @@ void savitzky_golay_filter()
typedef exprtk::parser<T> parser_t;
std::string sgfilter_program =
" var weight[9] := "
" { "
" -21, 14, 39, "
" 54, 59, 54, "
" 39, 14, -21 "
" }; "
" "
" if (v_in[] >= weight[]) "
" { "
" var lower_bound := trunc(weight[] / 2); "
" var upper_bound := v_in[] - lower_bound; "
" "
" for (i := lower_bound; i < upper_bound; i += 1) "
" { "
" v_out[i] := 0; "
" for (j := 0; j < weight[]; j += 1) "
" { "
" var index := i + j - lower_bound; "
" v_out[i] += weight[j] * v_in[index]; "
" }; "
" v_out[i] /= 231; "
" }; "
" "
" for (i := 0; i < lower_bound; i += 1) "
" { "
" v_out[i] := 0; "
" v_out[v_out[] - i - 1] := 0; "
" }; "
" } ";
" var weight[9] := "
" { "
" -21, 14, 39, "
" 54, 59, 54, "
" 39, 14, -21 "
" }; "
" "
" if (v_in[] >= weight[]) "
" { "
" var lower_bound := trunc(weight[] / 2); "
" var upper_bound := v_in[] - lower_bound; "
" "
" v_out := 0; "
" "
" for (i := lower_bound; i < upper_bound; i += 1) "
" { "
" for (j := -lower_bound; j <= lower_bound; j += 1) "
" { "
" v_out[i] += weight[j + lower_bound] * v_in[i + j]; "
" }; "
" }; "
" "
" v_out /= sum(weight); "
" "
" for (i := 0; i < lower_bound; i += 1) "
" { "
" v_out[i] := 0; "
" v_out[v_out[] - i - 1] := 0; "
" }; "
" } ";
const std::size_t n = 1024;