mitsuba-af602c6fd98a/src/samplers/faure.cpp
/**
 * \ref Compute the Faure permutations using dynamic programming
 *
 * For reference, see "Good permutations for extreme discrepancy"
 * by Henri Faure, Journal of Number Theory, Vol. 42, 1, 1992.
 */
\ref Compute the Faure permutations using dynamic programming
For reference, see "Good permutations for extreme discrepancy"
by Henri Faure, Journal of Number Theory, Vol.
\ ref Compute the Faure permutations using dynamic programming For reference see " Good permutations for extreme discrepancy " by Henri Faure Journal of Number Theory Vol .
void PermutationStorage::computeFaurePermutations(uint32_t maxBase, uint16_t **perm) {
	SAssert(maxBase >= 2);
	perm[1][0] = 0;
	perm[2][0] = 0;
	perm[2][1] = 1;
	for (uint32_t b=2; b<=maxBase; ++b) {
		if (b & 1) {
			uint16_t c = (b - 1) /2;
			for (uint16_t i=0; i<b; ++i) {
				if (i == c) {
					perm[b][i] = c;
				} else {
					uint16_t f = perm[b-1][i - (int) (i>c)];
					perm[b][i] = f + (int) (f >= c);
				}
			}
		} else {
			uint16_t c = b / 2;
			for (uint16_t i=0; i<b; ++i)
				perm[b][i] = i < c ? 2*perm[c][i] : 2*perm[c][i-c]+1;;
		}
	}
}
void PermutationStorage :: computeFaurePermutations ( uint32_t maxBase , uint16_t * * perm ) { SAssert ( maxBase >= 2 ) ; perm [ 1 ] [ 0 ] = 0 ; perm [ 2 ] [ 0 ] = 0 ; perm [ 2 ] [ 1 ] = 1 ; for ( uint32_t b = 2 ; b <= maxBase ; ++ b ) { if ( b & 1 ) { uint16_t c = ( b - 1 ) / 2 ; for ( uint16_t i = 0 ; i < b ; ++ i ) { if ( i == c ) { perm [ b ] [ i ] = c ; } else { uint16_t f = perm [ b - 1 ] [ i - ( int ) ( i > c ) ] ; perm [ b ] [ i ] = f + ( int ) ( f >= c ) ; } } } else { uint16_t c = b / 2 ; for ( uint16_t i = 0 ; i < b ; ++ i ) perm [ b ] [ i ] = i < c ? 2 * perm [ c ] [ i ] : 2 * perm [ c ] [ i - c ] + 1 ; ; } } }
\ref Compute the Faure permutations using dynamic programming
 For reference, see "Good permutations for extreme discrepancy"
 by Henri Faure, Journal of Number Theory, Vol.
\ ref Compute the Faure permutations using dynamic programming For reference see " Good permutations for extreme discrepancy " by Henri Faure Journal of Number Theory Vol .
/* Dimension 1 */ /* Dimension 2 */ /* Odd dimension */ /* Even dimension */