From 6c069ba4ea584d04a4c18391eb4db5b6c0da4712 Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Fri, 18 Oct 2024 00:54:40 +0900 Subject: [PATCH 1/4] chore(dev): bump clang tools version to v19 --- .clang-tidy | 3 ++- .clangd | 7 +++++++ test/.clang-tidy | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 5a9df02e..a54979d8 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,7 +5,7 @@ # Require clang-tidy v15 --- -Checks: "-*,abseil-*,boost-*,bugprone-*,clang-*,concurrency-*,cppcoreguidelines-*,google-*,misc-*,modernize-*,openmp-*,performance-*,portability-*,readability-*,-bugprone-assignment-in-if-condition,-bugprone-easily-swappable-parameters,-cppcoreguidelines-avoid-do-while,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-init-variables,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-*,-cppcoreguidelines-rvalue-reference-param-not-moved,-cppcoreguidelines-use-default-member-init,-google-explicit-constructor,-misc-no-recursion,-modernize-avoid-c-arrays,-modernize-return-braced-init-list,-modernize-loop-convert,-modernize-concat-nested-namespaces,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-use-trailing-return-type,-modernize-use-auto,-modernize-use-default-member-init,-modernize-use-emplace,-modernize-use-equals-delete,-modernize-use-nodiscard,-readability-isolate-declaration,-readability-identifier-length,-readability-qualified-auto,-*-magic-numbers" +Checks: "-*,abseil-*,boost-*,bugprone-*,clang-*,concurrency-*,cppcoreguidelines-*,google-*,misc-*,modernize-*,openmp-*,performance-*,portability-*,readability-*,-boost-use-ranges,-bugprone-assignment-in-if-condition,-bugprone-crtp-constructor-accessibility,-bugprone-easily-swappable-parameters,-clang-analyzer-optin.core.EnumCastOutOfRange,-cppcoreguidelines-avoid-do-while,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-init-variables,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-*,-cppcoreguidelines-rvalue-reference-param-not-moved,-cppcoreguidelines-use-default-member-init,-google-explicit-constructor,-misc-no-recursion,-modernize-avoid-c-arrays,-modernize-return-braced-init-list,-modernize-loop-convert,-modernize-concat-nested-namespaces,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-use-trailing-return-type,-modernize-use-auto,-modernize-use-default-member-init,-modernize-use-emplace,-modernize-use-equals-delete,-modernize-use-nodiscard,-performance-enum-size,-readability-isolate-declaration,-readability-identifier-length,-readability-qualified-auto,-readability-math-missing-parentheses,-readability-avoid-nested-conditional-operator,-*-magic-numbers" FormatStyle: "file" # If these flags are updated, .clangd should be updated as well ExtraArgsBefore: @@ -24,6 +24,7 @@ ExtraArgsBefore: - -Wno-unused-macros - -Wno-disabled-macro-expansion - -Wno-unsafe-buffer-usage + - -Wno-switch-default - -fno-sanitize=all CheckOptions: - key: bugprone-stringview-nullptr.IncludeStyle diff --git a/.clangd b/.clangd index 202f40c0..536e06ac 100644 --- a/.clangd +++ b/.clangd @@ -24,6 +24,7 @@ CompileFlags: - -Wno-unused-macros - -Wno-disabled-macro-expansion - -Wno-unsafe-buffer-usage + - -Wno-switch-default Remove: - "-fsanitize=*" - "-flto*" @@ -43,3 +44,9 @@ InlayHints: Enabled: Yes ParameterNames: Yes DeducedTypes: Yes +--- +If: + PathMatch: "third_party/.*" +Diagnostics: + Suppress: "*" + UnusedIncludes: None diff --git a/test/.clang-tidy b/test/.clang-tidy index 03d85a49..00cf7f50 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -2,8 +2,8 @@ # Project NuriKit - Copyright 2023 SNU Compbio Lab. # SPDX-License-Identifier: Apache-2.0 # -Checks: "-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-cppcoreguidelines-special-member-functions,-readability-function-cognitive-complexity,-readability-identifier-naming,-*-non-private-member-variables-in-classes" +Checks: "-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-cppcoreguidelines-special-member-functions,-readability-function-cognitive-complexity,-readability-identifier-naming,-*-non-private-member-variables-in-classes,-*-macro-usage" InheritParentConfig: true -ExtraArgs: +ExtraArgsBefore: - -Wno-gnu-zero-variadic-macro-arguments - -Wno-unused-member-function From b75a36d29de49226cb51f05c767e65fe3c3b6dce Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Fri, 18 Oct 2024 01:00:10 +0900 Subject: [PATCH 2/4] ci: bump clang tools version to v19 --- .github/workflows/_run-clang-tools.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_run-clang-tools.yaml b/.github/workflows/_run-clang-tools.yaml index 2c4b0176..2d7cb669 100644 --- a/.github/workflows/_run-clang-tools.yaml +++ b/.github/workflows/_run-clang-tools.yaml @@ -16,7 +16,7 @@ on: default: false version: type: string - default: "17" + default: "19" defaults: run: From 7f426abd534e78a0d2478980a7c36e21aea52f21 Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Fri, 18 Oct 2024 01:00:37 +0900 Subject: [PATCH 3/4] fix: correct bugs or silence invalid diagnostics found by clang-tidy v19 --- include/nuri/core/geometry.h | 2 +- include/nuri/core/graph.h | 2 +- src/algo/rings.cpp | 4 ++-- src/fmt/mol2.cpp | 2 +- src/fmt/pdb.cpp | 9 +++++---- src/fmt/sdf.cpp | 3 +-- test/core/geometry_test.cpp | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/nuri/core/geometry.h b/include/nuri/core/geometry.h index 2f28ab88..e2e28c1d 100644 --- a/include/nuri/core/geometry.h +++ b/include/nuri/core/geometry.h @@ -206,7 +206,7 @@ auto cdist(const ML1 &a, const ML2 &b) { } namespace internal { - constexpr inline double safe_normalizer(double sqn, double eps = 1e-12) { + constexpr double safe_normalizer(double sqn, double eps = 1e-12) { return sqn > eps ? 1 / std::sqrt(sqn) : 0; } diff --git a/include/nuri/core/graph.h b/include/nuri/core/graph.h index 0f69a018..998acb08 100644 --- a/include/nuri/core/graph.h +++ b/include/nuri/core/graph.h @@ -2170,7 +2170,7 @@ class Subgraph { * @note If the node is already in the subgraph, this is a no-op. If the * node id is out of range, the behavior is undefined. */ - void add_node(int id) { return nodes_.insert(id); } + void add_node(int id) { nodes_.insert(id); } /** * @brief Add nodes to the subgraph diff --git a/src/algo/rings.cpp b/src/algo/rings.cpp index 8f32b8ce..d4cb2fda 100644 --- a/src/algo/rings.cpp +++ b/src/algo/rings.cpp @@ -289,9 +289,9 @@ namespace { } template - auto make_dst_iterator(Iter it) { + auto make_dst_iterator(Iter &&it) { return internal::make_transform_iterator< - extract_did>(it); + extract_did>(std::forward(it)); } template diff --git a/src/fmt/mol2.cpp b/src/fmt/mol2.cpp index 4875b6ab..cb45a39a 100644 --- a/src/fmt/mol2.cpp +++ b/src/fmt/mol2.cpp @@ -683,7 +683,7 @@ SubstructInfo resolve_substructs(const Molecule &mol) { struct NameMapEntry { int first_idx; int count = 1; - std::string safe_name = {}; + std::string safe_name = {}; // NOLINT(readability-redundant-member-init) }; template diff --git a/src/fmt/pdb.cpp b/src/fmt/pdb.cpp index e74ae392..bb67ca55 100644 --- a/src/fmt/pdb.cpp +++ b/src/fmt/pdb.cpp @@ -485,7 +485,7 @@ struct PDBAtomInfoTemplate { std::string_view name; int atomic_number; int implicit_hydrogens; - std::string_view altname {}; + std::string_view altname {}; // NOLINT(readability-redundant-member-init) constants::Hybridization hyb = constants::kSP3; int formal_charge = 0; bool conjugated = false; @@ -2042,9 +2042,10 @@ void update_substructures(Molecule &mol, std::vector &subs, for (int i = 0; i < atom_data.size(); ++i) { ResidueId id = atom_data[i].first().id().res; - auto [cit, _] = insert_sorted(chains, { id.chain, {} }, [](auto a, auto b) { - return a.first < b.first; - }); + auto [cit, _] = insert_sorted(chains, { id.chain, {} }, + [](const auto &a, const auto &b) { + return a.first < b.first; + }); cit->second.push_back(i); } diff --git a/src/fmt/sdf.cpp b/src/fmt/sdf.cpp index 75f1c65d..55b3ca9f 100644 --- a/src/fmt/sdf.cpp +++ b/src/fmt/sdf.cpp @@ -70,8 +70,7 @@ struct HeaderReadResult { static HeaderReadResult failure() { return HeaderReadResult(); } static HeaderReadResult success(int version, int natoms, int nbonds) { - return HeaderReadResult(static_cast(version), static_cast(natoms), - static_cast(nbonds)); + return HeaderReadResult(version, natoms, nbonds); } int version() const { return version_; } diff --git a/test/core/geometry_test.cpp b/test/core/geometry_test.cpp index dd83b5c4..0b179226 100644 --- a/test/core/geometry_test.cpp +++ b/test/core/geometry_test.cpp @@ -302,7 +302,7 @@ class AlignTest: public ::testing::Test { // Below all calculated manually inline static const double msd_ = 0.4516332; - constexpr inline static double msd_reflected_ = 3.9094217; + constexpr static double msd_reflected_ = 3.9094217; inline static const Affine3d xform_reflected_ { Matrix4d {{ -0.994979, 0.091884, -0.0396638, 44.5055 }, { -0.0531631, -0.149479, 0.987335, 20.6586 }, From 85adc915d0a61340ebc918d67b89f58b18f3de9b Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Fri, 18 Oct 2024 01:22:28 +0900 Subject: [PATCH 4/4] style: re-format with clang-format v19 --- include/nuri/core/graph.h | 12 +- src/core/geometry.cpp | 10 +- src/fmt/pdb.cpp | 2 +- src/fmt/smiles.cpp | 2 +- test/algo/guess_test.cpp | 118 +++--- test/algo/optim_test.cpp | 706 ++++++++++++++++++------------------ test/core/geometry_test.cpp | 46 +-- 7 files changed, 448 insertions(+), 448 deletions(-) diff --git a/include/nuri/core/graph.h b/include/nuri/core/graph.h index 998acb08..b81e9a59 100644 --- a/include/nuri/core/graph.h +++ b/include/nuri/core/graph.h @@ -1003,8 +1003,8 @@ NodesErased Graph::erase_nodes(Iterator begin, Iterator end) { // E = O(V). if (begin == end) { return { - {num_nodes(), {}}, - {num_edges(), {}}, + { num_nodes(), {} }, + { num_edges(), {} }, }; } @@ -1028,7 +1028,7 @@ NodesErased Graph::erase_nodes(Iterator begin, Iterator end) { auto edge_info = erase_nodes_common(node_keep, first_erased_id, erase_trailing); return { - {erase_trailing ? first_erased_id : -1, std::move(node_keep)}, + { erase_trailing ? first_erased_id : -1, std::move(node_keep) }, std::move(edge_info), }; } @@ -1044,8 +1044,8 @@ NodesErased Graph::erase_nodes(const const_iterator begin, // This will also handle size() == 0 case correctly. if (begin >= end) { return { - {num_nodes(), {}}, - {num_edges(), {}}, + { num_nodes(), {} }, + { num_edges(), {} }, }; } @@ -1073,7 +1073,7 @@ NodesErased Graph::erase_nodes(const const_iterator begin, auto edge_info = erase_nodes_common(node_keep, first_erased_id, erase_trailing); return { - {erase_trailing ? first_erased_id : -1, std::move(node_keep)}, + { erase_trailing ? first_erased_id : -1, std::move(node_keep) }, std::move(edge_info), }; } diff --git a/src/core/geometry.cpp b/src/core/geometry.cpp index a5b62edd..e0e853d8 100644 --- a/src/core/geometry.cpp +++ b/src/core/geometry.cpp @@ -311,14 +311,14 @@ namespace { kTol = 1e-2, kEps = 1e-8, kEps2 = 1e-16; constexpr int kIp2[2][2] = { - {0, 1}, - {1, 2}, + { 0, 1 }, + { 1, 2 }, }; constexpr int kIp3[3][3] = { - {0, 1, 3}, - {1, 2, 4}, - {3, 4, 5}, + { 0, 1, 3 }, + { 1, 2, 4 }, + { 3, 4, 5 }, }; constexpr int kIp2312[] = { 1, 2, 0, 1 }; diff --git a/src/fmt/pdb.cpp b/src/fmt/pdb.cpp index bb67ca55..d49f2809 100644 --- a/src/fmt/pdb.cpp +++ b/src/fmt/pdb.cpp @@ -1597,7 +1597,7 @@ class AtomicLine { public: AtomicLine(std::string_view line, int serial) : serial_(serial), line_(line), id_ { - {safe_atoi(slice(line_, 22, 26)), line_[21], line_[26]}, + { safe_atoi(slice(line_, 22, 26)), line_[21], line_[26] }, slice_strip(line_, 11, 16) } { ABSL_DCHECK(line.size() >= 47) << "Invalid ATOM/HETATM record: " << line; diff --git a/src/fmt/smiles.cpp b/src/fmt/smiles.cpp index e250f054..bf350e88 100644 --- a/src/fmt/smiles.cpp +++ b/src/fmt/smiles.cpp @@ -346,7 +346,7 @@ void handle_ring(Ctx &ctx, int ring_idx) { const char bond_data = x3::get(ctx); RingMap &map = x3::get(ctx); auto [it, is_new] = map.insert({ - ring_idx, {bond_data, current_idx} + ring_idx, { bond_data, current_idx } }); // New ring index, nothing to do. diff --git a/test/algo/guess_test.cpp b/test/algo/guess_test.cpp index 281d5aa2..8576fda8 100644 --- a/test/algo/guess_test.cpp +++ b/test/algo/guess_test.cpp @@ -120,17 +120,17 @@ class ARGTestParam: public AATestParam { std::vector> bonds() const override { return { - {0, 1}, - {1, 2}, - {1, 4}, - {2, 3}, - {2, 11}, - {4, 5}, - {5, 6}, - {6, 7}, - {7, 8}, - {8, 9}, - {8, 10}, + { 0, 1 }, + { 1, 2 }, + { 1, 4 }, + { 2, 3 }, + { 2, 11 }, + { 4, 5 }, + { 5, 6 }, + { 6, 7 }, + { 7, 8 }, + { 8, 9 }, + { 8, 10 }, }; } @@ -206,17 +206,17 @@ class HISTestParam: public AATestParam { std::vector> bonds() const override { return { - {0, 1}, - {1, 2}, - {1, 4}, - {2, 3}, - {2, 10}, - {4, 5}, - {5, 6}, - {5, 7}, - {6, 8}, - {7, 9}, - {8, 9}, + { 0, 1 }, + { 1, 2 }, + { 1, 4 }, + { 2, 3 }, + { 2, 10 }, + { 4, 5 }, + { 5, 6 }, + { 5, 7 }, + { 6, 8 }, + { 7, 9 }, + { 8, 9 }, }; } @@ -274,14 +274,14 @@ class PROTestParam: public AATestParam { std::vector> bonds() const override { return { - {0, 1}, - {0, 6}, - {1, 2}, - {1, 4}, - {2, 3}, - {2, 7}, - {4, 5}, - {5, 6}, + { 0, 1 }, + { 0, 6 }, + { 1, 2 }, + { 1, 4 }, + { 2, 3 }, + { 2, 7 }, + { 4, 5 }, + { 5, 6 }, }; } @@ -353,19 +353,19 @@ class TYRTestParam: public AATestParam { std::vector> bonds() const override { return { - { 0, 1}, - { 1, 2}, - { 1, 4}, - { 2, 3}, - { 2, 12}, - { 4, 5}, - { 5, 6}, - { 5, 7}, - { 6, 8}, - { 7, 9}, - { 8, 10}, - { 9, 10}, - {10, 11}, + { 0, 1 }, + { 1, 2 }, + { 1, 4 }, + { 2, 3 }, + { 2, 12 }, + { 4, 5 }, + { 5, 6 }, + { 5, 7 }, + { 6, 8 }, + { 7, 9 }, + { 8, 10 }, + { 9, 10 }, + { 10, 11 }, }; } @@ -441,22 +441,22 @@ class TRPTestParam: public AATestParam { std::vector> bonds() const override { return { - { 0, 1}, - { 1, 2}, - { 1, 4}, - { 2, 3}, - { 2, 14}, - { 4, 5}, - { 5, 6}, - { 5, 7}, - { 6, 8}, - { 7, 9}, - { 7, 10}, - { 8, 9}, - { 9, 11}, - {10, 12}, - {11, 13}, - {12, 13}, + { 0, 1 }, + { 1, 2 }, + { 1, 4 }, + { 2, 3 }, + { 2, 14 }, + { 4, 5 }, + { 5, 6 }, + { 5, 7 }, + { 6, 8 }, + { 7, 9 }, + { 7, 10 }, + { 8, 9 }, + { 9, 11 }, + { 10, 12 }, + { 11, 13 }, + { 12, 13 }, }; } diff --git a/test/algo/optim_test.cpp b/test/algo/optim_test.cpp index 38ad1107..48223c25 100644 --- a/test/algo/optim_test.cpp +++ b/test/algo/optim_test.cpp @@ -29,28 +29,28 @@ using internal::lbfgsb_subsm; TEST(LBFGSBTest, Prjgr) { ArrayXi nbd { - {0, 1, 2, 3, 3} + { 0, 1, 2, 3, 3 } }; Array2Xd bds { - {0.0, 0.0, 0.0, 0.0, 0.0}, - {1.0, 1.0, 1.0, 1.0, 1.0} + { 0.0, 0.0, 0.0, 0.0, 0.0 }, + { 1.0, 1.0, 1.0, 1.0, 1.0 } }; LbfgsbBounds bounds { nbd, bds }; ArrayXXd x { - { 0.680375, -0.211234, 0.566198, 0.59688, 0.823295}, - {-0.0452059, 0.257742, -0.270431, 0.0268018, 0.904459}, - { -0.967399, -0.514226, -0.725537, 0.608354, -0.686642}, - { 0.0258648, 0.678224, 0.22528, -0.407937, 0.275105}, - { 0.05349, 0.539828, -0.199543, 0.783059, -0.433371}, + { 0.680375, -0.211234, 0.566198, 0.59688, 0.823295 }, + { -0.0452059, 0.257742, -0.270431, 0.0268018, 0.904459 }, + { -0.967399, -0.514226, -0.725537, 0.608354, -0.686642 }, + { 0.0258648, 0.678224, 0.22528, -0.407937, 0.275105 }, + { 0.05349, 0.539828, -0.199543, 0.783059, -0.433371 }, }; ArrayXXd g { - {-0.604897, -0.329554, 0.536459, -0.444451, 0.10794}, - { 0.83239, 0.271423, 0.434594, -0.716795, 0.213938}, - {-0.198111, -0.740419, -0.782382, 0.997849, -0.563486}, - {0.0485744, -0.012834, 0.94555, -0.414966, 0.542715}, - {-0.295083, 0.615449, 0.838053, -0.860489, 0.898654}, + { -0.604897, -0.329554, 0.536459, -0.444451, 0.10794 }, + { 0.83239, 0.271423, 0.434594, -0.716795, 0.213938 }, + { -0.198111, -0.740419, -0.782382, 0.997849, -0.563486 }, + { 0.0485744, -0.012834, 0.94555, -0.414966, 0.542715 }, + { -0.295083, 0.615449, 0.838053, -0.860489, 0.898654 }, }; double ans[] = { 0.604897, 0.832390, 0.782382, 0.945550, 0.838053 }; @@ -63,11 +63,11 @@ TEST(LBFGSBTest, Prjgr) { TEST(LBFGSBTest, Bmv) { MatrixXd vs { - { 0.680375, -0.211234, 0.566198, 0.59688, 0.823295, -0.604897}, - {-0.686642, -0.198111, -0.740419, -0.782382, 0.997849, -0.563486}, - {-0.860489, 0.898654, 0.0519907, -0.827888, -0.615572, 0.326454}, - {-0.124725, 0.86367, 0.86162, 0.441905, -0.431413, 0.477069}, - {-0.203127, 0.629534, 0.368437, 0.821944, -0.0350187, -0.56835}, + { 0.680375, -0.211234, 0.566198, 0.59688, 0.823295, -0.604897 }, + { -0.686642, -0.198111, -0.740419, -0.782382, 0.997849, -0.563486 }, + { -0.860489, 0.898654, 0.0519907, -0.827888, -0.615572, 0.326454 }, + { -0.124725, 0.86367, 0.86162, 0.441905, -0.431413, 0.477069 }, + { -0.203127, 0.629534, 0.368437, 0.821944, -0.0350187, -0.56835 }, }; std::vector sys { MatrixXd { @@ -125,11 +125,11 @@ TEST(LBFGSBTest, Bmv) { }; MatrixXd ans { - { 229.072270, 124.347662, -0.626007, 121.125489, 124.600417, 20.990036}, - {-824.671415, 2.376489, 1.784288, -10.636928, -35.578127, 9.380931}, - { 10.910744, 101.231874, -0.064632, -8.956068, -5.903956, 10.829057}, - { -21.902615, 33.871672, -1.589517, 29.352062, -29.766594, 6.473974}, - { -8.402572, -1.122897, -0.644116, 22.679712, -11.173730, 2.297666}, + { 229.072270, 124.347662, -0.626007, 121.125489, 124.600417, 20.990036 }, + { -824.671415, 2.376489, 1.784288, -10.636928, -35.578127, 9.380931 }, + { 10.910744, 101.231874, -0.064632, -8.956068, -5.903956, 10.829057 }, + { -21.902615, 33.871672, -1.589517, 29.352062, -29.766594, 6.473974 }, + { -8.402572, -1.122897, -0.644116, 22.679712, -11.173730, 2.297666 }, }; VectorXd p(8); @@ -144,38 +144,38 @@ TEST(LBFGSBTest, Bmv) { TEST(LBFGSBTest, Cauchy) { ArrayXi nbd { - {0, 1, 2, 3, 3} + { 0, 1, 2, 3, 3 } }; Array2Xd bds { - {0.0, 0.0, 0.0, 0.0, 0.0}, - {1.0, 1.0, 1.0, 1.0, 1.0} + { 0.0, 0.0, 0.0, 0.0, 0.0 }, + { 1.0, 1.0, 1.0, 1.0, 1.0 } }; LbfgsbBounds bounds { nbd, bds }; ArrayXXd xs { - { 0.680375, -0.211234, 0.566198, 0.59688, 0.823295}, - {-0.0452059, 0.257742, -0.270431, 0.0268018, 0.904459}, - { -0.967399, -0.514226, -0.725537, 0.608354, -0.686642}, - { 0.0258648, 0.678224, 0.22528, -0.407937, 0.275105}, - { 0.05349, 0.539828, -0.199543, 0.783059, -0.433371}, + { 0.680375, -0.211234, 0.566198, 0.59688, 0.823295 }, + { -0.0452059, 0.257742, -0.270431, 0.0268018, 0.904459 }, + { -0.967399, -0.514226, -0.725537, 0.608354, -0.686642 }, + { 0.0258648, 0.678224, 0.22528, -0.407937, 0.275105 }, + { 0.05349, 0.539828, -0.199543, 0.783059, -0.433371 }, }; xs.transposeInPlace(); ArrayXXd g { - {-0.604897, -0.329554, 0.536459, -0.444451, 0.10794}, - { 0.83239, 0.271423, 0.434594, -0.716795, 0.213938}, - {-0.198111, -0.740419, -0.782382, 0.997849, -0.563486}, - {0.0485744, -0.012834, 0.94555, -0.414966, 0.542715}, - {-0.295083, 0.615449, 0.838053, -0.860489, 0.898654}, + { -0.604897, -0.329554, 0.536459, -0.444451, 0.10794 }, + { 0.83239, 0.271423, 0.434594, -0.716795, 0.213938 }, + { -0.198111, -0.740419, -0.782382, 0.997849, -0.563486 }, + { 0.0485744, -0.012834, 0.94555, -0.414966, 0.542715 }, + { -0.295083, 0.615449, 0.838053, -0.860489, 0.898654 }, }; g.transposeInPlace(); MatrixXd vs { - { 0.680375, -0.211234, 0.566198, 0.59688, 0.823295, -0.604897}, - {-0.686642, -0.198111, -0.740419, -0.782382, 0.997849, -0.563486}, - {-0.860489, 0.898654, 0.0519907, -0.827888, -0.615572, 0.326454}, - {-0.124725, 0.86367, 0.86162, 0.441905, -0.431413, 0.477069}, - {-0.203127, 0.629534, 0.368437, 0.821944, -0.0350187, -0.56835}, + { 0.680375, -0.211234, 0.566198, 0.59688, 0.823295, -0.604897 }, + { -0.686642, -0.198111, -0.740419, -0.782382, 0.997849, -0.563486 }, + { -0.860489, 0.898654, 0.0519907, -0.827888, -0.615572, 0.326454 }, + { -0.124725, 0.86367, 0.86162, 0.441905, -0.431413, 0.477069 }, + { -0.203127, 0.629534, 0.368437, 0.821944, -0.0350187, -0.56835 }, }; vs.transposeInPlace(); @@ -310,48 +310,48 @@ TEST(LBFGSBTest, Cauchy) { }; ArrayXXd xcpans { - { 0.680375, 0.000000, 0.566198, 0.596880, 0.823295}, - {-0.045206, 0.257742, -0.270431, 0.026802, 0.904459}, - {-0.967399, 0.000000, -0.725537, 0.608354, 0.000000}, - { 0.001242, 0.684730, -0.254024, 0.210348, 0.000000}, - { 1.722777, 0.000000, -4.940416, 1.000000, 0.000000}, + { 0.680375, 0.000000, 0.566198, 0.596880, 0.823295 }, + { -0.045206, 0.257742, -0.270431, 0.026802, 0.904459 }, + { -0.967399, 0.000000, -0.725537, 0.608354, 0.000000 }, + { 0.001242, 0.684730, -0.254024, 0.210348, 0.000000 }, + { 1.722777, 0.000000, -4.940416, 1.000000, 0.000000 }, }; xcpans.transposeInPlace(); MatrixXd pans { - {-0.886504, -0.676173, -0.031902, -0.000196, -0.000443, -0.000274}, - {-0.262569, -0.614618, 0.060677, -0.000001, -0.000484, 0.000412}, - {-0.162045, -0.909390, 0.117659, -0.001251, 0.000849, -0.001022}, - { 0.264038, -0.273030, 1.032468, -0.000077, -0.000190, 0.000246}, - {-0.595891, -0.068418, 0.905387, -0.000170, 0.000554, -0.000086}, + { -0.886504, -0.676173, -0.031902, -0.000196, -0.000443, -0.000274 }, + { -0.262569, -0.614618, 0.060677, -0.000001, -0.000484, 0.000412 }, + { -0.162045, -0.909390, 0.117659, -0.001251, 0.000849, -0.001022 }, + { 0.264038, -0.273030, 1.032468, -0.000077, -0.000190, 0.000246 }, + { -0.595891, -0.068418, 0.905387, -0.000170, 0.000554, -0.000086 }, }; pans.transposeInPlace(); MatrixXd vans { - {-233.283106, -138.285076, 0.035272, -122.259504, -122.693681, - -26.877552 }, - {-335.409168, 2.992509, -0.146222, -3.034546, -14.605031, 4.295200}, - { -11.936100, -105.638206, -0.146266, 5.787840, 1.138340, -11.267936}, - { 2.021730, -3.600595, 1.420546, -3.122262, 3.259059, -0.723479}, - { -2.111828, -1.615625, -1.744323, 5.428624, -3.573644, 0.861716}, + { -233.283106, -138.285076, 0.035272, -122.259504, -122.693681, + -26.877552 }, + { -335.409168, 2.992509, -0.146222, -3.034546, -14.605031, 4.295200 }, + { -11.936100, -105.638206, -0.146266, 5.787840, 1.138340, -11.267936 }, + { 2.021730, -3.600595, 1.420546, -3.122262, 3.259059, -0.723479 }, + { -2.111828, -1.615625, -1.744323, 5.428624, -3.573644, 0.861716 }, }; vans.transposeInPlace(); MatrixXd cans { - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0}, - { 0.102617, -0.105763, 0.735202, -0.000018, 0.000042, 0.000176}, - {-3.032081, -0.876366, 4.467648, -0.001000, 0.002708, -0.000328}, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0.102617, -0.105763, 0.735202, -0.000018, 0.000042, 0.000176 }, + { -3.032081, -0.876366, 4.467648, -0.001000, 0.002708, -0.000328 }, }; cans.transposeInPlace(); ArrayXXi iwhans { - {-1, 0, 0, 0, 0}, - {-1, 0, 0, 0, 0}, - {-1, 0, 0, 0, 0}, - {-1, 0, 0, 0, 1}, - {-1, 1, 0, 2, 1}, + { -1, 0, 0, 0, 0 }, + { -1, 0, 0, 0, 0 }, + { -1, 0, 0, 0, 0 }, + { -1, 0, 0, 0, 1 }, + { -1, 1, 0, 2, 1 }, }; iwhans.transposeInPlace(); @@ -381,25 +381,25 @@ TEST(LBFGSBTest, Cauchy) { TEST(LBFGSBTest, Subsm) { ArrayXi nbd { - {0, 1, 2, 3, 3} + { 0, 1, 2, 3, 3 } }; Array2Xd bds { - {0.0, 0.0, 0.0, 0.0, 0.0}, - {1.0, 1.0, 1.0, 1.0, 1.0} + { 0.0, 0.0, 0.0, 0.0, 0.0 }, + { 1.0, 1.0, 1.0, 1.0, 1.0 } }; LbfgsbBounds bounds { nbd, bds }; ArrayXXd xs { - {-0.967399, -0.514226, -0.725537, 0.608354, -0.686642}, - {0.0258648, 0.678224, 0.22528, -0.407937, 0.275105}, - { 0.05349, 0.539828, -0.199543, 0.783059, -0.433371}, + { -0.967399, -0.514226, -0.725537, 0.608354, -0.686642 }, + { 0.0258648, 0.678224, 0.22528, -0.407937, 0.275105 }, + { 0.05349, 0.539828, -0.199543, 0.783059, -0.433371 }, }; xs.transposeInPlace(); ArrayXXd gs { - {-0.198111, -0.740419, -0.782382, 0.997849, -0.563486}, - {0.0485744, -0.012834, 0.94555, -0.414966, 0.542715}, - {-0.295083, 0.615449, 0.838053, -0.860489, 0.898654}, + { -0.198111, -0.740419, -0.782382, 0.997849, -0.563486 }, + { 0.0485744, -0.012834, 0.94555, -0.414966, 0.542715 }, + { -0.295083, 0.615449, 0.838053, -0.860489, 0.898654 }, }; gs.transposeInPlace(); @@ -451,58 +451,58 @@ TEST(LBFGSBTest, Subsm) { }; ArrayXXd zs { - {-0.967399, 0.000000, -0.725537, 0.608354, 0.000000}, - { 0.001242, 0.684730, -0.254024, 0.210348, 0.000000}, - { 1.722777, 0.000000, -4.940416, 1.000000, 0.000000}, + { -0.967399, 0.000000, -0.725537, 0.608354, 0.000000 }, + { 0.001242, 0.684730, -0.254024, 0.210348, 0.000000 }, + { 1.722777, 0.000000, -4.940416, 1.000000, 0.000000 }, }; zs.transposeInPlace(); MatrixXd cs { - { 0, 0, 0, 0, 0, 0}, - { 0.102617, -0.105763, 0.735202, -0.000018, 0.000042, 0.000176}, - {-3.032081, -0.876366, 4.467648, -0.001000, 0.002708, -0.000328}, + { 0, 0, 0, 0, 0, 0 }, + { 0.102617, -0.105763, 0.735202, -0.000018, 0.000042, 0.000176 }, + { -3.032081, -0.876366, 4.467648, -0.001000, 0.002708, -0.000328 }, }; cs.transposeInPlace(); ArrayXi free { - {0, 4} + { 0, 4 } }; ArrayXXd rs { - { 0.198111, 0.220165, 0, 0, 0}, - { 0.001037, 1.807676, 0, 0, 0}, - {-14.078347, 9.587907, 0, 0, 0}, + { 0.198111, 0.220165, 0, 0, 0 }, + { 0.001037, 1.807676, 0, 0, 0 }, + { -14.078347, 9.587907, 0, 0, 0 }, }; rs.transposeInPlace(); MatrixXd wnt { - {1.596070, 0.334823, 1.059997, 0.455904, -0.525436, -0.404465}, - { 0, 1.358974, 1.322411, 0.769674, 1.016884, -0.061445}, - { 0, 0, 0.152887, -2.085847, 2.649316, 9.972609}, - { 0, 0, 0, 2.286466, -2.095094, -9.122658}, - { 0, 0, 0, 0, 1.992419, 3.931478}, - { 0, 0, 0, 0, 0, 1.149771}, + { 1.596070, 0.334823, 1.059997, 0.455904, -0.525436, -0.404465 }, + { 0, 1.358974, 1.322411, 0.769674, 1.016884, -0.061445 }, + { 0, 0, 0.152887, -2.085847, 2.649316, 9.972609 }, + { 0, 0, 0, 2.286466, -2.095094, -9.122658 }, + { 0, 0, 0, 0, 1.992419, 3.931478 }, + { 0, 0, 0, 0, 0, 1.149771 }, }; wnt.transposeInPlace(); ArrayXXd zans { - {-1.702536, 0, -0.725537, 0.608354, 1}, - {-1.756607, 0.684730, -0.254024, 0.210348, 1}, - { 0.547059, 0, -4.940416, 1, 1}, + { -1.702536, 0, -0.725537, 0.608354, 1 }, + { -1.756607, 0.684730, -0.254024, 0.210348, 1 }, + { 0.547059, 0, -4.940416, 1, 1 }, }; zans.transposeInPlace(); ArrayXXd rans { - { -0.735137, 1.153705, 0, 0, 0}, - { -1.757849, 3.757679, 0, 0, 0}, - {-57.737404, 0.000000, 0, 0, 0}, + { -0.735137, 1.153705, 0, 0, 0 }, + { -1.757849, 3.757679, 0, 0, 0 }, + { -57.737404, 0.000000, 0, 0, 0 }, }; rans.transposeInPlace(); MatrixXd pans { - {-0.078845, 0.142419, -0.147806, 0.416238, -0.245800, -0.099450}, - { 0.270294, -0.365865, 0.305946, -0.427600, 0.636039, 0.574769}, - {-8.559166, 7.031202, -2.823381, 32.639278, -40.189454, 34.250817}, + { -0.078845, 0.142419, -0.147806, 0.416238, -0.245800, -0.099450 }, + { 0.270294, -0.365865, 0.305946, -0.427600, 0.636039, 0.574769 }, + { -8.559166, 7.031202, -2.823381, 32.639278, -40.189454, 34.250817 }, }; pans.transposeInPlace(); @@ -539,26 +539,26 @@ TEST(LBFGSBTest, LbfgsbSquared) { }; MatrixXd x { - { 0.680375, -0.211234, 0.566198}, - { 0.59688, 0.823295, -0.604897}, - {-0.329554, 0.536459, -0.444451}, - { 0.10794, -0.0452059, 0.257742}, - {-0.270431, 0.0268018, 0.904459}, - { 0.83239, 0.271423, 0.434594}, - {-0.716795, 0.213938, -0.967399}, - {-0.514226, -0.725537, 0.608354}, - {-0.686642, -0.198111, -0.740419}, - {-0.782382, 0.997849, -0.563486}, - {0.0258648, 0.678224, 0.22528}, - {-0.407937, 0.275105, 0.0485744}, - {-0.012834, 0.94555, -0.414966}, - { 0.542715, 0.05349, 0.539828}, - {-0.199543, 0.783059, -0.433371}, - {-0.295083, 0.615449, 0.838053}, - {-0.860489, 0.898654, 0.0519907}, - {-0.827888, -0.615572, 0.326454}, - { 0.780465, -0.302214, -0.871657}, - {-0.959954, -0.0845965, -0.873808}, + { 0.680375, -0.211234, 0.566198 }, + { 0.59688, 0.823295, -0.604897 }, + { -0.329554, 0.536459, -0.444451 }, + { 0.10794, -0.0452059, 0.257742 }, + { -0.270431, 0.0268018, 0.904459 }, + { 0.83239, 0.271423, 0.434594 }, + { -0.716795, 0.213938, -0.967399 }, + { -0.514226, -0.725537, 0.608354 }, + { -0.686642, -0.198111, -0.740419 }, + { -0.782382, 0.997849, -0.563486 }, + { 0.0258648, 0.678224, 0.22528 }, + { -0.407937, 0.275105, 0.0485744 }, + { -0.012834, 0.94555, -0.414966 }, + { 0.542715, 0.05349, 0.539828 }, + { -0.199543, 0.783059, -0.433371 }, + { -0.295083, 0.615449, 0.838053 }, + { -0.860489, 0.898654, 0.0519907 }, + { -0.827888, -0.615572, 0.326454 }, + { 0.780465, -0.302214, -0.871657 }, + { -0.959954, -0.0845965, -0.873808 }, }; x.transposeInPlace(); MutRef xa = x.reshaped().array(); @@ -569,66 +569,66 @@ TEST(LBFGSBTest, LbfgsbSquared) { nbd.tail(20) = 3; ArrayXXd bounds { - { -0.52344, 0.941268}, - { 0.70184, 0.804416}, - { -0.466669, 0.0795207}, - { -0.249586, 0.520497}, - { 0.0250707, 0.335448}, - { -0.921439, 0.0632129}, - { -0.124725, 0.86367}, - { 0.441905, 0.86162}, - { -0.431413, 0.477069}, - { -0.291903, 0.279958}, - { -0.668052, 0.375723}, - { -0.119791, 0.76015}, - { -0.339326, 0.658402}, - { -0.542064, 0.786745}, - { -0.29928, 0.37334}, - { 0.17728, 0.912937}, - { 0.314608, 0.717353}, - { -0.12088, 0.84794}, - { -0.203127, 0.629534}, - { 0.368437, 0.821944}, - { -0.56835, -0.0350187}, - { 0.840257, 0.900505}, - { -0.70468, 0.762124}, - { -0.136093, 0.282161}, - { -0.437881, 0.239193}, - { -0.385084, 0.572004}, - { -0.547787, -0.105933}, - { -0.624934, -0.447531}, - { -0.166997, 0.112888}, - { -0.660786, 0.813608}, - { -0.793658, -0.747849}, - {-0.00911187, 0.52095}, - { 0.870008, 0.969503}, - { -0.233623, 0.36889}, - { -0.262673, 0.499542}, - { -0.535477, -0.411679}, - { -0.511175, 0.168977}, - { -0.69522, 0.464297}, - { -0.74905, 0.586941}, - { -0.671796, 0.490143}, - { -0.85094, 0.900208}, - { -0.894941, 0.0431268}, - { -0.647579, -0.519875}, - { 0.465309, 0.595596}, - { 0.313127, 0.93481}, - { 0.278917, 0.51947}, - { -0.813039, -0.730195}, - { -0.843536, 0.0404201}, - { -0.860187, -0.59069}, - { -0.0771591, 0.639355}, - { 0.146637, 0.511162}, - { -0.896122, -0.684386}, - { -0.591343, 0.999987}, - { -0.749063, 0.779911}, - { -0.891885, 0.995598}, - { -0.855342, 0.74108}, - { -0.991677, 0.846138}, - { -0.639255, 0.187784}, - { -0.673737, -0.21662}, - { 0.63939, 0.826053}, + { -0.52344, 0.941268 }, + { 0.70184, 0.804416 }, + { -0.466669, 0.0795207 }, + { -0.249586, 0.520497 }, + { 0.0250707, 0.335448 }, + { -0.921439, 0.0632129 }, + { -0.124725, 0.86367 }, + { 0.441905, 0.86162 }, + { -0.431413, 0.477069 }, + { -0.291903, 0.279958 }, + { -0.668052, 0.375723 }, + { -0.119791, 0.76015 }, + { -0.339326, 0.658402 }, + { -0.542064, 0.786745 }, + { -0.29928, 0.37334 }, + { 0.17728, 0.912937 }, + { 0.314608, 0.717353 }, + { -0.12088, 0.84794 }, + { -0.203127, 0.629534 }, + { 0.368437, 0.821944 }, + { -0.56835, -0.0350187 }, + { 0.840257, 0.900505 }, + { -0.70468, 0.762124 }, + { -0.136093, 0.282161 }, + { -0.437881, 0.239193 }, + { -0.385084, 0.572004 }, + { -0.547787, -0.105933 }, + { -0.624934, -0.447531 }, + { -0.166997, 0.112888 }, + { -0.660786, 0.813608 }, + { -0.793658, -0.747849 }, + { -0.00911187, 0.52095 }, + { 0.870008, 0.969503 }, + { -0.233623, 0.36889 }, + { -0.262673, 0.499542 }, + { -0.535477, -0.411679 }, + { -0.511175, 0.168977 }, + { -0.69522, 0.464297 }, + { -0.74905, 0.586941 }, + { -0.671796, 0.490143 }, + { -0.85094, 0.900208 }, + { -0.894941, 0.0431268 }, + { -0.647579, -0.519875 }, + { 0.465309, 0.595596 }, + { 0.313127, 0.93481 }, + { 0.278917, 0.51947 }, + { -0.813039, -0.730195 }, + { -0.843536, 0.0404201 }, + { -0.860187, -0.59069 }, + { -0.0771591, 0.639355 }, + { 0.146637, 0.511162 }, + { -0.896122, -0.684386 }, + { -0.591343, 0.999987 }, + { -0.749063, 0.779911 }, + { -0.891885, 0.995598 }, + { -0.855342, 0.74108 }, + { -0.991677, 0.846138 }, + { -0.639255, 0.187784 }, + { -0.673737, -0.21662 }, + { 0.63939, 0.826053 }, }; bounds.transposeInPlace(); @@ -643,49 +643,49 @@ TEST(LBFGSBTest, LbfgsbSquared) { // Results from scipy.optimize.fmin_l_bfgs_b MatrixX3d xans { - { 2.97450449e-16, 7.01840000e-01, 2.79359746e-16}, - { 1.70398777e-16, 2.50707000e-02, -2.29439929e-16}, - {-8.40784200e-17, 4.41905000e-01, -2.98329073e-16}, - { 6.07533072e-17, -1.85049446e-17, 5.64862103e-17}, - {-1.52210280e-16, 1.50852139e-17, 2.74444780e-16}, - { 1.77280000e-01, 3.14608000e-01, 1.56861537e-16}, - {-1.42084249e-16, 3.68437000e-01, -3.50187000e-02}, - {-2.89428665e-16, -5.19385951e-16, 1.31056856e-16}, - {-2.92723838e-16, -1.11505452e-16, -1.05933000e-01}, - {-4.47531000e-01, 4.96604681e-17, -3.72665478e-16}, - {-7.47849000e-01, 2.93213224e-16, 9.90417659e-17}, - {-2.35956292e-16, 1.82596585e-16, -4.11679000e-01}, - {-8.95825455e-18, 2.05815310e-16, -2.89071989e-16}, - { 2.75873710e-16, 3.01064888e-17, 2.42736310e-17}, - {-5.19875000e-01, 4.65309000e-01, 3.13127000e-01}, - { 2.78917000e-01, -7.30195000e-01, 2.27501830e-17}, - {-5.90690000e-01, 1.18240810e-16, 1.46637000e-01}, - {-6.84386000e-01, -2.77322302e-16, 1.28231300e-16}, - { 3.28257204e-16, -1.14587978e-16, -4.94757427e-16}, - {-1.55684329e-16, -2.16620000e-01, 6.39390000e-01}, + { 2.97450449e-16, 7.01840000e-01, 2.79359746e-16 }, + { 1.70398777e-16, 2.50707000e-02, -2.29439929e-16 }, + { -8.40784200e-17, 4.41905000e-01, -2.98329073e-16 }, + { 6.07533072e-17, -1.85049446e-17, 5.64862103e-17 }, + { -1.52210280e-16, 1.50852139e-17, 2.74444780e-16 }, + { 1.77280000e-01, 3.14608000e-01, 1.56861537e-16 }, + { -1.42084249e-16, 3.68437000e-01, -3.50187000e-02 }, + { -2.89428665e-16, -5.19385951e-16, 1.31056856e-16 }, + { -2.92723838e-16, -1.11505452e-16, -1.05933000e-01 }, + { -4.47531000e-01, 4.96604681e-17, -3.72665478e-16 }, + { -7.47849000e-01, 2.93213224e-16, 9.90417659e-17 }, + { -2.35956292e-16, 1.82596585e-16, -4.11679000e-01 }, + { -8.95825455e-18, 2.05815310e-16, -2.89071989e-16 }, + { 2.75873710e-16, 3.01064888e-17, 2.42736310e-17 }, + { -5.19875000e-01, 4.65309000e-01, 3.13127000e-01 }, + { 2.78917000e-01, -7.30195000e-01, 2.27501830e-17 }, + { -5.90690000e-01, 1.18240810e-16, 1.46637000e-01 }, + { -6.84386000e-01, -2.77322302e-16, 1.28231300e-16 }, + { 3.28257204e-16, -1.14587978e-16, -4.94757427e-16 }, + { -1.55684329e-16, -2.16620000e-01, 6.39390000e-01 }, }; double fxans = 4.38648551081218; MatrixX3d gans { - { 5.94900898e-16, 1.40368000e+00, 5.58719491e-16}, - { 3.40797554e-16, 5.01414000e-02, -4.58879858e-16}, - {-1.68156840e-16, 8.83810000e-01, -5.96658147e-16}, - { 1.21506614e-16, -3.70098892e-17, 1.12972421e-16}, - {-3.04420560e-16, 3.01704278e-17, 5.48889559e-16}, - { 3.54560000e-01, 6.29216000e-01, 3.13723075e-16}, - {-2.84168498e-16, 7.36874000e-01, -7.00374000e-02}, - {-5.78857331e-16, -1.03877190e-15, 2.62113713e-16}, - {-5.85447677e-16, -2.23010903e-16, -2.11866000e-01}, - {-8.95062000e-01, 9.93209361e-17, -7.45330956e-16}, - {-1.49569800e+00, 5.86426447e-16, 1.98083532e-16}, - {-4.71912585e-16, 3.65193170e-16, -8.23358000e-01}, - {-1.79165091e-17, 4.11630621e-16, -5.78143979e-16}, - { 5.51747420e-16, 6.02129776e-17, 4.85472620e-17}, - {-1.03975000e+00, 9.30618000e-01, 6.26254000e-01}, - { 5.57834000e-01, -1.46039000e+00, 4.55003660e-17}, - {-1.18138000e+00, 2.36481621e-16, 2.93274000e-01}, - {-1.36877200e+00, -5.54644604e-16, 2.56462599e-16}, - { 6.56514407e-16, -2.29175955e-16, -9.89514853e-16}, - {-3.11368657e-16, -4.33240000e-01, 1.27878000e+00}, + { 5.94900898e-16, 1.40368000e+00, 5.58719491e-16 }, + { 3.40797554e-16, 5.01414000e-02, -4.58879858e-16 }, + { -1.68156840e-16, 8.83810000e-01, -5.96658147e-16 }, + { 1.21506614e-16, -3.70098892e-17, 1.12972421e-16 }, + { -3.04420560e-16, 3.01704278e-17, 5.48889559e-16 }, + { 3.54560000e-01, 6.29216000e-01, 3.13723075e-16 }, + { -2.84168498e-16, 7.36874000e-01, -7.00374000e-02 }, + { -5.78857331e-16, -1.03877190e-15, 2.62113713e-16 }, + { -5.85447677e-16, -2.23010903e-16, -2.11866000e-01 }, + { -8.95062000e-01, 9.93209361e-17, -7.45330956e-16 }, + { -1.49569800e+00, 5.86426447e-16, 1.98083532e-16 }, + { -4.71912585e-16, 3.65193170e-16, -8.23358000e-01 }, + { -1.79165091e-17, 4.11630621e-16, -5.78143979e-16 }, + { 5.51747420e-16, 6.02129776e-17, 4.85472620e-17 }, + { -1.03975000e+00, 9.30618000e-01, 6.26254000e-01 }, + { 5.57834000e-01, -1.46039000e+00, 4.55003660e-17 }, + { -1.18138000e+00, 2.36481621e-16, 2.93274000e-01 }, + { -1.36877200e+00, -5.54644604e-16, 2.56462599e-16 }, + { 6.56514407e-16, -2.29175955e-16, -9.89514853e-16 }, + { -3.11368657e-16, -4.33240000e-01, 1.27878000e+00 }, }; NURI_EXPECT_EIGEN_EQ(x, xans.transpose()); @@ -720,26 +720,26 @@ TEST(LBFGSBTest, LbfgsbCorrelated) { }; MatrixXd x { - { 0.680375, -0.211234, 0.566198}, - { 0.59688, 0.823295, -0.604897}, - {-0.329554, 0.536459, -0.444451}, - { 0.10794, -0.0452059, 0.257742}, - {-0.270431, 0.0268018, 0.904459}, - { 0.83239, 0.271423, 0.434594}, - {-0.716795, 0.213938, -0.967399}, - {-0.514226, -0.725537, 0.608354}, - {-0.686642, -0.198111, -0.740419}, - {-0.782382, 0.997849, -0.563486}, - {0.0258648, 0.678224, 0.22528}, - {-0.407937, 0.275105, 0.0485744}, - {-0.012834, 0.94555, -0.414966}, - { 0.542715, 0.05349, 0.539828}, - {-0.199543, 0.783059, -0.433371}, - {-0.295083, 0.615449, 0.838053}, - {-0.860489, 0.898654, 0.0519907}, - {-0.827888, -0.615572, 0.326454}, - { 0.780465, -0.302214, -0.871657}, - {-0.959954, -0.0845965, -0.873808}, + { 0.680375, -0.211234, 0.566198 }, + { 0.59688, 0.823295, -0.604897 }, + { -0.329554, 0.536459, -0.444451 }, + { 0.10794, -0.0452059, 0.257742 }, + { -0.270431, 0.0268018, 0.904459 }, + { 0.83239, 0.271423, 0.434594 }, + { -0.716795, 0.213938, -0.967399 }, + { -0.514226, -0.725537, 0.608354 }, + { -0.686642, -0.198111, -0.740419 }, + { -0.782382, 0.997849, -0.563486 }, + { 0.0258648, 0.678224, 0.22528 }, + { -0.407937, 0.275105, 0.0485744 }, + { -0.012834, 0.94555, -0.414966 }, + { 0.542715, 0.05349, 0.539828 }, + { -0.199543, 0.783059, -0.433371 }, + { -0.295083, 0.615449, 0.838053 }, + { -0.860489, 0.898654, 0.0519907 }, + { -0.827888, -0.615572, 0.326454 }, + { 0.780465, -0.302214, -0.871657 }, + { -0.959954, -0.0845965, -0.873808 }, }; x.transposeInPlace(); MutRef xa = x.reshaped().array(); @@ -759,49 +759,49 @@ TEST(LBFGSBTest, LbfgsbCorrelated) { EXPECT_EQ(iter, 24); MatrixX3d xans { - { 1.000000, -1.000000, 1.000000}, - { 1.000000, 1.000000, -1.000000}, - { 0.020200, -1.000000, -1.000000}, - { 1.000000, -0.089951, -1.000000}, - {-1.000000, -1.000000, 1.000000}, - { 1.000000, 1.000000, 0.152648}, - {-1.000000, -0.090330, -1.000000}, - { 0.078263, -1.000000, 1.000000}, - { 1.000000, -1.000000, 0.099281}, - {-1.000000, 1.000000, -1.000000}, - { 1.000000, 1.000000, 1.000000}, - {-1.000000, -0.022563, 1.000000}, - { 0.375690, 1.000000, -1.000000}, - { 0.072716, 1.000000, 1.000000}, - {-0.358441, 1.000000, -1.000000}, - {-1.000000, 1.000000, 1.000000}, - {-1.000000, 1.000000, 0.107459}, - {-1.000000, -1.000000, 0.042433}, - { 1.000000, -1.000000, -1.000000}, - {-1.000000, -1.000000, -1.000000}, + { 1.000000, -1.000000, 1.000000 }, + { 1.000000, 1.000000, -1.000000 }, + { 0.020200, -1.000000, -1.000000 }, + { 1.000000, -0.089951, -1.000000 }, + { -1.000000, -1.000000, 1.000000 }, + { 1.000000, 1.000000, 0.152648 }, + { -1.000000, -0.090330, -1.000000 }, + { 0.078263, -1.000000, 1.000000 }, + { 1.000000, -1.000000, 0.099281 }, + { -1.000000, 1.000000, -1.000000 }, + { 1.000000, 1.000000, 1.000000 }, + { -1.000000, -0.022563, 1.000000 }, + { 0.375690, 1.000000, -1.000000 }, + { 0.072716, 1.000000, 1.000000 }, + { -0.358441, 1.000000, -1.000000 }, + { -1.000000, 1.000000, 1.000000 }, + { -1.000000, 1.000000, 0.107459 }, + { -1.000000, -1.000000, 0.042433 }, + { 1.000000, -1.000000, -1.000000 }, + { -1.000000, -1.000000, -1.000000 }, }; double fxans = 101.15066430373199; MatrixX3d gans { - {-4.828977, 2.579002, -5.010159}, - {-8.551676, -3.889551, 3.573901}, - { 0.000029, 4.255305, 3.608052}, - {-4.437316, 0.000095, 3.368040}, - { 3.861739, 4.454953, -4.712982}, - {-4.451857, -3.070158, -0.000114}, - { 4.244722, -0.000062, 3.698355}, - { 0.000162, 3.328475, -4.156006}, - {-4.097918, 3.389620, 0.000166}, - { 8.114099, -3.986511, 3.867640}, - {-4.876951, -2.445919, -5.497012}, - { 3.515268, -0.000089, -4.206636}, - { 0.000159, -3.792768, 3.588330}, - { 0.000314, -3.163687, -4.431738}, - { 0.000051, -3.826949, 3.702865}, - { 3.964431, -4.133211, -5.210774}, - { 4.113488, -3.750476, 0.000019}, - { 3.734559, 4.058761, -0.000064}, - {-4.621804, 4.946700, 3.728489}, - { 4.317477, 5.046467, 4.089628}, + { -4.828977, 2.579002, -5.010159 }, + { -8.551676, -3.889551, 3.573901 }, + { 0.000029, 4.255305, 3.608052 }, + { -4.437316, 0.000095, 3.368040 }, + { 3.861739, 4.454953, -4.712982 }, + { -4.451857, -3.070158, -0.000114 }, + { 4.244722, -0.000062, 3.698355 }, + { 0.000162, 3.328475, -4.156006 }, + { -4.097918, 3.389620, 0.000166 }, + { 8.114099, -3.986511, 3.867640 }, + { -4.876951, -2.445919, -5.497012 }, + { 3.515268, -0.000089, -4.206636 }, + { 0.000159, -3.792768, 3.588330 }, + { 0.000314, -3.163687, -4.431738 }, + { 0.000051, -3.826949, 3.702865 }, + { 3.964431, -4.133211, -5.210774 }, + { 4.113488, -3.750476, 0.000019 }, + { 3.734559, 4.058761, -0.000064 }, + { -4.621804, 4.946700, 3.728489 }, + { 4.317477, 5.046467, 4.089628 }, }; NURI_EXPECT_EIGEN_EQ(x, xans.transpose()); @@ -847,26 +847,26 @@ TEST(LBFGSBTest, LbfgsbReference) { 1.0000083438107843, 1.0000120681556417, 1.0000196904590828, 1.0000374605368185, 1.0000770108551211, 1.0001583814754376, 1.0003231605131711, 1.0006492825285076, 1.0013006127613451, - 1.002601944378863, 1.0052112931969246, 1.010449820256067, - 1.0210095629751152, 1.0424600004275, 1.086723474398011, - 1.1809686991764257, 1.394691851289783, 1.9451626718243049, + 1.002601944378863, 1.0052112931969246, 1.010449820256067, + 1.0210095629751152, 1.0424600004275, 1.086723474398011, + 1.1809686991764257, 1.394691851289783, 1.9451626718243049, 3.7836626570644625, } }; double fans = 1.0834900834300615e-09; ArrayXd gans { { - 3.0365748651745088e-05, 1.234141889728772e-05, - 5.0625882852877512e-05, 3.7751766268700644e-05, - 3.9131017956764807e-05, 5.4405939303440887e-05, - 2.8257415671835532e-05, 3.4180539567112549e-05, + 3.0365748651745088e-05, 1.234141889728772e-05, + 5.0625882852877512e-05, 3.7751766268700644e-05, + 3.9131017956764807e-05, 5.4405939303440887e-05, + 2.8257415671835532e-05, 3.4180539567112549e-05, -4.8350726165878632e-06, -4.8781455271871458e-05, -5.2959691520253405e-05, -6.7145113998150568e-05, - 5.2519369914780871e-06, -3.1785220170763878e-06, - 2.8593132814416504e-05, -1.795750106352732e-05, - 3.8476695147693124e-06, -1.1090233921327606e-05, - 1.4403142695957529e-05, -1.4591078955444807e-05, + 5.2519369914780871e-06, -3.1785220170763878e-06, + 2.8593132814416504e-05, -1.795750106352732e-05, + 3.8476695147693124e-06, -1.1090233921327606e-05, + 1.4403142695957529e-05, -1.4591078955444807e-05, -8.7499549958468529e-06, -8.4059488955526312e-05, - 9.8250878119067711e-05, -0.00017205227288462103, + 9.8250878119067711e-05, -0.00017205227288462103, 3.8697646353114123e-05, } }; @@ -907,26 +907,26 @@ TEST(LBFGSBTest, LbfgsbUnbounded) { }; MatrixXd x { - { 0.680375, -0.211234, 0.566198}, - { 0.59688, 0.823295, -0.604897}, - {-0.329554, 0.536459, -0.444451}, - { 0.10794, -0.0452059, 0.257742}, - {-0.270431, 0.0268018, 0.904459}, - { 0.83239, 0.271423, 0.434594}, - {-0.716795, 0.213938, -0.967399}, - {-0.514226, -0.725537, 0.608354}, - {-0.686642, -0.198111, -0.740419}, - {-0.782382, 0.997849, -0.563486}, - {0.0258648, 0.678224, 0.22528}, - {-0.407937, 0.275105, 0.0485744}, - {-0.012834, 0.94555, -0.414966}, - { 0.542715, 0.05349, 0.539828}, - {-0.199543, 0.783059, -0.433371}, - {-0.295083, 0.615449, 0.838053}, - {-0.860489, 0.898654, 0.0519907}, - {-0.827888, -0.615572, 0.326454}, - { 0.780465, -0.302214, -0.871657}, - {-0.959954, -0.0845965, -0.873808}, + { 0.680375, -0.211234, 0.566198 }, + { 0.59688, 0.823295, -0.604897 }, + { -0.329554, 0.536459, -0.444451 }, + { 0.10794, -0.0452059, 0.257742 }, + { -0.270431, 0.0268018, 0.904459 }, + { 0.83239, 0.271423, 0.434594 }, + { -0.716795, 0.213938, -0.967399 }, + { -0.514226, -0.725537, 0.608354 }, + { -0.686642, -0.198111, -0.740419 }, + { -0.782382, 0.997849, -0.563486 }, + { 0.0258648, 0.678224, 0.22528 }, + { -0.407937, 0.275105, 0.0485744 }, + { -0.012834, 0.94555, -0.414966 }, + { 0.542715, 0.05349, 0.539828 }, + { -0.199543, 0.783059, -0.433371 }, + { -0.295083, 0.615449, 0.838053 }, + { -0.860489, 0.898654, 0.0519907 }, + { -0.827888, -0.615572, 0.326454 }, + { 0.780465, -0.302214, -0.871657 }, + { -0.959954, -0.0845965, -0.873808 }, }; x.transposeInPlace(); MutRef xa = x.reshaped().array(); @@ -941,49 +941,49 @@ TEST(LBFGSBTest, LbfgsbUnbounded) { EXPECT_EQ(iter, 54); MatrixX3d xans { - { 1.329873, -0.702233, 0.525096}, - { 0.959901, 0.504039, -1.180017}, - { 0.000066, 0.000213, 0.000389}, - { 0.473379, -1.519620, -0.191415}, - {-0.699817, -0.462164, 1.365490}, - { 1.532975, 0.410986, 0.077387}, - {-0.076689, -0.100664, -1.592082}, - { 0.170076, -1.250362, 0.984563}, - {-0.365095, -1.160734, -1.038901}, - {-1.324395, 0.880736, -0.169923}, - { 0.736751, 1.045224, 0.949381}, - {-1.523757, -0.162909, 0.449013}, - { 0.693983, 1.394387, -0.367577}, - { 0.621756, -0.052286, 1.461228}, - {-0.434747, 1.039471, -1.115292}, - {-0.630837, 0.770384, 1.234164}, - {-0.364141, 1.536944, 0.272608}, - {-0.942729, -1.267791, 0.131732}, - { 1.122640, -0.690652, -0.882549}, - {-1.279187, -0.212978, -0.913293}, + { 1.329873, -0.702233, 0.525096 }, + { 0.959901, 0.504039, -1.180017 }, + { 0.000066, 0.000213, 0.000389 }, + { 0.473379, -1.519620, -0.191415 }, + { -0.699817, -0.462164, 1.365490 }, + { 1.532975, 0.410986, 0.077387 }, + { -0.076689, -0.100664, -1.592082 }, + { 0.170076, -1.250362, 0.984563 }, + { -0.365095, -1.160734, -1.038901 }, + { -1.324395, 0.880736, -0.169923 }, + { 0.736751, 1.045224, 0.949381 }, + { -1.523757, -0.162909, 0.449013 }, + { 0.693983, 1.394387, -0.367577 }, + { 0.621756, -0.052286, 1.461228 }, + { -0.434747, 1.039471, -1.115292 }, + { -0.630837, 0.770384, 1.234164 }, + { -0.364141, 1.536944, 0.272608 }, + { -0.942729, -1.267791, 0.131732 }, + { 1.122640, -0.690652, -0.882549 }, + { -1.279187, -0.212978, -0.913293 }, }; double fxans = 144.943662; MatrixX3d gans { - { 0.000093, 0.000046, -0.000365}, - { 0.000654, 0.000675, 0.000634}, - { 0.000110, 0.001210, 0.001484}, - { 0.000256, -0.000578, 0.000258}, - { 0.000145, 0.000925, -0.000211}, - {-0.000525, -0.000307, 0.000488}, - {-0.000276, 0.000175, -0.000814}, - { 0.000221, 0.000032, 0.000199}, - {-0.000376, -0.000439, -0.000964}, - { 0.000739, 0.000136, 0.000476}, - {-0.000958, -0.001127, -0.000077}, - { 0.000324, 0.000788, 0.000459}, - { 0.000234, -0.000668, -0.000163}, - { 0.000023, 0.001554, -0.001037}, - {-0.000147, 0.000407, 0.000102}, - { 0.000273, -0.000632, -0.001037}, - {-0.000611, -0.001219, 0.000600}, - {-0.000351, -0.000584, 0.000527}, - { 0.000795, -0.000274, -0.000175}, - {-0.000610, -0.000138, -0.000381}, + { 0.000093, 0.000046, -0.000365 }, + { 0.000654, 0.000675, 0.000634 }, + { 0.000110, 0.001210, 0.001484 }, + { 0.000256, -0.000578, 0.000258 }, + { 0.000145, 0.000925, -0.000211 }, + { -0.000525, -0.000307, 0.000488 }, + { -0.000276, 0.000175, -0.000814 }, + { 0.000221, 0.000032, 0.000199 }, + { -0.000376, -0.000439, -0.000964 }, + { 0.000739, 0.000136, 0.000476 }, + { -0.000958, -0.001127, -0.000077 }, + { 0.000324, 0.000788, 0.000459 }, + { 0.000234, -0.000668, -0.000163 }, + { 0.000023, 0.001554, -0.001037 }, + { -0.000147, 0.000407, 0.000102 }, + { 0.000273, -0.000632, -0.001037 }, + { -0.000611, -0.001219, 0.000600 }, + { -0.000351, -0.000584, 0.000527 }, + { 0.000795, -0.000274, -0.000175 }, + { -0.000610, -0.000138, -0.000381 }, }; NURI_EXPECT_EIGEN_EQ(x, xans.transpose()); diff --git a/test/core/geometry_test.cpp b/test/core/geometry_test.cpp index 0b179226..d765d29d 100644 --- a/test/core/geometry_test.cpp +++ b/test/core/geometry_test.cpp @@ -244,35 +244,35 @@ class AlignTest: public ::testing::Test { public: // Random rotation matrix inline static const Affine3d xform_ { - Matrix4d {{ 0.82743922, 0.54630659, 0.12997477, -10 }, + Matrix4d { { 0.82743922, 0.54630659, 0.12997477, -10 }, { 0.05113706, 0.15719006, -0.98624352, 20 }, { -0.55922208, 0.8227031, 0.10212871, 30 }, - { 0, 0, 0, 1 }}, + { 0, 0, 0, 1 } }, }; // reflected inline static const Matrix3Xd query_ = -1 * MatrixX3d { - {-18.3397, 72.5541, 64.7727}, - {-17.5457, 72.7646, 65.8591}, - {-17.5263, 71.9973, 66.9036}, - {-18.3203, 70.8982, 66.9881}, - {-19.2153, 70.5869, 65.8606}, - {-19.1851, 71.4993, 64.7091}, - {-19.8932, 71.3140, 63.7366}, - {-19.8586, 69.4953, 66.1942}, - {-19.4843, 69.0910, 67.3570}, - {-18.5535, 69.9074, 67.8928}, - {-17.8916, 69.7493, 69.2373}, - {-16.7519, 70.7754, 69.3878}, - {-15.5030, 70.1100, 69.5871}, - {-17.1385, 71.5903, 70.6459}, - {-15.9909, 71.8532, 71.4558}, - {-18.1166, 70.6286, 71.3678}, - {-18.8422, 70.0100, 70.2837}, - {-19.0679, 71.4098, 72.2764}, - {-20.1784, 71.8813, 71.5104}, + { -18.3397, 72.5541, 64.7727 }, + { -17.5457, 72.7646, 65.8591 }, + { -17.5263, 71.9973, 66.9036 }, + { -18.3203, 70.8982, 66.9881 }, + { -19.2153, 70.5869, 65.8606 }, + { -19.1851, 71.4993, 64.7091 }, + { -19.8932, 71.3140, 63.7366 }, + { -19.8586, 69.4953, 66.1942 }, + { -19.4843, 69.0910, 67.3570 }, + { -18.5535, 69.9074, 67.8928 }, + { -17.8916, 69.7493, 69.2373 }, + { -16.7519, 70.7754, 69.3878 }, + { -15.5030, 70.1100, 69.5871 }, + { -17.1385, 71.5903, 70.6459 }, + { -15.9909, 71.8532, 71.4558 }, + { -18.1166, 70.6286, 71.3678 }, + { -18.8422, 70.0100, 70.2837 }, + { -19.0679, 71.4098, 72.2764 }, + { -20.1784, 71.8813, 71.5104 }, }.transpose(); // transformed @@ -304,10 +304,10 @@ class AlignTest: public ::testing::Test { inline static const double msd_ = 0.4516332; constexpr static double msd_reflected_ = 3.9094217; inline static const Affine3d xform_reflected_ { - Matrix4d {{ -0.994979, 0.091884, -0.0396638, 44.5055 }, + Matrix4d { { -0.994979, 0.091884, -0.0396638, 44.5055 }, { -0.0531631, -0.149479, 0.987335, 20.6586 }, { 0.0847914, 0.984486, 0.153613, 184.346 }, - { 0, 0, 0, 1 }}, + { 0, 0, 0, 1 } }, }; };