From 740f38b4d91101e90f4417a953d33b712f1be117 Mon Sep 17 00:00:00 2001 From: "Kevin\" Seung Whan Chung" Date: Wed, 9 Aug 2023 20:44:55 -0700 Subject: [PATCH] CI workflow for style check (#226) * scripts/stylize.sh: by default, checks if stylization is required. enforces the stylization by -f flag. * code-style ci test. must fail now since some files needs stylization. * minor fix for scripts/stylize.sh * returns error only when not enforced. * astyle option file * ran stylization * some manual edits. --- .astylerc | 1 + .github/workflows/ci.yml | 19 +++++++ lib/algo/DMD.cpp | 5 +- regression_tests/basisComparator.cpp | 34 +++++++---- regression_tests/fileComparator.cpp | 12 ++-- regression_tests/solutionComparator.cpp | 28 +++++---- scripts/stylize.sh | 76 +++++++++++++++++++++---- unit_tests/test_DEIM.cpp | 56 +++++++++--------- unit_tests/test_GNAT.cpp | 68 +++++++++++----------- unit_tests/test_Matrix.cpp | 6 +- unit_tests/test_QDEIM.cpp | 56 +++++++++--------- unit_tests/test_RandomizedSVD.cpp | 65 +++++++++++---------- unit_tests/test_S_OPT.cpp | 50 ++++++++-------- unit_tests/test_StaticSVD.cpp | 68 ++++++++++++---------- 14 files changed, 326 insertions(+), 218 deletions(-) create mode 100755 .astylerc mode change 100644 => 100755 lib/algo/DMD.cpp mode change 100644 => 100755 regression_tests/basisComparator.cpp mode change 100644 => 100755 unit_tests/test_Matrix.cpp diff --git a/.astylerc b/.astylerc new file mode 100755 index 000000000..16841dea3 --- /dev/null +++ b/.astylerc @@ -0,0 +1 @@ +--max-code-length=80 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09b812b27..393636546 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,25 @@ on: jobs: docker-image: uses: ./.github/workflows/docker.yml + code-style: + runs-on: ubuntu-latest + needs: [docker-image] + container: + image: ghcr.io/llnl/librom/librom_env:latest + options: --user 1001 --privileged + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.11.0 + with: + access_token: ${{ github.token }} + - name: Check out libROM + uses: actions/checkout@v3 + - name: Artistic Style version (for information) + run: astyle --version + - name: Check Stylization + run: | + cd ${GITHUB_WORKSPACE}/scripts + ./stylize.sh astyle linux: runs-on: ubuntu-latest needs: [docker-image] diff --git a/lib/algo/DMD.cpp b/lib/algo/DMD.cpp old mode 100644 new mode 100755 index 80aa7eb59..cb9f36b8a --- a/lib/algo/DMD.cpp +++ b/lib/algo/DMD.cpp @@ -547,8 +547,9 @@ DMD::projectInitialCondition(const Vector* init, double t_offset) Matrix* d_phi_imaginary_squared_2 = d_phi_imaginary->transposeMult(d_phi_real); *d_phi_imaginary_squared -= *d_phi_imaginary_squared_2; - double* inverse_input = new double[d_phi_real_squared->numRows() * - d_phi_real_squared->numColumns() * 2]; + const int dprs_row = d_phi_real_squared->numRows(); + const int dprs_col = d_phi_real_squared->numColumns(); + double* inverse_input = new double[dprs_row * dprs_col * 2]; for (int i = 0; i < d_phi_real_squared->numRows(); i++) { int k = 0; diff --git a/regression_tests/basisComparator.cpp b/regression_tests/basisComparator.cpp old mode 100644 new mode 100755 index adc726cb3..a6c436527 --- a/regression_tests/basisComparator.cpp +++ b/regression_tests/basisComparator.cpp @@ -18,7 +18,8 @@ using namespace std; -void compareBasis(string &baselineFile, string &targetFile, double errorBound, int numProcessors) { +void compareBasis(string &baselineFile, string &targetFile, double errorBound, + int numProcessors) { MPI_Init(NULL, NULL); // Get the number of processes @@ -35,8 +36,10 @@ void compareBasis(string &baselineFile, string &targetFile, double errorBound, i vector reducedDiffVecNormL2; CAROM::BasisReader baselineReader(baselineFile); - CAROM::Matrix *baselineBasis = (CAROM::Matrix*) baselineReader.getSpatialBasis(0.0); - CAROM::Vector *baselineSV = (CAROM::Vector*) baselineReader.getSingularValues(0.0); + CAROM::Matrix *baselineBasis = + (CAROM::Matrix*) baselineReader.getSpatialBasis(0.0); + CAROM::Vector *baselineSV = + (CAROM::Vector*) baselineReader.getSingularValues(0.0); CAROM::BasisReader targetReader(targetFile); CAROM::Matrix *targetBasis = (CAROM::Matrix*) targetReader.getSpatialBasis(0.0); CAROM::BasisReader diffReader(baselineFile); @@ -51,18 +54,21 @@ void compareBasis(string &baselineFile, string &targetFile, double errorBound, i // Test basis matrices have the same dimensions if (baselineNumRows != targetNumRows) { cerr << "The number of rows of the two basis matrices \ -are not equal in the following files: " << baselineFile << " and " << targetFile << endl; + are not equal in the following files: " << baselineFile + << " and " << targetFile << endl; MPI_Abort(MPI_COMM_WORLD, 1); } if (baselineNumColumns != targetNumColumns) { cerr << "The number of columns of the two basis matrices \ -are not equal in the following file: " << baselineFile << " and " << targetFile << endl; + are not equal in the following file: " << baselineFile + << " and " << targetFile << endl; MPI_Abort(MPI_COMM_WORLD, 1); } if (baselineSV->dim() != baselineNumColumns) { cerr << "The number of singular values does not equal the \ -number of basis vectors in the following file: " << baselineFile << endl; + number of basis vectors in the following file: " << baselineFile + << endl; MPI_Abort(MPI_COMM_WORLD, 1); } @@ -76,7 +82,8 @@ number of basis vectors in the following file: " << baselineFile << endl; } catch (const exception& e) { cerr << "Something went wrong when calculating the difference \ -between the basis matrices in the following files: " << baselineFile << " and " << targetFile << endl; + between the basis matrices in the following files: " << baselineFile + << " and " << targetFile << endl; MPI_Abort(MPI_COMM_WORLD, 1); } @@ -88,8 +95,10 @@ between the basis matrices in the following files: " << baselineFile << " and " } } - MPI_Reduce(vecNormL2.data(), reducedVecNormL2.data(), baselineNumColumns, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); - MPI_Reduce(diffVecNormL2.data(), reducedDiffVecNormL2.data(), baselineNumColumns, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); + MPI_Reduce(vecNormL2.data(), reducedVecNormL2.data(), baselineNumColumns, + MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); + MPI_Reduce(diffVecNormL2.data(), reducedDiffVecNormL2.data(), + baselineNumColumns, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); if (rank == 0) { double baselineNormL2 = 0.0; @@ -113,9 +122,12 @@ between the basis matrices in the following files: " << baselineFile << " and " // Test whether l2 norm is smaller than error bound if (error > errorBound) { - cerr << "baselineNormL2 = " << baselineNormL2 << ", diffNormL2 = " << diffNormL2 << endl; + cerr << "baselineNormL2 = " << baselineNormL2 << ", diffNormL2 = " << diffNormL2 + << endl; cerr << "error = " << error << endl; - cerr << "Error bound: " << errorBound << " was surpassed for the l2 norm of the difference of the basis matrices." << endl; + cerr << "Error bound: " << errorBound << + " was surpassed for the l2 norm of the difference of the basis matrices." << + endl; MPI_Abort(MPI_COMM_WORLD, 1); } } diff --git a/regression_tests/fileComparator.cpp b/regression_tests/fileComparator.cpp index 300753525..cdaa1ca8d 100644 --- a/regression_tests/fileComparator.cpp +++ b/regression_tests/fileComparator.cpp @@ -16,7 +16,8 @@ using namespace std; -void compareFiles(ifstream &baselineFile, ifstream &targetFile, double errorBound) { +void compareFiles(ifstream &baselineFile, ifstream &targetFile, + double errorBound) { string baselineLine, targetLine; double baselineNum, targetNum; int fileLine = 1; @@ -27,7 +28,8 @@ void compareFiles(ifstream &baselineFile, ifstream &targetFile, double errorBoun getline(baselineFile, baselineLine); getline(targetFile, targetLine); if (baselineLine == "" || targetLine == "") { - assert(baselineLine == targetLine || !(cerr << "The files are not the same length." << endl)); + assert(baselineLine == targetLine + || !(cerr << "The files are not the same length." << endl)); break; } @@ -50,12 +52,14 @@ void compareFiles(ifstream &baselineFile, ifstream &targetFile, double errorBoun if (error > errorBound) { cerr << "baseline = " << baselineNum << ", diff = " << diff << endl; cerr << "error = " << error << endl; - cerr << "Error bound: " << errorBound << " was surpassed on line: " << fileLine << endl; + cerr << "Error bound: " << errorBound << " was surpassed on line: " << fileLine + << endl; abort(); } fileLine++; } - assert(targetFile.eof() || !(cerr << "The files are not the same length." << endl)); + assert(targetFile.eof() + || !(cerr << "The files are not the same length." << endl)); } int main(int argc, char *argv[]) { diff --git a/regression_tests/solutionComparator.cpp b/regression_tests/solutionComparator.cpp index ff96a3172..9fe1faa81 100644 --- a/regression_tests/solutionComparator.cpp +++ b/regression_tests/solutionComparator.cpp @@ -27,7 +27,8 @@ int getDimensions(string &filePath) { return count; } -void compareSolutions(string &baselineFile, string &targetFile, double errorBound, int numProcessors) { +void compareSolutions(string &baselineFile, string &targetFile, + double errorBound, int numProcessors) { int* baselineDim = new int[numProcessors]; istream** baselineFiles = new istream*[numProcessors]; int* targetDim = new int[numProcessors]; @@ -45,7 +46,8 @@ void compareSolutions(string &baselineFile, string &targetFile, double errorBoun baselineDim[i] = getDimensions(baselineFile); } else { - cerr << "Something went wrong with opening the following file. Most likely it doesn't exist: " << baselineFile << endl; + cerr << "Something went wrong with opening the following file. Most likely it doesn't exist: " + << baselineFile << endl; abort(); } cout << "Solution Comparator is Opening file: " << targetFile << endl; @@ -54,7 +56,8 @@ void compareSolutions(string &baselineFile, string &targetFile, double errorBoun targetDim[i] = getDimensions(targetFile); } else { - cerr << "Something went wrong with opening the following file. Most likely it doesn't exist: " << targetFile << endl; + cerr << "Something went wrong with opening the following file. Most likely it doesn't exist: " + << targetFile << endl; abort(); } } @@ -65,7 +68,8 @@ void compareSolutions(string &baselineFile, string &targetFile, double errorBoun if (baseline.Size() != target.Size()) { cerr << "The solution vectors are different dimensions." << endl; - cerr << "Baseline dim: " << baseline.Size() << ", Target dim: " << target.Size() << endl; + cerr << "Baseline dim: " << baseline.Size() << ", Target dim: " << target.Size() + << endl; abort(); } @@ -81,14 +85,14 @@ between the solution vectors." << endl; double baselineNormL2 = baseline.Norml2(); double diffNormL2 = diff.Norml2(); // Check for NaN - if(std::isnan(baselineNormL2)){ + if(std::isnan(baselineNormL2)) { std::cerr << "baselineNormL2 is NaN" << std::endl; - if(std::isnan(diffNormL2)){ + if(std::isnan(diffNormL2)) { std::cerr << "diffNormL2 is NaN" << std::endl; } abort(); } - if(std::isnan(diffNormL2)){ + if(std::isnan(diffNormL2)) { std::cerr << "diffNormL2 is NaN" << std::endl; abort(); } @@ -101,12 +105,12 @@ between the solution vectors." << endl; } - if(std::isnan(baselineNormL2)){ + if(std::isnan(baselineNormL2)) { std::cout << "baselineNormL2 is NaN" << std::endl; abort(); } - if(std::isnan(diffNormL2)){ + if(std::isnan(diffNormL2)) { std::cout << "diffNormL2 is NaN" << std::endl; abort(); } @@ -114,9 +118,11 @@ between the solution vectors." << endl; // Test whether l2 norm is smaller than error bound if (error > errorBound) { - cerr << "baselineNormL2 = " << baselineNormL2 << ", diffNormL2 = " << diffNormL2 << endl; + cerr << "baselineNormL2 = " << baselineNormL2 << ", diffNormL2 = " << diffNormL2 + << endl; cerr << "error = " << error << endl; - cerr << "Error bound: " << errorBound << " was surpassed for the l2 norm of the difference of the solutions." << endl; + cerr << "Error bound: " << errorBound << + " was surpassed for the l2 norm of the difference of the solutions." << endl; abort(); } } diff --git a/scripts/stylize.sh b/scripts/stylize.sh index f472820c9..e2406bc8e 100755 --- a/scripts/stylize.sh +++ b/scripts/stylize.sh @@ -1,16 +1,70 @@ -if [ "$1" == "" ] || [ $# -gt 1 ]; then - echo "Usage: ./stylize.sh /path/to/astyle/executable" - exit 0 +#!/bin/bash +if [ "$1" == "" ] || [ $# -gt 2 ]; then + echo "Usage: ./stylize.sh [-f] /path/to/astyle/executable" + echo "Checks if stylization is required." + echo " -f: enforce stylization. By default, only the check is executed." + exit 1 +fi +ASTYLE_BIN=$1 +enforce=false + +# parse the flags. +while getopts f: flag +do + case "${flag}" in + f) + enforce=true + ASTYLE_BIN=$2 + ;; + *) + echo "Unknown option." + exit 1 + ;; + esac +done + +# astyle version check +ASTYLE_VER="Artistic Style Version 3.1" +astyle_version="$($ASTYLE_BIN --version)" +if [ "$astyle_version" != "$ASTYLE_VER" ]; then + printf "%s\n" "Invalid astyle version: '$astyle_version'"\ + "Please use: '$ASTYLE_VER'" + exit 1 +fi + +# astyle dry-run if not enforced. +if [ $enforce != true ]; then + ASTYLE_BIN="$ASTYLE_BIN --dry-run" fi DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR="$(dirname "$DIR")" -$1 --recursive --max-code-length=80 "$DIR/lib/*.cpp" -$1 --recursive --max-code-length=80 "$DIR/lib/*.h" -$1 --recursive --max-code-length=80 "$DIR/lib/*.hpp" -$1 --recursive --max-code-length=80 "$DIR/lib/*.c" -$1 --recursive --max-code-length=80 "$DIR/lib/*h.in" -$1 --recursive --max-code-length=80 "$DIR/tests/*.cpp" -$1 --recursive --max-code-length=80 "$DIR/examples/*.cpp" -$1 --recursive --max-code-length=80 "$DIR/examples/*.hpp" +FILELIST=("lib/*.cpp" + "lib/*.h" + "lib/*.hpp" + "lib/*.c" + "lib/*h.in" + "regression_tests/*.cpp" + "unit_tests/*.cpp" + "examples/*.cpp" + "examples/*.hpp") + +ASTYLE_COMMAND="$ASTYLE_BIN --recursive --project=../.astylerc" + +result=false +for files in ${FILELIST[@]} +do + echo $files + if $ASTYLE_COMMAND "$DIR/$files" | grep "Formatted"; then + result=true + fi +done + +if [ $enforce != true ] && [ $result = true ]; then + echo "Files need stylization!" + echo "Please run stylization before merging the pull-request." + echo " 1. Install $ASTYLE_VER" + echo " 2. cd scripts && ./stylize.sh -f /path/to/astyle" + exit 1 +fi diff --git a/unit_tests/test_DEIM.cpp b/unit_tests/test_DEIM.cpp index 6589d6c27..f977a6bf2 100644 --- a/unit_tests/test_DEIM.cpp +++ b/unit_tests/test_DEIM.cpp @@ -34,25 +34,25 @@ TEST(DEIMSerialTest, Test_DEIM) // Orthonormal input matrix to DEIM double* orthonormal_mat = new double[50] { -0.1067, -0.4723, -0.4552, 0.1104, -0.2337, - 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, - 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, - 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, - 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, - -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, - -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, - -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, - 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, - 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 - }; + 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, + 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, + 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, + 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, + -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, + -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, + -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, + 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, + 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 + }; // Result of DEIM (f_basis_sampled_inv) double* DEIM_true_ans = new double[25] { -0.295811, -0.264874, 1.02179, -1.05194, -0.554046, - -0.270643, 1.05349, 0.119162, 0.541832, 0.646459, - -1.33334, -0.874864, -0.276067, -0.27327, 0.124747, - 0.672776, 0.538704, -0.735484, -0.794417, 0.388543, - -0.682073, -0.049598, -0.51706, -0.457748, -1.11295 - }; + -0.270643, 1.05349, 0.119162, 0.541832, 0.646459, + -1.33334, -0.874864, -0.276067, -0.27327, 0.124747, + 0.672776, 0.538704, -0.735484, -0.794417, 0.388543, + -0.682073, -0.049598, -0.51706, -0.457748, -1.11295 + }; int num_cols = 5; int num_rows = 10; @@ -91,23 +91,23 @@ TEST(DEIMSerialTest, Test_DEIM_decreased_used_basis_vectors) // Orthonormal input matrix to DEIM double* orthonormal_mat = new double[50] { -0.1067, -0.4723, -0.4552, 0.1104, -0.2337, - 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, - 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, - 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, - 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, - -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, - -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, - -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, - 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, - 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 - }; + 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, + 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, + 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, + 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, + -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, + -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, + -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, + 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, + 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 + }; // Result of DEIM (f_basis_sampled_inv) double* DEIM_true_ans = new double[9] { -0.331632, -0.690455, 2.07025, - -0.541131, 1.17546, -0.446068, - -1.55764, -1.05777, -0.022448 - }; + -0.541131, 1.17546, -0.446068, + -1.55764, -1.05777, -0.022448 + }; int num_cols = 5; int num_rows = 10; diff --git a/unit_tests/test_GNAT.cpp b/unit_tests/test_GNAT.cpp index f92b6b203..be19dbee7 100644 --- a/unit_tests/test_GNAT.cpp +++ b/unit_tests/test_GNAT.cpp @@ -34,25 +34,25 @@ TEST(GNATSerialTest, Test_GNAT) // Orthonormal input matrix to GNAT double* orthonormal_mat = new double[50] { -0.1067, -0.4723, -0.4552, 0.1104, -0.2337, - 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, - 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, - 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, - 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, - -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, - -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, - -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, - 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, - 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 - }; + 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, + 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, + 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, + 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, + -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, + -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, + -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, + 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, + 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 + }; // Result of GNAT (f_basis_sampled_inv) double* GNAT_true_ans = new double[25] { -0.295811, -0.264874, 1.02179, -1.05194, -0.554046, - -0.270643, 1.05349, 0.119162, 0.541832, 0.646459, - -1.33334, -0.874864, -0.276067, -0.27327, 0.124747, - 0.672776, 0.538704, -0.735484, -0.794417, 0.388543, - -0.682073, -0.049598, -0.51706, -0.457748, -1.11295 - }; + -0.270643, 1.05349, 0.119162, 0.541832, 0.646459, + -1.33334, -0.874864, -0.276067, -0.27327, 0.124747, + 0.672776, 0.538704, -0.735484, -0.794417, 0.388543, + -0.682073, -0.049598, -0.51706, -0.457748, -1.11295 + }; int num_cols = 5; int num_rows = 10; @@ -91,29 +91,29 @@ TEST(GNATSerialTest, Test_GNAT_oversampling) // Orthonormal input matrix to GNAT double* orthonormal_mat = new double[50] { -0.1067, -0.4723, -0.4552, 0.1104, -0.2337, - 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, - 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, - 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, - 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, - -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, - -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, - -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, - 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, - 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 - }; + 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, + 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, + 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, + 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, + -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, + -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, + -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, + 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, + 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 + }; // Result of GNAT (f_basis_sampled_inv) double* GNAT_true_ans = new double[45] { -0.111754, -0.472181, -0.454143, 0.110436, -0.234925, - 0.169535, 0.691715, -0.276502, 0.166065, 0.362544, - 0.443111, -0.344589, 0.488125, -0.336035, 0.332789, - 0.556025, 0.154167, -0.172054, -0.344493, -0.294606, - -0.498551, 0.0149608,-0.191435, -0.576216, 0.00647047, - -0.247487, 0.328931, 0.293216, -0.459384, -0.134887, - -0.036157, 0.120386, -0.0906109,-0.228902, -0.382862, - 0.478391, -0.0208761,-0.342018, -0.171577, -0.2125, - -0.0109879, 0.181169, 0.453212, 0.322187, -0.640965 - }; + 0.169535, 0.691715, -0.276502, 0.166065, 0.362544, + 0.443111, -0.344589, 0.488125, -0.336035, 0.332789, + 0.556025, 0.154167, -0.172054, -0.344493, -0.294606, + -0.498551, 0.0149608,-0.191435, -0.576216, 0.00647047, + -0.247487, 0.328931, 0.293216, -0.459384, -0.134887, + -0.036157, 0.120386, -0.0906109,-0.228902, -0.382862, + 0.478391, -0.0208761,-0.342018, -0.171577, -0.2125, + -0.0109879, 0.181169, 0.453212, 0.322187, -0.640965 + }; int num_cols = 5; int num_rows = 10; diff --git a/unit_tests/test_Matrix.cpp b/unit_tests/test_Matrix.cpp old mode 100644 new mode 100755 index 7aa3cce24..b89defa37 --- a/unit_tests/test_Matrix.cpp +++ b/unit_tests/test_Matrix.cpp @@ -1427,12 +1427,14 @@ TEST(MatrixParallelTest, Test_distribute_and_gather) int local_rows = CAROM::split_dimension(total_rows, MPI_COMM_WORLD); std::vector row_offsets; - int total_rows_check = CAROM::get_global_offsets(local_rows, row_offsets, MPI_COMM_WORLD); + int total_rows_check = + CAROM::get_global_offsets(local_rows, row_offsets, MPI_COMM_WORLD); EXPECT_EQ(total_rows, total_rows_check); CAROM::Matrix test(answer); test.distribute(local_rows); - for (int local_i = 0, global_i = row_offsets[my_rank]; local_i < local_rows; local_i++, global_i++) + for (int local_i = 0, global_i = row_offsets[my_rank]; local_i < local_rows; + local_i++, global_i++) for (int j = 0; j < answer.numColumns(); j++) EXPECT_DOUBLE_EQ(test.item(local_i, j), answer.item(global_i, j)); diff --git a/unit_tests/test_QDEIM.cpp b/unit_tests/test_QDEIM.cpp index 822d29487..d40e2bfe9 100644 --- a/unit_tests/test_QDEIM.cpp +++ b/unit_tests/test_QDEIM.cpp @@ -34,16 +34,16 @@ TEST(QDEIMSerialTest, Test_QDEIM) // Orthonormal input matrix to QDEIM double* orthonormal_mat = new double[50] { -0.1067, -0.4723, -0.4552, 0.1104, -0.2337, - 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, - 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, - 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, - 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, - -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, - -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, - -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, - 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, - 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 - }; + 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, + 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, + 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, + 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, + -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, + -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, + -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, + 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, + 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 + }; // Result of QDEIM (f_basis_sampled_inv) double* QDEIM_true_ans = new double[25] { @@ -91,28 +91,28 @@ TEST(QDEIMSerialTest, Test_QDEIM_gpode_oversampling) // Orthonormal input matrix to QDEIM double* orthonormal_mat = new double[50] { -0.1067, -0.4723, -0.4552, 0.1104, -0.2337, - 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, - 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, - 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, - 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, - -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, - -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, - -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, - 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, - 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 - }; + 0.1462, 0.6922, -0.2716, 0.1663, 0.3569, + 0.4087, -0.3437, 0.4952, -0.3356, 0.3246, + 0.2817, -0.0067, -0.0582, -0.0034, 0.0674, + 0.5147, 0.1552, -0.1635, -0.3440, -0.3045, + -0.4628, 0.0141, -0.1988, -0.5766, 0.0150, + -0.2203, 0.3283, 0.2876, -0.4597, -0.1284, + -0.0275, 0.1202, -0.0924, -0.2290, -0.3808, + 0.4387, -0.0199, -0.3338, -0.1711, -0.2220, + 0.0101, 0.1807, 0.4488, 0.3219, -0.6359 + }; // Result of QDEIM (f_basis_sampled_inv) double* QDEIM_true_ans = new double[40] { -0.114191, -0.464064, -0.460252, 0.0950032, -0.260738, - 0.172884, 0.680565, -0.268109, 0.187266, 0.398005, - 0.450012, -0.367566, 0.505419, -0.292346, 0.405863, - 0.546255, 0.186697, -0.196538, -0.406346, -0.39806, - -0.506112, 0.0401362, -0.210384, -0.624084, -0.0735944, - -0.255659, 0.356138, 0.272739, -0.511115, -0.221413, - 0.472064, 0.00019259, -0.357875, -0.211637, -0.279505, - -0.0179827, 0.204459, 0.435683, 0.277904, -0.715033 - }; + 0.172884, 0.680565, -0.268109, 0.187266, 0.398005, + 0.450012, -0.367566, 0.505419, -0.292346, 0.405863, + 0.546255, 0.186697, -0.196538, -0.406346, -0.39806, + -0.506112, 0.0401362, -0.210384, -0.624084, -0.0735944, + -0.255659, 0.356138, 0.272739, -0.511115, -0.221413, + 0.472064, 0.00019259, -0.357875, -0.211637, -0.279505, + -0.0179827, 0.204459, 0.435683, 0.277904, -0.715033 + }; int num_cols = 5; int num_rows = 10; diff --git a/unit_tests/test_RandomizedSVD.cpp b/unit_tests/test_RandomizedSVD.cpp index a3080fbaa..4e243b2fd 100644 --- a/unit_tests/test_RandomizedSVD.cpp +++ b/unit_tests/test_RandomizedSVD.cpp @@ -61,9 +61,9 @@ TEST(RandomizedSVDTest, Test_RandomizedSVD) double* basis_right_true_ans = new double[9] { -1.78651649346571794741E-01, 5.44387957786310106023E-01, -8.19588518467042281834E-01, - -9.49719639253861602768E-01, -3.13100149275943651084E-01, -9.50441422536040881122E-04, - -2.57130696341890396805E-01, 7.78209514167382598870E-01, 5.72951792961765460355E-01 - }; + -9.49719639253861602768E-01, -3.13100149275943651084E-01, -9.50441422536040881122E-04, + -2.57130696341890396805E-01, 7.78209514167382598870E-01, 5.72951792961765460355E-01 + }; double* sv_true_ans = new double[3] { 4.84486375065219387892E+00, 3.66719976398777269821E+00, 2.69114625366671811335E+00 @@ -132,18 +132,18 @@ TEST(RandomizedSVDTest, Test_RandomizedSVDTransposed) double* sample5 = new double[3] {0.3188, 2.7694, 0.7147}; double* basis_right_true_ans = new double[15] { - 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, - -5.92561353877168350834E-01, -3.74570084880578441089E-02, 5.40928141934190823137E-02, + 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, + -5.92561353877168350834E-01, -3.74570084880578441089E-02, 5.40928141934190823137E-02, }; double* basis_true_ans = new double[9] { - -1.78651649346571794741E-01, 5.44387957786310106023E-01, -8.19588518467042281834E-01, - -9.49719639253861602768E-01, -3.13100149275943651084E-01, -9.50441422536040881122E-04, - -2.57130696341890396805E-01, 7.78209514167382598870E-01, 5.72951792961765460355E-01, - }; + -1.78651649346571794741E-01, 5.44387957786310106023E-01, -8.19588518467042281834E-01, + -9.49719639253861602768E-01, -3.13100149275943651084E-01, -9.50441422536040881122E-04, + -2.57130696341890396805E-01, 7.78209514167382598870E-01, 5.72951792961765460355E-01, + }; double* sv_true_ans = new double[3] { 4.84486375065219387892E+00, 3.66719976398777269821E+00, 2.69114625366671811335E+00, @@ -179,7 +179,8 @@ TEST(RandomizedSVDTest, Test_RandomizedSVDTransposed) } for (int i = 0; i < d_num_rows * 3; i++) { - EXPECT_NEAR(abs(d_basis_vals[i]), abs(basis_true_ans[row_offset[d_rank] * 3 + i]), 1e-7); + EXPECT_NEAR(abs(d_basis_vals[i]), + abs(basis_true_ans[row_offset[d_rank] * 3 + i]), 1e-7); } for (int i = 0; i < 3; i++) { @@ -210,17 +211,17 @@ TEST(RandomizedSVDTest, Test_RandomizedSVDSmallerSubspace) double* sample3 = new double[5] {-1.3499, 3.0349, 0.7254, -0.0631, 0.7147}; double* basis_true_ans = new double[10] { - 2.46707456258500545943E-01, 2.40668223895116051292E-01, - 1.22600535968995782987E-02, 6.13241535464043252546E-01, - 2.43268241912782956504E-02, -7.45453669205227487105E-01, - -7.73110544854238135315E-01, 9.33140592900994769732E-02, - -5.83689483520313912024E-01, -4.00616848889396720557E-02, + 2.46707456258500545943E-01, 2.40668223895116051292E-01, + 1.22600535968995782987E-02, 6.13241535464043252546E-01, + 2.43268241912782956504E-02, -7.45453669205227487105E-01, + -7.73110544854238135315E-01, 9.33140592900994769732E-02, + -5.83689483520313912024E-01, -4.00616848889396720557E-02, }; double* basis_right_true_ans = new double[4] { - -1.56565710761715548571E-01, 9.35014519663929455362E-01, - -9.78462684973472551775E-01, -1.90716931883349205545E-01, - }; + -1.56565710761715548571E-01, 9.35014519663929455362E-01, + -9.78462684973472551775E-01, -1.90716931883349205545E-01, + }; double* sv_true_ans = new double[2] { 4.80607940538476441361E+00, 3.21443716375044896694E+00, @@ -289,17 +290,17 @@ TEST(RandomizedSVDTest, Test_RandomizedSVDTransposedSmallerSubspace) double* sample5 = new double[5] {0.3188, 2.7694, 0.7147}; double* basis_right_true_ans = new double[10] { - 2.46707456258500545943E-01, 2.40668223895116051292E-01, - 1.22600535968995782987E-02, 6.13241535464043252546E-01, - 2.43268241912782956504E-02, -7.45453669205227487105E-01, - -7.73110544854238135315E-01, 9.33140592900994769732E-02, - -5.83689483520313912024E-01, -4.00616848889396720557E-02, + 2.46707456258500545943E-01, 2.40668223895116051292E-01, + 1.22600535968995782987E-02, 6.13241535464043252546E-01, + 2.43268241912782956504E-02, -7.45453669205227487105E-01, + -7.73110544854238135315E-01, 9.33140592900994769732E-02, + -5.83689483520313912024E-01, -4.00616848889396720557E-02, }; double* basis_true_ans = new double[4] { - -1.56565710761715548571E-01, 9.35014519663929455362E-01, - -9.78462684973472551775E-01, -1.90716931883349205545E-01, - }; + -1.56565710761715548571E-01, 9.35014519663929455362E-01, + -9.78462684973472551775E-01, -1.90716931883349205545E-01, + }; double* sv_true_ans = new double[2] { 4.80607940538476441361E+00, 3.21443716375044896694E+00, @@ -321,7 +322,8 @@ TEST(RandomizedSVDTest, Test_RandomizedSVDTransposedSmallerSubspace) const CAROM::Vector* sv = sampler.getSingularValues(); d_num_rows = CAROM::split_dimension(reduced_rows, MPI_COMM_WORLD); - int reduced_rows_check = CAROM::get_global_offsets(d_num_rows, row_offset, MPI_COMM_WORLD); + int reduced_rows_check = CAROM::get_global_offsets(d_num_rows, row_offset, + MPI_COMM_WORLD); EXPECT_EQ(d_basis_right->numRows(), num_samples); EXPECT_EQ(d_basis_right->numColumns(), reduced_rows); @@ -338,7 +340,8 @@ TEST(RandomizedSVDTest, Test_RandomizedSVDTransposedSmallerSubspace) } for (int i = 0; i < d_num_rows * reduced_rows; i++) { - EXPECT_NEAR(abs(d_basis_vals[i]), abs(basis_true_ans[row_offset[d_rank] * reduced_rows + i]), 1e-7); + EXPECT_NEAR(abs(d_basis_vals[i]), + abs(basis_true_ans[row_offset[d_rank] * reduced_rows + i]), 1e-7); } for (int i = 0; i < reduced_rows; i++) { diff --git a/unit_tests/test_S_OPT.cpp b/unit_tests/test_S_OPT.cpp index e8f7cfff5..159cc384c 100644 --- a/unit_tests/test_S_OPT.cpp +++ b/unit_tests/test_S_OPT.cpp @@ -89,16 +89,16 @@ TEST(S_OPTSerialTest, Test_S_OPT) // Result of S_OPT (f_basis_sampled_inv) double* S_OPT_true_ans = new double[50] { -0.5918106, 1.141427, 1.142373, 1.477501, -0.7002456, - -1.204534, 1.608694, 0.5777631, -0.8686062, 0.9839489, - -1.21845, 1.569369, 0.4668517, -0.958101, 0.9462786, - -1.023713, 0.2118963, -1.029118, -0.3487639, -0.740034, - -1.016572, 0.1513296, -1.060517, -0.2849657, -0.774013, - -1.009973, 0.0911333, -1.088985, -0.2200843, -0.8032426, - -1.107097, -0.8899746, -0.7112781, 1.030203, 0.2788396, - -1.173239, -1.002324, -0.1872992, 1.061846, 0.969148, - -1.040098, -1.004302, 0.8125958, 0.2427455, 0.9231714, - -0.570251, -0.9721371, 1.327513, -1.113124, -1.083388 - }; + -1.204534, 1.608694, 0.5777631, -0.8686062, 0.9839489, + -1.21845, 1.569369, 0.4668517, -0.958101, 0.9462786, + -1.023713, 0.2118963, -1.029118, -0.3487639, -0.740034, + -1.016572, 0.1513296, -1.060517, -0.2849657, -0.774013, + -1.009973, 0.0911333, -1.088985, -0.2200843, -0.8032426, + -1.107097, -0.8899746, -0.7112781, 1.030203, 0.2788396, + -1.173239, -1.002324, -0.1872992, 1.061846, 0.969148, + -1.040098, -1.004302, 0.8125958, 0.2427455, 0.9231714, + -0.570251, -0.9721371, 1.327513, -1.113124, -1.083388 + }; int index = 0; for (int i = 0; i < num_rows; i++) @@ -209,11 +209,11 @@ TEST(S_OPTSerialTest, Test_S_OPT_less_basis_vectors) // Result of S_OPT (f_basis_sampled_inv) double* S_OPT_true_ans = new double[15] { -1.433786, 2.925154, 2.209402, - -1.861405, 0.6665424, -1.247851, - -1.890357, 0.5250462, -1.304832, - -1.935721, 0.3061151, -1.365598, - -2.835807, -3.503679, 1.97353 - }; + -1.861405, 0.6665424, -1.247851, + -1.890357, 0.5250462, -1.304832, + -1.935721, 0.3061151, -1.365598, + -2.835807, -3.503679, 1.97353 + }; int index = 0; for (int i = 0; i < num_rows; i++) @@ -325,11 +325,11 @@ TEST(S_OPTSerialTest, Test_S_OPT_init_vector) // Result of S_OPT (f_basis_sampled_inv) double* S_OPT_true_ans = new double[15] { -1.433786, 2.925154, 2.209402, - -1.861405, 0.6665424, -1.247851, - -1.890357, 0.5250462, -1.304832, - -1.935721, 0.3061151, -1.365598, - -2.835807, -3.503679, 1.97353 - }; + -1.861405, 0.6665424, -1.247851, + -1.890357, 0.5250462, -1.304832, + -1.935721, 0.3061151, -1.365598, + -2.835807, -3.503679, 1.97353 + }; int index = 0; for (int i = 0; i < num_rows; i++) @@ -484,11 +484,11 @@ TEST(S_OPTSerialTest, Test_S_OPT_QR) // Result of S_OPT (f_basis_sampled_inv) double* S_OPT_true_ans = new double[15] { -1.433785, -2.925153, -2.209402, - -1.861404, -0.6665415, 1.24785, - -1.890357, -0.5250456, 1.304833, - -1.93572, -0.3061142, 1.365598, - -2.835807, 3.503679, -1.97353 - }; + -1.861404, -0.6665415, 1.24785, + -1.890357, -0.5250456, 1.304833, + -1.93572, -0.3061142, 1.365598, + -2.835807, 3.503679, -1.97353 + }; int index = 0; for (int i = 0; i < num_rows; i++) diff --git a/unit_tests/test_StaticSVD.cpp b/unit_tests/test_StaticSVD.cpp index 3d0aaacc1..7d99960d9 100644 --- a/unit_tests/test_StaticSVD.cpp +++ b/unit_tests/test_StaticSVD.cpp @@ -128,28 +128,30 @@ TEST(StaticSVDTest, Test_SLPKTranspose) constexpr int num_total_cols = 5; int d_num_rows = CAROM::split_dimension(num_total_rows, MPI_COMM_WORLD); std::vector row_offset(d_num_procs + 1); - const int total_rows = CAROM::get_global_offsets(d_num_rows, row_offset, MPI_COMM_WORLD); + const int total_rows = CAROM::get_global_offsets(d_num_rows, row_offset, + MPI_COMM_WORLD); EXPECT_EQ(total_rows, num_total_rows); double* samples = new double[15] {0.5377, -1.3077, -1.3499, 1.8339, -0.4336, 3.0349, -2.2588, 0.3426, 0.7254, 0.8622, 3.5784, -0.0631, - 0.3188, 2.7694, 0.7147}; + 0.3188, 2.7694, 0.7147 + }; double* basis_right_true_ans = new double[15] { - 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, - -5.92561353877168350834E-01, -3.74570084880578441089E-02, 5.40928141934190823137E-02, + 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, + -5.92561353877168350834E-01, -3.74570084880578441089E-02, 5.40928141934190823137E-02, }; double* basis_true_ans = new double[9] { - -1.78651649346571794741E-01, 5.44387957786310106023E-01, -8.19588518467042281834E-01, - -9.49719639253861602768E-01, -3.13100149275943651084E-01, -9.50441422536040881122E-04, - -2.57130696341890396805E-01, 7.78209514167382598870E-01, 5.72951792961765460355E-01, - }; + -1.78651649346571794741E-01, 5.44387957786310106023E-01, -8.19588518467042281834E-01, + -9.49719639253861602768E-01, -3.13100149275943651084E-01, -9.50441422536040881122E-04, + -2.57130696341890396805E-01, 7.78209514167382598870E-01, 5.72951792961765460355E-01, + }; double* sv_true_ans = new double[3] { 4.84486375065219387892E+00, 3.66719976398777269821E+00, 2.69114625366671811335E+00, @@ -158,7 +160,8 @@ TEST(StaticSVDTest, Test_SLPKTranspose) SLPK_Matrix *d_samples = new SLPK_Matrix; std::vector d_dims; d_dims.resize(static_cast(d_num_procs)); - MPI_Allgather(&d_num_rows, 1, MPI_INT, d_dims.data(), 1, MPI_INT, MPI_COMM_WORLD); + MPI_Allgather(&d_num_rows, 1, MPI_INT, d_dims.data(), 1, MPI_INT, + MPI_COMM_WORLD); int d_total_dim = 0; std::vector d_istarts(static_cast(d_num_procs), 0); @@ -185,8 +188,8 @@ TEST(StaticSVDTest, Test_SLPKTranspose) const double *u_in = &samples[3*s]; for (int rank = 0; rank < d_num_procs; ++rank) { scatter_block(d_samples, d_istarts[static_cast(rank)]+1, - s+1, u_in, d_dims[static_cast(rank)], - 1, rank); + s+1, u_in, d_dims[static_cast(rank)], + 1, rank); } } printf("original\n"); @@ -221,7 +224,8 @@ TEST(StaticSVDTest, Test_SLPKTranspose) int ncolumns = num_total_rows; CAROM::Matrix *d_basis = new CAROM::Matrix(d_dims[d_rank], ncolumns, true); - CAROM::Matrix *d_basis_right = new CAROM::Matrix(ncolumns, num_total_cols, false); + CAROM::Matrix *d_basis_right = new CAROM::Matrix(ncolumns, num_total_cols, + false); for (int rank = 0; rank < d_num_procs; ++rank) { // gather_transposed_block does the same as gather_block, but transposes @@ -230,8 +234,8 @@ TEST(StaticSVDTest, Test_SLPKTranspose) 1, 1, num_total_cols, ncolumns, rank); // V is computed in the transposed order so no reordering necessary. gather_block(&d_basis->item(0, 0), d_factorizer->V, - 1, d_istarts[static_cast(rank)]+1, - ncolumns, d_dims[static_cast(rank)], rank); + 1, d_istarts[static_cast(rank)]+1, + ncolumns, d_dims[static_cast(rank)], rank); } delete d_basis, d_basis_right; @@ -255,7 +259,8 @@ TEST(StaticSVDTest, Test_StaticSVDClass) constexpr int num_total_rows = 5; int d_num_rows = CAROM::split_dimension(num_total_rows, MPI_COMM_WORLD); std::vector row_offset(d_num_procs + 1); - const int total_rows = CAROM::get_global_offsets(d_num_rows, row_offset, MPI_COMM_WORLD); + const int total_rows = CAROM::get_global_offsets(d_num_rows, row_offset, + MPI_COMM_WORLD); EXPECT_EQ(total_rows, num_total_rows); double* sample1 = new double[5] {0.5377, 1.8339, -2.2588, 0.8622, 0.3188}; @@ -272,9 +277,9 @@ TEST(StaticSVDTest, Test_StaticSVDClass) double* basis_right_true_ans = new double[9] { -1.78651649346571794741E-01, 5.44387957786310106023E-01, -8.19588518467042281834E-01, - -9.49719639253861602768E-01, -3.13100149275943651084E-01, -9.50441422536040881122E-04, - -2.57130696341890396805E-01, 7.78209514167382598870E-01, 5.72951792961765460355E-01 - }; + -9.49719639253861602768E-01, -3.13100149275943651084E-01, -9.50441422536040881122E-04, + -2.57130696341890396805E-01, 7.78209514167382598870E-01, 5.72951792961765460355E-01 + }; double* sv_true_ans = new double[3] { 4.84486375065219387892E+00, 3.66719976398777269821E+00, 2.69114625366671811335E+00 @@ -332,7 +337,8 @@ TEST(StaticSVDTest, Test_StaticSVDTranspose) constexpr int num_total_cols = 5; int d_num_rows = CAROM::split_dimension(num_total_rows, MPI_COMM_WORLD); std::vector row_offset(d_num_procs + 1); - const int total_rows = CAROM::get_global_offsets(d_num_rows, row_offset, MPI_COMM_WORLD); + const int total_rows = CAROM::get_global_offsets(d_num_rows, row_offset, + MPI_COMM_WORLD); EXPECT_EQ(total_rows, num_total_rows); double* sample1 = new double[5] {0.5377, -1.3077, -1.3499}; @@ -342,18 +348,18 @@ TEST(StaticSVDTest, Test_StaticSVDTranspose) double* sample5 = new double[5] {0.3188, 2.7694, 0.7147}; double* basis_right_true_ans = new double[15] { - 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, - -5.92561353877168350834E-01, -3.74570084880578441089E-02, 5.40928141934190823137E-02, + 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, + -5.92561353877168350834E-01, -3.74570084880578441089E-02, 5.40928141934190823137E-02, }; double* basis_true_ans = new double[9] { - -1.78651649346571794741E-01, 5.44387957786310106023E-01, -8.19588518467042281834E-01, - -9.49719639253861602768E-01, -3.13100149275943651084E-01, -9.50441422536040881122E-04, - -2.57130696341890396805E-01, 7.78209514167382598870E-01, 5.72951792961765460355E-01, - }; + -1.78651649346571794741E-01, 5.44387957786310106023E-01, -8.19588518467042281834E-01, + -9.49719639253861602768E-01, -3.13100149275943651084E-01, -9.50441422536040881122E-04, + -2.57130696341890396805E-01, 7.78209514167382598870E-01, 5.72951792961765460355E-01, + }; double* sv_true_ans = new double[3] { 4.84486375065219387892E+00, 3.66719976398777269821E+00, 2.69114625366671811335E+00,