void OptionCalculator::parrallel_realisation(int nb_realisation)
{
	m_realisation_values.resize(nb_realisation);
	concurrency::extent<1> e(nb_realisation);


	concurrency::array_view<float, 1> c(e, m_realisation_values);
	c.discard_data();

	const float two_pi = _two_pi;
	const float neg_two = -2.0f;
	const int time_laps = OptionCalculator::_M;
	const float initial = m_initial_share_prices;
	const float sdt = m_sdt;
	const float rate = m_rate;
	const float dt = OptionCalculator::_dt;

	concurrency::index<1> idx(0);
	tinymt_collection<1> randomClass(e, rand());

	concurrency::parallel_for_each(e, [=](concurrency::index<1> idx) restrict(amp)
	{
		c[idx] = initial;
		for (int i = 1; i < time_laps; ++i)
		{
			float random_tmp = concurrency::fast_math::sqrt(neg_two * float(concurrency::fast_math::log((float(randomClass[idx].next_single())))))
						* float(concurrency::fast_math::cos((float(two_pi * float(randomClass[idx].next_single())))));
			c[idx] = c[idx] * (1.f + random_tmp * sdt + rate * dt);
		}
	});
예제 #2
0
Invader* InvaderSwarm::getRightInvader() {
	InvaderClass invClass = randomClass();

	Invader* right = getInvader(invClass, 9, 6);
	if(right != 0) return right;

	Invader* left = getInvader(invClass, 0, 9);
	if(left != 0) return left;
	
	return getSubstitudeInvader();
}