Skip to content

Commit

Permalink
Merge pull request #227 from phbasler/eigenFix
Browse files Browse the repository at this point in the history
Changed scalar_normal_dist_op to class with user-defined moved ctor
  • Loading branch information
beniz authored Sep 10, 2021
2 parents a21fc5e + 1e4d61a commit d5bde81
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 d5bde81

Please sign in to comment.