#include <iostream>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include "input.h"
{
const float a1 = 0.254829592;
const float a2 = -0.284496736;
const float a3 = 1.421413741;
const float a4 = -1.453152027;
const float a5 = 1.061405429;
const float p = 0.3275911;
const float sqrt2 =
sqrt(2.0);
array t = 1.0f / (1.0f + p*x);
array y = 1.0f + 0.5f * (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*
exp(-x*x);
return xSign * y + !xSign * (1 - y);
}
{
d1 = d1 + (R + (V*V)*0.5) * T;
C = S * cnd_d1 - (X *
exp((-R)*T) * cnd_d2);
P = X *
exp((-R)*T) * (1 - cnd_d2) - (S * (1 - cnd_d1));
}
int main(int argc, char **argv)
{
try {
int device = argc > 1 ? atoi(argv[1]) : 0;
printf("** ArrayFire Black-Scholes Example **\n"
"** by AccelerEyes **\n\n");
black_scholes(Cg, Pg, Sg,Xg,Rg,Vg,Tg);
printf("Warming up done\n");
int iter = 1000;
for (int n = 50; n <= 500; n += 50) {
for (int i = 0; i < iter; i++) {
black_scholes(Cg, Pg, Sg,Xg,Rg,Vg,Tg);
}
printf("Input Data Size = %8d. Mean GPU Time: %0.6f ms\n", (int)dims[0], 1000 * t);
}
fprintf(stderr,
"%s\n", e.
what());
throw;
}
return 0;
}