mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
add a unit test for permutation applied to sparse objects
This commit is contained in:
17
test/main.h
17
test/main.h
@@ -355,6 +355,23 @@ void createRandomPIMatrixOfRank(typename MatrixType::Index desired_rank, typenam
|
||||
m = qra.householderQ() * d * qrb.householderQ();
|
||||
}
|
||||
|
||||
template<typename PermutationVectorType>
|
||||
void randomPermutationVector(PermutationVectorType& v, typename PermutationVectorType::Index size)
|
||||
{
|
||||
typedef typename PermutationVectorType::Index Index;
|
||||
typedef typename PermutationVectorType::Scalar Scalar;
|
||||
v.resize(size);
|
||||
for(Index i = 0; i < size; ++i) v(i) = Scalar(i);
|
||||
if(size == 1) return;
|
||||
for(Index n = 0; n < 3 * size; ++n)
|
||||
{
|
||||
Index i = internal::random<Index>(0, size-1);
|
||||
Index j;
|
||||
do j = internal::random<Index>(0, size-1); while(j==i);
|
||||
std::swap(v(i), v(j));
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
template<typename T> struct GetDifferentType;
|
||||
|
||||
Reference in New Issue
Block a user