Skip to content

Commit

Permalink
Changed scalar_normal_dist_op to class with user-defined moved constr…
Browse files Browse the repository at this point in the history
…uctor and assignment
  • Loading branch information
Philipp Basler committed Sep 10, 2021
1 parent 0c4d1c1 commit 1e4d61a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion include/libcmaes/eigenmvn.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,30 @@
namespace Eigen {
namespace internal {
template<typename Scalar>
struct scalar_normal_dist_op
class scalar_normal_dist_op
{
private:
void swap(scalar_normal_dist_op &other) {
std::swap(rng, other.rng);
std::swap(norm, other.norm);
}
public:
static std::mt19937 rng; // The uniform pseudo-random algorithm
mutable std::normal_distribution<Scalar> norm; // gaussian combinator

EIGEN_EMPTY_STRUCT_CTOR(scalar_normal_dist_op)

scalar_normal_dist_op &operator=(scalar_normal_dist_op &&other)
{
if (this != &other) {
swap(other);
}
return *this;
}

scalar_normal_dist_op(scalar_normal_dist_op &&other) {
*this = std::move(other);
}

template<typename Index>
inline const Scalar operator() (Index, Index = 0) const { return norm(rng); }
Expand Down

0 comments on commit 1e4d61a

Please sign in to comment.