MCPcopy Create free account
hub / github.com/PX4/eigen / randomPermutationVector

Function randomPermutationVector

test/main.h:597–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

595void randomPermutationVector(PermutationVectorType& v, Index size);
596template<typename PermutationVectorType>
597void randomPermutationVector(PermutationVectorType& v, Index size)
598{
599 typedef typename PermutationVectorType::Scalar Scalar;
600 v.resize(size);
601 for(Index i = 0; i < size; ++i) v(i) = Scalar(i);
602 if(size == 1) return;
603 for(Index n = 0; n < 3 * size; ++n)
604 {
605 Index i = internal::random<Index>(0, size-1);
606 Index j;
607 do j = internal::random<Index>(0, size-1); while(j==i);
608 std::swap(v(i), v(j));
609 }
610}
611
612template<typename T> bool isNotNaN(const T& x)
613{

Callers 2

sparse_permutationsFunction · 0.85
permutationmatricesFunction · 0.85

Calls 2

swapFunction · 0.70
resizeMethod · 0.45

Tested by

no test coverage detected