Revision ff64d3aab7611bc18d7c4319fa886b0df188df1c authored by Dmitri Naumov on 26 January 2021, 12:15:46 UTC, committed by Dmitri Naumov on 29 January 2021, 22:47:36 UTC
Fixes clang-tidy warning bugprone-use-after-move.
1 parent 6850352
VectorUtils.h
/**
* \copyright
* Copyright (c) 2012-2021, 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 <random>
#include "MathLib/LinAlg/MatrixVectorTraits.h"
#include "MathLib/LinAlg/UnifiedMatrixSetters.h"
template <typename Vector>
void fillVectorRandomly(Vector& x)
{
std::random_device rd;
std::mt19937 random_number_generator(rd());
std::uniform_real_distribution<double> rnd;
using Index = typename MathLib::MatrixVectorTraits<Vector>::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<double>& x)
{
std::random_device rd;
std::mt19937 random_number_generator(rd());
std::uniform_real_distribution<double> rnd;
for (auto& value : x)
{
value = rnd(random_number_generator);
}
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...