Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 66 additions & 20 deletions include/sampling/random_point_generators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

template
<
typename Walk
typename Walk,
bool storeValue = true
>
struct RandomPointGenerator
{
template
template
<
typename Polytope,
typename Point,
Expand All @@ -36,7 +37,10 @@ struct RandomPointGenerator
for (unsigned int i=0; i<rnum; ++i)
{
walk.apply(P, p, walk_length, rng);
policy.apply(randPoints, p);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p);
}
}
}

Expand All @@ -60,15 +64,19 @@ struct RandomPointGenerator
for (unsigned int i=0; i<rnum; ++i)
{
walk.apply(P, p, walk_length, rng);
policy.apply(randPoints, p);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p);
}
}
}
};


template
<
typename Walk
typename Walk,
bool storeValue = true
>
struct MultivariateGaussianRandomPointGenerator
{
Expand Down Expand Up @@ -96,7 +104,10 @@ struct MultivariateGaussianRandomPointGenerator
for (unsigned int i=0; i<rnum; ++i)
{
walk.apply(P, p, walk_length, rng);
policy.apply(randPoints, p);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p);
}
}
}

Expand All @@ -122,15 +133,19 @@ struct MultivariateGaussianRandomPointGenerator
for (unsigned int i=0; i<rnum; ++i)
{
walk.apply(P, p, walk_length, rng);
policy.apply(randPoints, p);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p);
}
}
}
};


template
<
typename Walk
typename Walk,
bool storeValue = true
>
struct GaussianRandomPointGenerator
{
Expand All @@ -156,7 +171,10 @@ struct GaussianRandomPointGenerator
for (unsigned int i=0; i<rnum; ++i)
{
walk.apply(P, p, a_i, walk_length, rng);
policy.apply(randPoints, p);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p);
}
}
}

Expand Down Expand Up @@ -185,14 +203,21 @@ struct GaussianRandomPointGenerator
for (unsigned int i=0; i<rnum; ++i)
{
walk.apply(P, p, a_i, walk_length, rng);
policy.apply(randPoints, p);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p);
}
}
}
};



template <typename Walk>
template
<
typename Walk,
bool storeValue = true
>
struct BoundaryRandomPointGenerator
{
template
Expand All @@ -216,16 +241,20 @@ struct BoundaryRandomPointGenerator
for (unsigned int i=0; i<rnum; ++i)
{
walk.apply(P, p1, p2, walk_length, rng);
policy.apply(randPoints, p1);
policy.apply(randPoints, p2);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p1);
policy.apply(randPoints, p2);
}
}
}
};


template
<
typename Walk
typename Walk,
bool storeValue = true
>
struct LogconcaveRandomPointGenerator
{
Expand All @@ -250,14 +279,18 @@ struct LogconcaveRandomPointGenerator
walk.apply(rng, walk_length);

// Use PushBackWalkPolicy
policy.apply(randPoints, walk.x);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, walk.x);
}
}
}
};

template
<
typename Walk
typename Walk,
bool storeValue = true
>
struct CrhmcRandomPointGenerator
{
Expand Down Expand Up @@ -302,22 +335,29 @@ struct CrhmcRandomPointGenerator
if((i + 1) * simdLen > rnum){
for(int j = 0; j < rnum-simdLen*i; j++){
Point p = Point(x.col(j));
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p);
}
}
break;
}
// Use PushBackWalkPolicy
for(int j=0; j<x.cols();j++){
Point p = Point(x.col(j));
policy.apply(randPoints, p);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p);
}
}
}
}
};

template
<
typename Walk
typename Walk,
bool storeValue = true
>
struct ExponentialRandomPointGenerator
{
Expand Down Expand Up @@ -349,7 +389,10 @@ struct ExponentialRandomPointGenerator
//return;
throw std::range_error("A generated point is outside polytope");
}
policy.apply(randPoints, p);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p);
}
}
}

Expand Down Expand Up @@ -384,7 +427,10 @@ struct ExponentialRandomPointGenerator
//return;
throw std::range_error("A generated point is outside polytope");
}
policy.apply(randPoints, p);
if constexpr (storeValue) // Only store points if storeValue is true
{
policy.apply(randPoints, p);
}
}
}

Expand Down
Loading
Loading