Execution time bottleneck: How to speed up execution?

Jeff Racine racine at yunexus.yorku.ca
Tue Feb 12 02:17:37 AEST 1991


Execution time query:

I have the following nested loop in which I must sum (over all i), for each
x[j], e raised to the power x[i]-x[j] squared (times a constant).

This section of the program is of order n-squared (i.e. execution time
increases at the rate of the number of observations squared).

   for (j=1; j <= n; j++) {
      sum = 0.0;
      for (i=1; i<= n; i++) {
         sum += exp( con * (x[i]-x[j]) * (x[i]-x[j]) );
      }
      a[j] = k*sum;
   }

This part of the algorithmn is a bottleneck. I want to make this as
quick as possible. What are my options? I have heard that assembler
would be faster. How much faster would assembler be? Would it be worth
the effort? Are there other alternatives that you can see?  Any
improvement would be welcome.

Any help would be greatly appreciated. Thanks for your time and effort.


--------------------------------------------------------------------
Jeff Racine             Tel (416)-656-2916
racine at nexus.yorku.ca   
racine at yunexus.UUCP     /* Yo Mama */



More information about the Comp.lang.c mailing list