diff --git a/exprtk_simple_example_13.cpp b/exprtk_simple_example_13.cpp index 192096d..aafe6fb 100644 --- a/exprtk_simple_example_13.cpp +++ b/exprtk_simple_example_13.cpp @@ -30,7 +30,7 @@ void savitzky_golay_filter() typedef exprtk::expression expression_t; typedef exprtk::parser parser_t; - std::string gsfilter_program = + std::string sgfilter_program = " var weight[9] := " " { " " -21, 14, 39, " @@ -38,20 +38,27 @@ void savitzky_golay_filter() " 39, 14, -21 " " }; " " " - " var lower_bound := trunc(weight[] / 2); " - " var upper_bound := v_in[] - lower_bound; " - " " " 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) " " { " - " v_out[i] += weight[j] * v_in[i + j]; " + " 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; " + " }; " " } "; const std::size_t n = 1024; @@ -81,7 +88,7 @@ void savitzky_golay_filter() parser_t parser; - parser.compile(gsfilter_program,expression); + parser.compile(sgfilter_program,expression); expression.value(); diff --git a/readme.txt b/readme.txt index 748df97..d95b907 100644 --- a/readme.txt +++ b/readme.txt @@ -261,6 +261,9 @@ of C++ compilers: | | r0 < r1. If x is within the range it will snap to the | | | closest bound. (eg: iclamp(r0,x,r1) | +----------+---------------------------------------------------------+ +| inrange | In-range returns 'true' when x is within the range r0 | +| | and r1. Where r0 < r1. (eg: inrange(r0,x,r1) | ++----------+---------------------------------------------------------+ | log | Natural logarithm of x. (eg: log(x)) | +----------+---------------------------------------------------------+ | log10 | Base 10 logarithm of x. (eg: log10(x)) |