I know this post is a little old but I would like to share a small project I created yesterday.
I think the easier way is to use C++ 11 and create a .dll in Managed C++.
There's a link to the source and a zip containing the dll already compiled.
And the code I made :
// NormalDistributionRandom.h
#include <random>
#pragma once
using namespace System;
namespace NormalDistribution
{
class _NormalDistributionRandom
{
std::default_random_engine engine;
std::normal_distribution<double> distribution;
public:
_NormalDistributionRandom(double mean, double deviation) : distribution(mean, deviation)
{
}
double Next()
{
return distribution(engine);
}
};
public ref class NormalDistributionRandom
{
private:
void* Distribution;
public:
NormalDistributionRandom( double mean, double deviation)
{
Distribution = new _NormalDistributionRandom(mean, deviation);
}
double Next()
{
return ((_NormalDistributionRandom*)Distribution)->Next();
}
~NormalDistributionRandom()
{
this->!NormalDistributionRandom();
}
protected:
!NormalDistributionRandom()
{
if (Distribution != nullptr)
{
delete (_NormalDistributionRandom*)Distribution;
Distribution = nullptr;
}
}
};
}