Path: utzoo!mnetor!tmsoft!torsqnt!lethe!yunexus!racine From: racine@yunexus.yorku.ca (Jeff Racine) Newsgroups: comp.lang.c Subject: Execution time bottleneck: How to speed up execution? Summary: Need to speed up nested loop: What are alternatives? Keywords: Execution time, would like to speed up. Alternatives? Message-ID: <21658@yunexus.YorkU.CA> Date: 11 Feb 91 15:17:37 GMT Sender: news@yunexus.YorkU.CA Followup-To: comp.lang.c Organization: York University, Toronto, Ont. Lines: 29 References: 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@nexus.yorku.ca racine@yunexus.UUCP /* Yo Mama */