diff --git a/CMakeLists.txt b/CMakeLists.txt index afc39bb68171c04e64c70010878655b13e48aca1..0d04b975529508cfa6eedc5112ed09744402faae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,7 +266,6 @@ if( OGS_BUILD_TESTS AND NOT IS_SUBPROJECT ) if(OGS_USE_MPI) add_subdirectory( SimpleTests/MeshTests/MPI ) else() - add_subdirectory( SimpleTests/MatrixTests ) add_subdirectory( SimpleTests/MeshTests ) endif() endif() # OGS_BUILD_TESTS diff --git a/SimpleTests/MatrixTests/CMakeLists.txt b/SimpleTests/MatrixTests/CMakeLists.txt deleted file mode 100644 index f5db03f53f0d95ecfcd3fd16312c192f92720a89..0000000000000000000000000000000000000000 --- a/SimpleTests/MatrixTests/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Create the executable -add_executable(DenseGaussEliminationChecker - DenseGaussEliminationChecker.cpp - ${SOURCES} - ${HEADERS} -) -set_target_properties(DenseGaussEliminationChecker PROPERTIES FOLDER SimpleTests) -target_link_libraries(DenseGaussEliminationChecker - logog - BaseLib - MathLib -) diff --git a/SimpleTests/MatrixTests/DenseGaussEliminationChecker.cpp b/SimpleTests/MatrixTests/DenseGaussEliminationChecker.cpp deleted file mode 100644 index 6586c0affc0d4cfcee90395f43eb5879a78e39ae..0000000000000000000000000000000000000000 --- a/SimpleTests/MatrixTests/DenseGaussEliminationChecker.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/** - * \date 2014-06-11 - * \brief Implementation of tests. - * - * \copyright - * Copyright (c) 2012-2017, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include <fstream> -#include <sstream> - -#include <tclap/CmdLine.h> -#include <logog/include/logog.hpp> -#include <logog/include/formatter.hpp> - -#include "BaseLib/LogogSimpleFormatter.h" -#include "MathLib/LinAlg/Dense/DenseMatrix.h" -#include "MathLib/LinAlg/Solvers/GaussAlgorithm.h" - -int main(int argc, char *argv[]) -{ - LOGOG_INITIALIZE(); - auto* custom_format(new BaseLib::LogogSimpleFormatter); - auto* logogCout(new logog::Cout); - logogCout->SetFormatter(*custom_format); - - TCLAP::CmdLine cmd("Simple direct matrix solver test.\n\ - It consists of the following steps:\n\ - (1) Read a matrix A from ascii format\n\ - (2) Set all entries of a vector x to one and compute b = A * x\n\ - (3) Solve the system of linear equations -> result have to be (1,...,1)", ' ', "0.1"); - TCLAP::ValueArg<std::string> matrix_arg("m", "matrix", "input matrix file (ascii format)", true, "", "string"); - cmd.add( matrix_arg ); - cmd.parse( argc, argv ); - - // *** reading dense matrix in ascii format from file - std::string const fname_mat(matrix_arg.getValue()); - std::ifstream in(fname_mat.c_str()); - if (!in) { - INFO("error reading matrix from %s", fname_mat.c_str()); - return -1; - } - INFO("reading matrix from %s ...", fname_mat.c_str()); - std::size_t n_rows(0), n_cols(0); - in >> n_rows; - in >> n_cols; - MathLib::DenseMatrix<double, std::size_t> mat(n_rows, n_cols); - for (std::size_t i(0); i<mat.getNumberOfRows(); ++i) { - for (std::size_t j(0); j<mat.getNumberOfColumns(); ++j) { - in >> mat(i,j); - } - } - { - std::stringstream stream; - stream << mat; - INFO("read matrix:\n%s", stream.str().c_str()); - } - - std::vector<double> x(n_cols,1.0), b; - b.resize(n_rows); - b = mat * x; - - MathLib::GaussAlgorithm<MathLib::DenseMatrix<double, std::size_t>> gauss; - gauss.solve(mat, b, true); - - { - std::stringstream stream; - std::copy(b.begin(), b.end(), std::ostream_iterator<double>(stream, " ")); - stream << std::endl; - INFO("solution vector:\n%s", stream.str().c_str()); - } - - delete custom_format; - delete logogCout; - LOGOG_SHUTDOWN(); - - return 0; -} - diff --git a/Tests/MathLib/TestDenseGaussAlgorithm.cpp b/Tests/MathLib/TestDenseGaussAlgorithm.cpp deleted file mode 100644 index f7a9703501ae4b6526639d66f3218124fe0d32f8..0000000000000000000000000000000000000000 --- a/Tests/MathLib/TestDenseGaussAlgorithm.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @file TestDenseGaussAlgorithm.cpp - * @author Thomas Fischer - * @date Jun 17, 2013 - * @brief - * - * @copyright - * Copyright (c) 2012-2017, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/LICENSE.txt - */ - -#include <cstdlib> -#include <ctime> -#include <limits> -#include <algorithm> - -#include <gtest/gtest.h> - -#include "MathLib/LinAlg/Solvers/GaussAlgorithm.h" - -TEST(MathLib, DenseGaussAlgorithm) -{ - std::size_t n_rows(100); - std::size_t n_cols(n_rows); - - MathLib::DenseMatrix<double,std::size_t> mat(n_rows, n_cols); - - // *** fill matrix with arbitrary values - // ** initialize random seed - srand ( static_cast<unsigned>(time(nullptr)) ); - // ** loop over rows and columns - for (std::size_t i(0); i<n_rows; i++) { - for (std::size_t j(0); j<n_cols; j++) { - mat(i,j) = rand()/static_cast<double>(RAND_MAX); - } - } - - // *** create solution vector, set all entries to 0.0 - auto* x(new double[n_cols]); - std::fill(x,x+n_cols, 0.0); - double *b0(mat * x); - - // *** create other right hand sides, - // set all entries of the solution vector to 1.0 - std::fill(x,x+n_cols, 1.0); - double *b1(mat * x); - - std::generate(x,x+n_cols, std::rand); - double *b2(mat * x); - - // right hand side and solution vector with random entries - double *b3(mat * x); - double *b3_copy(mat * x); - auto* x3(new double[n_cols]); - std::generate(x3,x3+n_cols, std::rand); - - MathLib::GaussAlgorithm<MathLib::DenseMatrix<double, std::size_t>, double*> gauss; - - // solve with b0 as right hand side - gauss.solve(mat, b0, true); - for (std::size_t i(0); i<n_rows; i++) { - ASSERT_NEAR(b0[i], 0.0, std::numeric_limits<float>::epsilon()); - } - - // solve with b1 as right hand side - gauss.solve(mat, b1, false); - for (std::size_t i(0); i<n_rows; i++) { - ASSERT_NEAR(b1[i], 1.0, std::numeric_limits<float>::epsilon()); - } - - // solve with b2 as right hand side - gauss.solve(mat, b2, false); - for (std::size_t i(0); i<n_rows; i++) { - ASSERT_NEAR(fabs(b2[i]-x[i])/fabs(x[i]), 0.0, std::numeric_limits<float>::epsilon()); - } - - // solve with b3 as right hand side and x3 as solution vector - gauss.solve(mat, b3, x3, false); - for (std::size_t i(0); i<n_rows; i++) { - ASSERT_NEAR(fabs(x3[i]-x[i])/fabs(x[i]), 0.0, std::numeric_limits<float>::epsilon()); - } - // assure entries of vector b3 are not changed - for (std::size_t i(0); i<n_rows; i++) { - ASSERT_NEAR(fabs(b3[i]-b3_copy[i])/fabs(b3[i]), 0.0, std::numeric_limits<float>::epsilon()); - } - - delete [] x; - delete [] b0; - delete [] b1; - delete [] b2; - delete [] b3; - delete [] x3; - delete [] b3_copy; -} -