Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed scalar_normal_dist_op to class with user-defined moved ctor #227

Merged
merged 1 commit into from
Sep 10, 2021
Merged
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
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