Skip to content

atomic lint least squares

hgratten requested to merge atomic_lint_least_squares into master

this merge request introduces the clang-tidied least squares chapter

LectureCodes/LeastSquares/*

  • removed "using namespace", since it clutters the translation unit, instead explicitly introduced individual symbols via using
  • 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
  • introduced const wherever possible
  • avoided multiple declarations in a single line for readability
  • wrapped body statement of for, do while, and while in braces. increases readability and forgetting braces is a common source of bugs for students.
  • removed cmake_minimum_required(VERSION 2.8), since the cmake version is better handled by the global CMakeLists.txt file
  • ignored locally bugprone-exception-escape: a subroutine (e.g. clsq) may throw an exception, but in this case we want the program to exit
  • reordered includes as good practice (user header first, then system headers, ordered alphabetically
  • modernized return statements of e.g. std::pair with brace initialization instead of re-stating the return type to access its constructor
  • explicitly casted integer types to double
  • modernized function declaration
  • avoided copying (e.g. matrix decompositioned parts) by value, when they can be used as const reference
  • integer type hygiene (use Eigen::Index for indexing)
  • avoided uninitialized variables, instead used NAN to initialize doubles or -1 to initialize indices. this is more likely to show up as an error than accidentally using unitialized memory
  • avoided naming unused lambda arguments
  • initialized time function with nulltpr instead of implicit cast of int zero to pointer

LectureCodes/LeastSquares/lsqtotal/Eigen/lsqtotal.hpp:

  • avoided using exit(1), instead used print to stderr and attempt recovery

Merge request reports

Loading