Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::math Namespace Reference

Classes

struct  AliasTableEntry
 Alias sampling data structure (see makeAliasTable() for details) More...
 
struct  SSEVector4f
 
struct  SSEVector4i
 

Functions

template<typename Scalar , typename QuantizedScalar , typename Index >
float makeAliasTable (AliasTableEntry< QuantizedScalar, Index > *tbl, Scalar *pmf, Index size)
 Create the lookup table needed for Walker's alias sampling method implemented in sampleAlias(). Runs in linear time. More...
 
template<typename Scalar , typename QuantizedScalar , typename Index >
Index sampleAlias (const AliasTableEntry< QuantizedScalar, Index > *tbl, Index size, Scalar sample)
 Generate a sample in constant time using the alias method. More...
 
template<typename Scalar , typename QuantizedScalar , typename Index >
Index sampleAliasReuse (const AliasTableEntry< QuantizedScalar, Index > *tbl, Index size, Scalar &sample)
 Generate a sample in constant time using the alias method. More...
 
template<int idx3, int idx2, int idx1, int idx0>
SSEVector4f shuffle (const SSEVector4f &low, const SSEVector4f &hi)
 
template<int idx3, int idx2, int idx1, int idx0>
SSEVector4f shuffle (const SSEVector4f &a)
 
SSEVector4i castAsInt (const SSEVector4f &a)
 Reinterprets as a SSEVector4i. More...
 
SSEVector4i toInt (const SSEVector4f &a)
 Convert a to integer using truncate. More...
 
SSEVector4i roundToInt (const SSEVector4f &a)
 Converts a to integer using round. More...
 
SSEVector4f castAsFloat (const SSEVector4i &a)
 Reinterprets a as a SSEVector4f. More...
 
SSEVector4f toFloat (const SSEVector4i &a)
 Convert a to floating point. More...
 
FINLINE void transpose (SSEVector4f &row0, SSEVector4f &row1, SSEVector4f &row2, SSEVector4f &row3)
 The arguments row0, row1, row2 and row3 are __m128 values whose elements form the corresponding rows of a 4-by-4 matrix. The matrix transposition is returned in arguments row0, row1, row2 and row3 where row0 now holds column 0 of the original matrix, row1 now holds column 1 of the original matrix, and so on. More...
 

Function Documentation

SSEVector4f mitsuba::math::castAsFloat ( const SSEVector4i &  a)
inline

Reinterprets a as a SSEVector4f.

SSEVector4i mitsuba::math::castAsInt ( const SSEVector4f &  a)
inline

Reinterprets as a SSEVector4i.

template<typename Scalar , typename QuantizedScalar , typename Index >
float mitsuba::math::makeAliasTable ( AliasTableEntry< QuantizedScalar, Index > *  tbl,
Scalar *  pmf,
Index  size 
)

Create the lookup table needed for Walker's alias sampling method implemented in sampleAlias(). Runs in linear time.

The basic idea of this method is that one can "redistribute" the probability mass of a distribution to make it uniform. This this can be done in a way such that the probability of each entry in the "flattened" PMF consists of probability mass from at most two entries in the original PMF. That then leads to an efficient O(1) sampling algorithm with a O(n) preprocessing step to set up this special decomposition.

The downside of this method is that it generally does not preserve the nice stratification properties of QMC number sequences.

Returns
The original (un-normalized) sum of all probabilities in pmf.
SSEVector4i mitsuba::math::roundToInt ( const SSEVector4f &  a)
inline

Converts a to integer using round.

template<typename Scalar , typename QuantizedScalar , typename Index >
Index mitsuba::math::sampleAlias ( const AliasTableEntry< QuantizedScalar, Index > *  tbl,
Index  size,
Scalar  sample 
)

Generate a sample in constant time using the alias method.

template<typename Scalar , typename QuantizedScalar , typename Index >
Index mitsuba::math::sampleAliasReuse ( const AliasTableEntry< QuantizedScalar, Index > *  tbl,
Index  size,
Scalar &  sample 
)

Generate a sample in constant time using the alias method.

This variation shifts and scales the uniform random sample so that it can be reused for another sampling operation

template<int idx3, int idx2, int idx1, int idx0>
SSEVector4f mitsuba::math::shuffle ( const SSEVector4f &  low,
const SSEVector4f &  hi 
)
template<int idx3, int idx2, int idx1, int idx0>
SSEVector4f mitsuba::math::shuffle ( const SSEVector4f &  a)
SSEVector4f mitsuba::math::toFloat ( const SSEVector4i &  a)
inline

Convert a to floating point.

SSEVector4i mitsuba::math::toInt ( const SSEVector4f &  a)
inline

Convert a to integer using truncate.

FINLINE void mitsuba::math::transpose ( SSEVector4f &  row0,
SSEVector4f &  row1,
SSEVector4f &  row2,
SSEVector4f &  row3 
)

The arguments row0, row1, row2 and row3 are __m128 values whose elements form the corresponding rows of a 4-by-4 matrix. The matrix transposition is returned in arguments row0, row1, row2 and row3 where row0 now holds column 0 of the original matrix, row1 now holds column 1 of the original matrix, and so on.

Author
Intel Intrinsics Guide for AVX2