diff --git a/.clang-format b/.clang-format index d617cd54e81c5d7212b12acbcb64ff2348f55c85..d0165aef39ffabfe0d88c7f53d9dffadb00d3045 100644 --- a/.clang-format +++ b/.clang-format @@ -8,6 +8,12 @@ # https://clang.llvm.org/docs/ClangFormatStyleOptions.html # Effective configuration can be obtained with: # clang-format --dump-config + +# The RemoveParentheses and RemoveSemicolon option are not permanently set, +# because the clang-format manual (as of version 19) states that these +# options can lead to incorrect formatting and thus their result should be +# carefully reviewed. + Language: Cpp Standard: c++20 ColumnLimit: 100 @@ -23,7 +29,8 @@ InsertNewlineAtEOF: true PackConstructorInitializers: NextLine PPIndentWidth: 1 PointerAlignment: Left -RemoveSemicolon: true +# RemoveParentheses: ReturnStatement +# RemoveSemicolon: true SpaceAfterTemplateKeyword: false SpaceBeforeParens: ControlStatements SpaceBeforeCpp11BracedList: true diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index 1249555850d1c6efe56278d971a82c998b309775..a8717615c951c51f2cc17f23611b742640bc9f7a 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -2198,7 +2198,7 @@ Interpreter::complete(int beg_t) } mxFree(save_code); mxFree(diff); - return (beg_t); + return beg_t; } void diff --git a/mex/sources/libkorder/kord/first_order.cc b/mex/sources/libkorder/kord/first_order.cc index 9bb49ecb8803143228dad061f1e89ee23e3fa815..23490c11547327da505db2ac1f6203cff711402d 100644 --- a/mex/sources/libkorder/kord/first_order.cc +++ b/mex/sources/libkorder/kord/first_order.cc @@ -35,8 +35,8 @@ std::mutex FirstOrder::mut; lapack_int FirstOrder::order_eigs(const double* alphar, const double* alphai, const double* beta) { - return (*alphar * *alphar + *alphai * *alphai - < *beta * *beta * qz_criterium_global * qz_criterium_global); + return *alphar * *alphar + *alphai * *alphai + < *beta * *beta * qz_criterium_global * qz_criterium_global; } /* Here we solve the linear approximation. The result are the matrices diff --git a/mex/sources/libkorder/sylv/QuasiTriangular.cc b/mex/sources/libkorder/sylv/QuasiTriangular.cc index 12d4f151f35f553a267dc5c6c01c99ef68377914..1e116c4510ffeee1052282558c44bcd446e1b95b 100644 --- a/mex/sources/libkorder/sylv/QuasiTriangular.cc +++ b/mex/sources/libkorder/sylv/QuasiTriangular.cc @@ -306,7 +306,7 @@ Diagonal::print() const bool Diagonal::isZero(double p) { - return (std::abs(p) < EPS); + return std::abs(p) < EPS; } QuasiTriangular::const_col_iter diff --git a/mex/sources/libkorder/sylv/SylvesterSolver.hh b/mex/sources/libkorder/sylv/SylvesterSolver.hh index d5de5cb23265db7bcb48064d2fb2470f0b53e5b4..cc7700091feb41d496aa650b61754d8ce6e33e13 100644 --- a/mex/sources/libkorder/sylv/SylvesterSolver.hh +++ b/mex/sources/libkorder/sylv/SylvesterSolver.hh @@ -42,7 +42,7 @@ private: static bool zeroPad(const SchurDecompZero& kdecomp) { - return ((kdecomp.getZeroCols() * 3 < kdecomp.getDim() * 2) || (kdecomp.getZeroCols() < 10)); + return (kdecomp.getZeroCols() * 3 < kdecomp.getDim() * 2) || (kdecomp.getZeroCols() < 10); } public: diff --git a/mex/sources/libkorder/sylv/tests/tests.cc b/mex/sources/libkorder/sylv/tests/tests.cc index 4235c0e37cb608f946d61cad7674c061fd46d74a..20fc267b6387f2705996851dfdd30de45b12b609 100644 --- a/mex/sources/libkorder/sylv/tests/tests.cc +++ b/mex/sources/libkorder/sylv/tests/tests.cc @@ -142,7 +142,7 @@ TestRunnable::quasi_solve(bool trans, const std::string& mname, const std::strin xx.add(1.0, x); double norm = xx.getNorm(); std::cout << "\terror norm = " << norm << std::endl; - return (norm < eps_norm); + return norm < eps_norm; } bool @@ -174,7 +174,7 @@ TestRunnable::mult_kron(bool trans, const std::string& mname, const std::string& c.add(-1.0, v); double norm = c.getNorm(); std::cout << "\terror norm = " << norm << std::endl; - return (norm < eps_norm); + return norm < eps_norm; } bool @@ -208,7 +208,7 @@ TestRunnable::level_kron(bool trans, const std::string& mname, const std::string x.add(-1, c); double norm = x.getNorm(); std::cout << "\terror norm = " << norm << std::endl; - return (norm < eps_norm); + return norm < eps_norm; } bool @@ -241,7 +241,7 @@ TestRunnable::kron_power(const std::string& m1name, const std::string& m2name, x.add(-1, c); double norm = x.getNorm(); std::cout << "\terror norm = " << norm << std::endl; - return (norm < eps_norm); + return norm < eps_norm; } bool @@ -282,7 +282,7 @@ TestRunnable::lin_eval(const std::string& m1name, const std::string& m2name, double norm1 = x1.getNorm(); double norm2 = x2.getNorm(); std::cout << "\terror norm1 = " << norm1 << "\n\terror norm2 = " << norm2 << '\n'; - return (norm1 * norm1 + norm2 * norm2 < eps_norm * eps_norm); + return norm1 * norm1 + norm2 * norm2 < eps_norm * eps_norm; } bool @@ -323,7 +323,7 @@ TestRunnable::qua_eval(const std::string& m1name, const std::string& m2name, double norm1 = x1.getNorm(); double norm2 = x2.getNorm(); std::cout << "\terror norm1 = " << norm1 << "\n\terror norm2 = " << norm2 << std::endl; - return (norm1 * norm1 + norm2 * norm2 < 100 * eps_norm * eps_norm); // relax norm + return norm1 * norm1 + norm2 * norm2 < 100 * eps_norm * eps_norm; // relax norm } bool @@ -362,7 +362,7 @@ TestRunnable::tri_sylv(const std::string& m1name, const std::string& m2name, double max = dcheck.getMax(); double xmax = v.getMax(); std::cout << "\trel. error max = " << max / xmax << std::endl; - return (norm < xnorm * eps_norm); + return norm < xnorm * eps_norm; } bool @@ -388,8 +388,8 @@ TestRunnable::gen_sylv(const std::string& aname, const std::string& bname, const gs.check(mmd.getData()); const SylvParams& pars = gs.getParams(); pars.print("\t"); - return (*(pars.mat_err1) < eps_norm && *(pars.mat_errI) < eps_norm && *(pars.mat_errF) < eps_norm - && *(pars.vec_err1) < eps_norm && *(pars.vec_errI) < eps_norm); + return *(pars.mat_err1) < eps_norm && *(pars.mat_errI) < eps_norm && *(pars.mat_errF) < eps_norm + && *(pars.vec_err1) < eps_norm && *(pars.vec_errI) < eps_norm; } bool @@ -424,7 +424,7 @@ TestRunnable::eig_bubble(const std::string& aname, int from, int to) << "\tabs. error∞ = " << normInf << std::endl << "\trel. error1 = " << norm1 / onorm1 << std::endl << "\trel. error∞ = " << normInf / onormInf << std::endl; - return (norm1 < eps_norm * onorm1 && normInf < eps_norm * onormInf); + return norm1 < eps_norm * onorm1 && normInf < eps_norm * onormInf; } bool @@ -463,7 +463,7 @@ TestRunnable::block_diag(const std::string& aname, double log10norm) std::cout << "\terror Q·Q⁻¹:" << std::endl << "\tabs. error1 = " << nor1 << std::endl << "\tabs. error∞ = " << norInf << std::endl; - return (norm1 < eps_norm * pow(10, log10norm) * onorm1); + return norm1 < eps_norm * pow(10, log10norm) * onorm1; } bool @@ -503,7 +503,7 @@ TestRunnable::iter_sylv(const std::string& m1name, const std::string& m2name, double max = dcheck.getMax(); double xmax = v.getMax(); std::cout << "\trel. error max = " << max / xmax << std::endl; - return (cnorm < xnorm * eps_norm); + return cnorm < xnorm * eps_norm; } /**********************************************************/ diff --git a/mex/sources/libkorder/tl/equivalence.cc b/mex/sources/libkorder/tl/equivalence.cc index 3b560bfd3f8213585a4ec927a60a92001719594b..bc7f4a32546d63ee7fb41980e5db64fbfee269bd 100644 --- a/mex/sources/libkorder/tl/equivalence.cc +++ b/mex/sources/libkorder/tl/equivalence.cc @@ -57,7 +57,7 @@ OrdSequence::operator==(const OrdSequence& s) const while (i < length() && operator[](i) == s[i]) i++; - return (i == length()); + return i == length(); } /* The first add() adds a given integer to the class, the second diff --git a/mex/sources/libkorder/tl/int_sequence.cc b/mex/sources/libkorder/tl/int_sequence.cc index 6d2ffc0f14827565aa3eff02b8940db186472128..f08e40cae7c2ab58d565cf0f73e57041d6fd6c2c 100644 --- a/mex/sources/libkorder/tl/int_sequence.cc +++ b/mex/sources/libkorder/tl/int_sequence.cc @@ -117,7 +117,7 @@ IntSequence::lessEq(const IntSequence& s) const int i = 0; while (i < size() && operator[](i) <= s[i]) i++; - return (i == size()); + return i == size(); } bool @@ -128,7 +128,7 @@ IntSequence::less(const IntSequence& s) const int i = 0; while (i < size() && operator[](i) < s[i]) i++; - return (i == size()); + return i == size(); } void diff --git a/mex/sources/libkorder/tl/stack_container.hh b/mex/sources/libkorder/tl/stack_container.hh index 30a2e9806b41a87003e098f5bc387bd10a2773a6..e15cef7295bfe0d77bab4b1f9bfa8c57c1269e7f 100644 --- a/mex/sources/libkorder/tl/stack_container.hh +++ b/mex/sources/libkorder/tl/stack_container.hh @@ -208,8 +208,7 @@ public: isZero(int i, const Symmetry& s) const override { TL_RAISE_IF(i < 0 || i >= numStacks(), "Wrong index to stack in StackContainer::isZero."); - return (getType(i, s) == itype::zero - || (getType(i, s) == itype::matrix && !conts[i]->check(s))); + return getType(i, s) == itype::zero || (getType(i, s) == itype::matrix && !conts[i]->check(s)); } [[nodiscard]] const _Ttype& diff --git a/mex/sources/libkorder/tl/tests/tests.cc b/mex/sources/libkorder/tl/tests/tests.cc index e146ddbd105738cc27bb0b9affd30aff18a7cad8..8c837bf205f05468bd75c1e9683bf3480dc37983 100644 --- a/mex/sources/libkorder/tl/tests/tests.cc +++ b/mex/sources/libkorder/tl/tests/tests.cc @@ -450,7 +450,7 @@ TestRunnable::folded_contraction(int r, int nv, int dim) << "\terror normMax: " << v.getMax() << '\n' << "\terror norm1: " << v.getNorm1() << '\n'; - return (v.getMax() < 1.e-10); + return v.getMax() < 1.e-10; } bool @@ -485,7 +485,7 @@ TestRunnable::unfolded_contraction(int r, int nv, int dim) << "\terror normMax: " << v.getMax() << '\n' << "\terror norm1: " << v.getNorm1() << '\n'; - return (v.getMax() < 1.e-10); + return v.getMax() < 1.e-10; } bool @@ -542,7 +542,7 @@ TestRunnable::poly_eval(int r, int nv, int maxdim) << "\tfolded horner error norm max: " << max_fh << '\n' << "\tunfolded horner error norm max: " << max_uh << '\n'; - return (max_ft + max_fh + max_uh < 1.0e-10); + return max_ft + max_fh + max_uh < 1.0e-10; } /****************************************************/