/** * \copyright * Copyright (c) 2012-2023, 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 #include "MathLib/LinAlg/MatrixVectorTraits.h" #include "MathLib/LinAlg/UnifiedMatrixSetters.h" #pragma once template void fillVectorRandomly(Vector& x) { std::random_device rd; std::mt19937 random_number_generator(rd()); std::uniform_real_distribution rnd; using Index = typename MathLib::MatrixVectorTraits::Index; Index const size = x.size(); for (Index i = 0; i < size; ++i) { MathLib::setVector(x, i, rnd(random_number_generator)); } #ifdef USE_PETSC finalizeVectorAssembly(x); #endif } inline void fillVectorRandomly(std::vector& x) { std::random_device rd; std::mt19937 random_number_generator(rd()); std::uniform_real_distribution rnd; for (auto& value : x) { value = rnd(random_number_generator); } } template void fillVectorRandomly(std::array& x) { std::random_device rd; std::mt19937 random_number_generator(rd()); std::uniform_real_distribution rnd; for (auto& value : x) { value = rnd(random_number_generator); } }