diff --git a/CMakeLists.txt b/CMakeLists.txt index 18c96b2..f53288e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,3 +48,10 @@ if (ExprTk_BUILD_TESTING) enable_testing() add_subdirectory(tests) endif () + +# create an ExprTK option for building examples +option(ExprTk_BUILD_EXAMPLES "Build ExprTk examples" ON) +# if ExprTk_BUILD_EXAMPLES is set to ON, then build the examples +if (ExprTk_BUILD_EXAMPLES) + add_subdirectory(examples) +endif () diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..5d909e4 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,71 @@ +# ************************************************************** +# * C++ Mathematical Expression Toolkit Library * +# * * +# * Author: Arash Partow (1999-2023) * +# * URL: https://www.partow.net/programming/exprtk/index.html * +# * * +# * Copyright notice: * +# * Free use of the Mathematical Expression Toolkit Library is * +# * permitted under the guidelines and in accordance with the * +# * most current version of the MIT License. * +# * http://www.opensource.org/licenses/MIT * +# * * +# ************************************************************** + +# create executables for each example +add_executable(exprtk_simple_example_01 exprtk_simple_example_01.cpp) +target_link_libraries(exprtk_simple_example_01 ExprTk) + +add_executable(exprtk_simple_example_02 exprtk_simple_example_02.cpp) +target_link_libraries(exprtk_simple_example_02 ExprTk) + +add_executable(exprtk_simple_example_03 exprtk_simple_example_03.cpp) +target_link_libraries(exprtk_simple_example_03 ExprTk) + +add_executable(exprtk_simple_example_04 exprtk_simple_example_04.cpp) +target_link_libraries(exprtk_simple_example_04 ExprTk) + +add_executable(exprtk_simple_example_05 exprtk_simple_example_05.cpp) +target_link_libraries(exprtk_simple_example_05 ExprTk) + +add_executable(exprtk_simple_example_06 exprtk_simple_example_06.cpp) +target_link_libraries(exprtk_simple_example_06 ExprTk) + +add_executable(exprtk_simple_example_07 exprtk_simple_example_07.cpp) +target_link_libraries(exprtk_simple_example_07 ExprTk) + +add_executable(exprtk_simple_example_08 exprtk_simple_example_08.cpp) +target_link_libraries(exprtk_simple_example_08 ExprTk) + +add_executable(exprtk_simple_example_09 exprtk_simple_example_09.cpp) +target_link_libraries(exprtk_simple_example_09 ExprTk) + +add_executable(exprtk_simple_example_10 exprtk_simple_example_10.cpp) +target_link_libraries(exprtk_simple_example_10 ExprTk) + +add_executable(exprtk_simple_example_11 exprtk_simple_example_11.cpp) +target_link_libraries(exprtk_simple_example_11 ExprTk) + +add_executable(exprtk_simple_example_12 exprtk_simple_example_12.cpp) +target_link_libraries(exprtk_simple_example_12 ExprTk) + +add_executable(exprtk_simple_example_13 exprtk_simple_example_13.cpp) +target_link_libraries(exprtk_simple_example_13 ExprTk) + +add_executable(exprtk_simple_example_14 exprtk_simple_example_14.cpp) +target_link_libraries(exprtk_simple_example_14 ExprTk) + +add_executable(exprtk_simple_example_15 exprtk_simple_example_15.cpp) +target_link_libraries(exprtk_simple_example_15 ExprTk) + +add_executable(exprtk_simple_example_16 exprtk_simple_example_16.cpp) +target_link_libraries(exprtk_simple_example_16 ExprTk) + +add_executable(exprtk_simple_example_17 exprtk_simple_example_17.cpp) +target_link_libraries(exprtk_simple_example_17 ExprTk) + +add_executable(exprtk_simple_example_18 exprtk_simple_example_18.cpp) +target_link_libraries(exprtk_simple_example_18 ExprTk) + +add_executable(exprtk_simple_example_19 exprtk_simple_example_19.cpp) +target_link_libraries(exprtk_simple_example_19 ExprTk) diff --git a/exprtk_simple_example_01.cpp b/examples/exprtk_simple_example_01.cpp similarity index 99% rename from exprtk_simple_example_01.cpp rename to examples/exprtk_simple_example_01.cpp index d20e2ed..cc2e587 100644 --- a/exprtk_simple_example_01.cpp +++ b/examples/exprtk_simple_example_01.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void trig_function() { diff --git a/exprtk_simple_example_02.cpp b/examples/exprtk_simple_example_02.cpp similarity index 99% rename from exprtk_simple_example_02.cpp rename to examples/exprtk_simple_example_02.cpp index 77c8c60..f32fdfa 100644 --- a/exprtk_simple_example_02.cpp +++ b/examples/exprtk_simple_example_02.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void square_wave() { diff --git a/exprtk_simple_example_03.cpp b/examples/exprtk_simple_example_03.cpp similarity index 99% rename from exprtk_simple_example_03.cpp rename to examples/exprtk_simple_example_03.cpp index e133df0..0b8f154 100644 --- a/exprtk_simple_example_03.cpp +++ b/examples/exprtk_simple_example_03.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void polynomial() { diff --git a/exprtk_simple_example_04.cpp b/examples/exprtk_simple_example_04.cpp similarity index 99% rename from exprtk_simple_example_04.cpp rename to examples/exprtk_simple_example_04.cpp index 69a663e..543faaa 100644 --- a/exprtk_simple_example_04.cpp +++ b/examples/exprtk_simple_example_04.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void fibonacci() { diff --git a/exprtk_simple_example_05.cpp b/examples/exprtk_simple_example_05.cpp similarity index 99% rename from exprtk_simple_example_05.cpp rename to examples/exprtk_simple_example_05.cpp index fdbabc9..a103cfa 100644 --- a/exprtk_simple_example_05.cpp +++ b/examples/exprtk_simple_example_05.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template struct myfunc : public exprtk::ifunction { diff --git a/exprtk_simple_example_06.cpp b/examples/exprtk_simple_example_06.cpp similarity index 99% rename from exprtk_simple_example_06.cpp rename to examples/exprtk_simple_example_06.cpp index b50660b..2785a1d 100644 --- a/exprtk_simple_example_06.cpp +++ b/examples/exprtk_simple_example_06.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void vector_function() { diff --git a/exprtk_simple_example_07.cpp b/examples/exprtk_simple_example_07.cpp similarity index 99% rename from exprtk_simple_example_07.cpp rename to examples/exprtk_simple_example_07.cpp index 845b158..d089e76 100644 --- a/exprtk_simple_example_07.cpp +++ b/examples/exprtk_simple_example_07.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void logic() { diff --git a/exprtk_simple_example_08.cpp b/examples/exprtk_simple_example_08.cpp similarity index 99% rename from exprtk_simple_example_08.cpp rename to examples/exprtk_simple_example_08.cpp index bfacb1e..cf1208d 100644 --- a/exprtk_simple_example_08.cpp +++ b/examples/exprtk_simple_example_08.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void composite() { diff --git a/exprtk_simple_example_09.cpp b/examples/exprtk_simple_example_09.cpp similarity index 99% rename from exprtk_simple_example_09.cpp rename to examples/exprtk_simple_example_09.cpp index 8934523..ffadfa0 100644 --- a/exprtk_simple_example_09.cpp +++ b/examples/exprtk_simple_example_09.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void primes() { diff --git a/exprtk_simple_example_10.cpp b/examples/exprtk_simple_example_10.cpp similarity index 99% rename from exprtk_simple_example_10.cpp rename to examples/exprtk_simple_example_10.cpp index 0a0add4..0ae1d09 100644 --- a/exprtk_simple_example_10.cpp +++ b/examples/exprtk_simple_example_10.cpp @@ -22,7 +22,6 @@ #include "exprtk.hpp" - template void newton_sqrt() { diff --git a/exprtk_simple_example_11.cpp b/examples/exprtk_simple_example_11.cpp similarity index 99% rename from exprtk_simple_example_11.cpp rename to examples/exprtk_simple_example_11.cpp index fdf123c..8317844 100644 --- a/exprtk_simple_example_11.cpp +++ b/examples/exprtk_simple_example_11.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void square_wave2() { diff --git a/exprtk_simple_example_12.cpp b/examples/exprtk_simple_example_12.cpp similarity index 99% rename from exprtk_simple_example_12.cpp rename to examples/exprtk_simple_example_12.cpp index aafeebb..b8c2d84 100644 --- a/exprtk_simple_example_12.cpp +++ b/examples/exprtk_simple_example_12.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void bubble_sort() { diff --git a/exprtk_simple_example_13.cpp b/examples/exprtk_simple_example_13.cpp similarity index 99% rename from exprtk_simple_example_13.cpp rename to examples/exprtk_simple_example_13.cpp index 29ac239..89e1f04 100644 --- a/exprtk_simple_example_13.cpp +++ b/examples/exprtk_simple_example_13.cpp @@ -23,7 +23,6 @@ #include "exprtk.hpp" - template void savitzky_golay_filter() { diff --git a/exprtk_simple_example_14.cpp b/examples/exprtk_simple_example_14.cpp similarity index 99% rename from exprtk_simple_example_14.cpp rename to examples/exprtk_simple_example_14.cpp index 259067b..127d197 100644 --- a/exprtk_simple_example_14.cpp +++ b/examples/exprtk_simple_example_14.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void stddev_example() { diff --git a/exprtk_simple_example_15.cpp b/examples/exprtk_simple_example_15.cpp similarity index 99% rename from exprtk_simple_example_15.cpp rename to examples/exprtk_simple_example_15.cpp index 7affeb7..0fb1662 100644 --- a/exprtk_simple_example_15.cpp +++ b/examples/exprtk_simple_example_15.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void black_scholes_merton_model() { diff --git a/exprtk_simple_example_16.cpp b/examples/exprtk_simple_example_16.cpp similarity index 99% rename from exprtk_simple_example_16.cpp rename to examples/exprtk_simple_example_16.cpp index 2480500..5e0763c 100644 --- a/exprtk_simple_example_16.cpp +++ b/examples/exprtk_simple_example_16.cpp @@ -22,7 +22,6 @@ #include "exprtk.hpp" - template void linear_least_squares() { diff --git a/exprtk_simple_example_17.cpp b/examples/exprtk_simple_example_17.cpp similarity index 99% rename from exprtk_simple_example_17.cpp rename to examples/exprtk_simple_example_17.cpp index 24ae15b..ec36f3e 100644 --- a/exprtk_simple_example_17.cpp +++ b/examples/exprtk_simple_example_17.cpp @@ -23,7 +23,6 @@ #include "exprtk.hpp" - template struct rnd_01 : public exprtk::ifunction { diff --git a/exprtk_simple_example_18.cpp b/examples/exprtk_simple_example_18.cpp similarity index 99% rename from exprtk_simple_example_18.cpp rename to examples/exprtk_simple_example_18.cpp index ad4631e..f0d7ba3 100644 --- a/exprtk_simple_example_18.cpp +++ b/examples/exprtk_simple_example_18.cpp @@ -21,7 +21,6 @@ #include "exprtk.hpp" - template void file_io() { diff --git a/exprtk_simple_example_19.cpp b/examples/exprtk_simple_example_19.cpp similarity index 99% rename from exprtk_simple_example_19.cpp rename to examples/exprtk_simple_example_19.cpp index 7929b8b..8709813 100644 --- a/exprtk_simple_example_19.cpp +++ b/examples/exprtk_simple_example_19.cpp @@ -23,7 +23,6 @@ #include "exprtk.hpp" - template class randu : public exprtk::igeneric_function {