From 3dd2758cef57ee5bfe881c418b58775be57b0539 Mon Sep 17 00:00:00 2001 From: Dylan Copeland Date: Fri, 17 May 2024 17:12:23 -0700 Subject: [PATCH] style --- lib/linalg/Matrix.h | 6 ++-- unit_tests/test_HDFDatabase.cpp | 8 ++--- unit_tests/test_QR.cpp | 56 ++++++++++++++++----------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/linalg/Matrix.h b/lib/linalg/Matrix.h index e8fba6832..68414b4dc 100644 --- a/lib/linalg/Matrix.h +++ b/lib/linalg/Matrix.h @@ -918,7 +918,7 @@ class Matrix * * @return The Q of the QR factorization of this. */ - std::unique_ptr + std::unique_ptr qr_factorize() const; /** @@ -926,7 +926,7 @@ class Matrix * * @return The Q and R of the QR factorization of this. */ - void qr_factorize(std::vector> & QR) const; + void qr_factorize(std::vector> & QR) const; /** * @brief Compute the leading numColumns() column pivots from a @@ -1259,7 +1259,7 @@ class Matrix * @return The Q and R of the QR factorization of this. If computeR is * false, the R pointer will be nullptr. */ - void qr_factorize(bool computeR, std::vector & QR) const; + void qr_factorize(bool computeR, std::vector & QR) const; /** * @brief The storage for the Matrix's values on this processor. diff --git a/unit_tests/test_HDFDatabase.cpp b/unit_tests/test_HDFDatabase.cpp index 3f810d881..68fc5222b 100644 --- a/unit_tests/test_HDFDatabase.cpp +++ b/unit_tests/test_HDFDatabase.cpp @@ -820,7 +820,7 @@ TEST(BasisGeneratorIO, Scaling_test) auto stop = steady_clock::now(); auto duration = duration_cast(stop-start); if (rank == 0) - printf("Base writeSnapshot- duration: %dms\n", duration.count()); + printf("Base writeSnapshot- duration: %dms\n", duration.count()); MPI_Barrier(MPI_COMM_WORLD); start = steady_clock::now(); @@ -829,7 +829,7 @@ TEST(BasisGeneratorIO, Scaling_test) stop = steady_clock::now(); duration = duration_cast(stop-start); if (rank == 0) - printf("MPIO writeSnapshot- duration: %dms\n", duration.count()); + printf("MPIO writeSnapshot- duration: %dms\n", duration.count()); MPI_Barrier(MPI_COMM_WORLD); start = steady_clock::now(); @@ -838,7 +838,7 @@ TEST(BasisGeneratorIO, Scaling_test) stop = steady_clock::now(); duration = duration_cast(stop-start); if (rank == 0) - printf("Base endSamples- duration: %dms\n", duration.count()); + printf("Base endSamples- duration: %dms\n", duration.count()); MPI_Barrier(MPI_COMM_WORLD); start = steady_clock::now(); @@ -847,7 +847,7 @@ TEST(BasisGeneratorIO, Scaling_test) stop = steady_clock::now(); duration = duration_cast(stop-start); if (rank == 0) - printf("MPIO endSamples- duration: %dms\n", duration.count()); + printf("MPIO endSamples- duration: %dms\n", duration.count()); } int main(int argc, char* argv[]) diff --git a/unit_tests/test_QR.cpp b/unit_tests/test_QR.cpp index be9cfd0d4..cdf4fe00f 100644 --- a/unit_tests/test_QR.cpp +++ b/unit_tests/test_QR.cpp @@ -50,7 +50,7 @@ TEST(QRfactorizeTest, Test_QR) EXPECT_EQ(total_rows, num_total_rows); double* q_data = new double[15] { - 3.08158946098238906153E-01, -9.49897947980619661301E-02, -4.50691774108525788911E-01, + 3.08158946098238906153E-01, -9.49897947980619661301E-02, -4.50691774108525788911E-01, -1.43697905723455976457E-01, 9.53289043424090820622E-01, 8.77767692937209131898E-02, -2.23655845793717528158E-02, -2.10628953513210204207E-01, 8.42235962392685943989E-01, -7.29903965154318323805E-01, -1.90917141788945754488E-01, -2.77280930877637610266E-01, @@ -59,17 +59,17 @@ TEST(QRfactorizeTest, Test_QR) double* r_data = new double[9] { -1.78651649346571794741E-01, 5.44387957786310106023E-01, -8.19588518467042281834E-01, - 0.0, -3.13100149275943651084E-01, -9.50441422536040881122E-04, - 0.0, 0.0, 5.72951792961765460355E-01 + 0.0, -3.13100149275943651084E-01, -9.50441422536040881122E-04, + 0.0, 0.0, 5.72951792961765460355E-01 }; CAROM::Matrix exactQ(loc_num_rows, num_columns, true); CAROM::Matrix exactR(r_data, num_columns, num_columns, false); for (int i = 0; i < loc_num_rows; i++) { - for (int j = 0; j < num_columns; j++) { - exactQ(i, j) = q_data[((i + row_offset[rank]) * num_columns) + j]; - } + for (int j = 0; j < num_columns; j++) { + exactQ(i, j) = q_data[((i + row_offset[rank]) * num_columns) + j]; + } } EXPECT_EQ(exactQ.numRows(), loc_num_rows); @@ -77,23 +77,23 @@ TEST(QRfactorizeTest, Test_QR) // Verify that the columns of Q are orthonormal. { - CAROM::Matrix *id = exactQ.transposeMult(exactQ); + CAROM::Matrix *id = exactQ.transposeMult(exactQ); - EXPECT_EQ(id->numRows(), num_columns); - EXPECT_EQ(id->numColumns(), num_columns); + EXPECT_EQ(id->numRows(), num_columns); + EXPECT_EQ(id->numColumns(), num_columns); - double maxError = 0.0; - for (int i = 0; i < num_columns; i++) { - for (int j = 0; j < num_columns; j++) { - const double delta_ij = i == j ? 1.0 : 0.0; - const double error = std::abs((*id)(i,j) - delta_ij); - maxError = std::max(maxError, error); - } - } + double maxError = 0.0; + for (int i = 0; i < num_columns; i++) { + for (int j = 0; j < num_columns; j++) { + const double delta_ij = i == j ? 1.0 : 0.0; + const double error = std::abs((*id)(i,j) - delta_ij); + maxError = std::max(maxError, error); + } + } - EXPECT_NEAR(maxError, 0.0, 1.0e-15); + EXPECT_NEAR(maxError, 0.0, 1.0e-15); - delete id; + delete id; } CAROM::Matrix *A = exactQ.mult(exactR); // Compute A = QR @@ -113,24 +113,24 @@ TEST(QRfactorizeTest, Test_QR) double maxError = 0.0; for (int i = 0; i < loc_num_rows; i++) { - for (int j = 0; j < num_columns; j++) { - const double error = std::abs(exactQ(i, j) + (*Q)(i, j)); - maxError = std::max(maxError, error); - } + for (int j = 0; j < num_columns; j++) { + const double error = std::abs(exactQ(i, j) + (*Q)(i, j)); + maxError = std::max(maxError, error); + } } EXPECT_NEAR(maxError, 0.0, 1.0e-15); if (rank > 0) return; - + EXPECT_EQ(R->numRows(), num_columns); EXPECT_EQ(R->numColumns(), num_columns); for (int i = 0; i < num_columns; i++) { - for (int j = 0; j < num_columns; j++) { - const double error = std::abs(exactR(i, j) + (*R)(i, j)); - maxError = std::max(maxError, error); - } + for (int j = 0; j < num_columns; j++) { + const double error = std::abs(exactR(i, j) + (*R)(i, j)); + maxError = std::max(maxError, error); + } } EXPECT_NEAR(maxError, 0.0, 1.0e-15);