17 template <
typename TScalarRng>
25 static_assert(!std::is_reference<TScalarRng>::value,
"Cannot be used for references");
28 template <
typename... TArgs>
30 : rngImpl(
std::forward<TArgs>(args)...) {}
33 : rngImpl(
std::move(other.rngImpl)) {
34 static_assert(!std::is_reference<TScalarRng>::value,
"Cannot be used for references");
38 static_assert(!std::is_reference<TScalarRng>::value,
"Cannot be used for references");
39 rngImpl = std::move(other.rngImpl);
44 return Vector(rngImpl(0), rngImpl(1), rngImpl(2));
59 template <
typename TScalarRng>
80 const Float maximalPdf = 0._f)
84 , maxPdf(maximalPdf) {
91 this->maxPdf =
max(this->maxPdf, this->pdf(v) * this->jacobian(v));
99 for (
Size i = 0; i < 10000; ++i) {
102 if (p < pdf(v) * jacobian(v)) {
106 SPH_ASSERT(
false,
"Couldn't generate vector in 1000 iterations");
#define SPH_ASSERT(x,...)
Generic wrappers of lambdas, functors and other callables.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
constexpr INLINE T max(const T &f1, const T &f2)
#define NAMESPACE_SPH_END
Random number generators.
INLINE Float getLength(const Vector &v)
Returns the length of the vector. Enabled only for vectors of floating-point precision.
BasicVector< Float > Vector
Helper object defining three-dimensional interval (box).
INLINE const Vector & lower() const
Returns lower bounds of the box.
INLINE Vector size() const
Returns box dimensions.
void iterate(const Vector &step, TFunctor &&functor) const
Execute functor for all possible values of vector (with constant stepping)
Generic generator of random vectors using sampling with given PDF.
VectorPdfRng(const Box &box, const Function< Float(const Vector &)> &pdf=[](const Vector &) { return 1._f;}, const Function< Float(const Vector &)> &jacobian=[](const Vector &) { return 1._f;}, const Float maximalPdf=0._f)
Wrapper for generating random vectors.
VectorRng()
Default constructor. Can be only used if RNG is owned by the object.
VectorRng(TArgs &&... args)
Float getAdditional(const Size i)
VectorRng & operator=(VectorRng &&other)
VectorRng(VectorRng &&other)
Overload of std::swap for Sph::Array.
Object with deleted copy constructor and copy operator.