Atomic lint function approximation
this merge request introduces the clang-tidied function approximation chapter
LectureCodes/FuncApproximation/*
- removed cmake_minimum_required(VERSION 2.8), since the cmake version is better handled by the global CMakeLists.txt file
- reordered includes as good practice (user header first, then system headers, ordered alphabetically
- put functions in header files in a separate namespace if there are using directives, to avoid clutter in the global namespace and clarify dependencies in main files
- inlined functions in header file to avoid potential ODR (one-definition-rule) violations: since functions are defined directly in the header, including it from multiple translation units would cause multiple definitions, which inlining avoids by duplicating the definition per translation unit
- integer type hygiene (use Eigen::Index for indexing)
- explicitly casted integer types to double
- introduced const wherever possible
- avoided multiple declarations in a single line for readability
- avoided else after return since it reduces readability of code flow when it comes to main and exit error codes and quickly causes bugs
- wrapped body statement of if-else, for, do while, and while in braces. increases readability and forgetting braces is a common source of bugs for students
- explicitly casted between integer types (narrowing, different signedness)
- lifted all things thrown to derive from std::exception, since the C++ standard library's exception handling mechanism is designed around the std::exception base class and otherwise leads to problem in catching (e.g. does not allow polymorphic catching)
- modernized return statements of e.g. std::pair with brace initialization instead of re-stating the return type to access its constructor
- avoided pointer arithmetic, instead used begin and end iterator for e.g. modern std::sort and std::find
- used auto instead of re-stating the type when a variable is the immediate result of a static_cast
- modernized function declaration
LectureCodes/FuncApproximation/chebexp/Eigen/chebexp.hpp
- avoided indexing of std::array by non-const integer expression, since this gives a warning, even though it is logically safe. used an alternative with indexing by referencing either two vector variables
LectureCodes/FuncApproximation/barycentricformula/Eigen/ipvclass.hpp includes LectureCodes/Interpolation/barycentricformula/Eigen/ipvclass.hpp
- marked single-argument constructors explicit, to avoid accidental implicit conversion of an argument into class object
- marked function with
[[nodiscard]]
attribute to throw a warning if result is not used