public static void Main(string[] args)
{
/* Size of the array of elements to compute the polynomial on */
const int arraySize = 1024*1024*8;
/* Allocate arrays of inputs and outputs */
double[] x = new double[arraySize];
double[] pYeppp = new double[arraySize];
double[] pNaive = new double[arraySize];
/* Populate the array of inputs with random data */
Random rng = new Random();
for (int i = 0; i < x.Length; i++) {
x[i] = rng.NextDouble();
}
/* Zero-initialize the output arrays */
Array.Clear(pYeppp, 0, pYeppp.Length);
Array.Clear(pNaive, 0, pYeppp.Length);
/* Retrieve the number of timer ticks per second */
ulong frequency = Yeppp.Library.GetTimerFrequency();
/* Retrieve the number of timer ticks before calling the C version of polynomial evaluation */
ulong startTimeNaive = Yeppp.Library.GetTimerTicks();
/* Evaluate polynomial using C# implementation */
EvaluatePolynomialNaive(x, pNaive);
/* Retrieve the number of timer ticks after calling the C version of polynomial evaluation */
ulong endTimeNaive = Yeppp.Library.GetTimerTicks();
/* Retrieve the number of timer ticks before calling Yeppp! polynomial evaluation */
ulong startTimeYeppp = Yeppp.Library.GetTimerTicks();
/* Evaluate polynomial using Yeppp! */
Yeppp.Math.EvaluatePolynomial_V64fV64f_V64f(coefs, 0, x, 0, pYeppp, 0, coefs.Length, x.Length);
/* Retrieve the number of timer ticks after calling Yeppp! polynomial evaluation */
ulong endTimeYeppp = Yeppp.Library.GetTimerTicks();
/* Compute time in seconds and performance in FLOPS */
double secsNaive = ((double)(endTimeNaive - startTimeNaive)) / ((double)(frequency));
double secsYeppp = ((double)(endTimeYeppp - startTimeYeppp)) / ((double)(frequency));
double flopsNaive = (double)(arraySize * (coefs.Length - 1) * 2) / secsNaive;
double flopsYeppp = (double)(arraySize * (coefs.Length - 1) * 2) / secsYeppp;
/* Report the timing and performance results */
Console.WriteLine("Naive implementation:");
Console.WriteLine("\tTime = {0:F2} secs", secsNaive);
Console.WriteLine("\tPerformance = {0:F2} GFLOPS", flopsNaive * 1.0e-9);
Console.WriteLine("Yeppp! implementation:");
Console.WriteLine("\tTime = {0:F2} secs", secsYeppp);
Console.WriteLine("\tPerformance = {0:F2} GFLOPS", flopsYeppp * 1.0e-9);
/* Make sure the result is correct. */
Console.WriteLine("Max difference: {0:F3}%", ComputeMaxDifference(pNaive, pYeppp) * 100.0f);
}