5#include <Common/assertion.h>
13 const T*
const weights,
17 m_conditionalXs(numWeights.y())
19 PH_ASSERT(weights && numWeights.
x() > 0 && numWeights.
y() > 0);
22 std::vector<T> rowSums(numWeights.
y(), 0);
23 for(std::size_t y = 0; y < numWeights.
y(); ++y)
25 const std::size_t baseIndex = y * numWeights.
x();
26 for(std::size_t x = 0; x < numWeights.
x(); ++x)
28 rowSums[y] += weights[baseIndex + x];
34 &(weights[baseIndex]),
47 const T*
const weights,
61 const std::array<T, 2>& sample,
62 T*
const out_pdf)
const
68 const T sampleY = m_marginalYs.sampleContinuous(sample[1], &pdfY, &y);
69 const T sampleX = m_conditionalXs[y].sampleContinuous(sample[0], &pdfXgivenY);
71 *out_pdf = pdfXgivenY * pdfY;
72 PH_ASSERT(*out_pdf > 0);
79 const std::size_t y = m_marginalYs.continuousToDiscrete(sample[1]);
81 const T pdfY = m_marginalYs.pdfContinuous(y);
82 const T pdfXgivenY = m_conditionalXs[y].pdfContinuous(sample[0]);
84 return pdfXgivenY * pdfY;
A 2-D Axis-Aligned Bounding Box (AABB).
Definition TAABB2D.h:26
const TVector2< T > & getMaxVertex() const
Definition TAABB2D.ipp:126
const TVector2< T > & getMinVertex() const
Definition TAABB2D.ipp:120
A 1-D piecewise constant distribution of floating-point type T. The sample weights can be seen as a h...
Definition TPwcDistribution1D.h:16
Definition TPwcDistribution2D.h:16
T pdfContinuous(const std::array< T, 2 > &sample) const
Definition TPwcDistribution2D.ipp:77
TVector2< T > sampleContinuous(const std::array< T, 2 > &sample, T *out_pdf) const
Definition TPwcDistribution2D.ipp:60
Represents a 2-D vector.
Definition TVector2.h:19
T & x()
Definition TVector2.ipp:38
T & y()
Definition TVector2.ipp:44
Math functions and utilities.
Definition TransformInfo.h:10