// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cmath>

using namespace std;

int main()
{
   srand(time(NULL));
   double x[6000];
   for(int i=0;i<6000;i++)
   {
      x[i]=(rand()/(double)RAND_MAX)*2-1;
   }
   double w[6000];
   for(int i=0;i<6000;i++)
   {
      w[i]=(rand()/(double)RAND_MAX)*20-10;
   }
   double v,u;
   clock_t t1 = clock();
   for(int j=0;j<1000;j++)
   {
      v = 0;
      for(int i=0;i<6000;i++)
      {
         v+=x[i]*w[i];
      }
      u=tanh(v);
   }
   clock_t t2 = clock();
   cout << "results = " << v << " " << u << " / " << (1000.0*(t2-t1))/CLOCKS_PER_SEC << " us" << endl;
   return 0;
}
