LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (September 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 17 Sep 2003 08:31:50 -0700
Reply-To:     Dale McLerran <stringplayer_2@YAHOO.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dale McLerran <stringplayer_2@YAHOO.COM>
Subject:      Re: speeding-up IML?
Comments: To: Tanja Repsilber <Tanja.Repsilber@UNI-DUESSELDORF.DE>
In-Reply-To:  <3F686E7C.6A6483A7@uni-duesseldorf.de>
Content-Type: text/plain; charset=us-ascii

Tanja,

Without seeing any code, one can only guess at whether the code could be sped up either through some rewrite of your IML code or by writing the whole thing in C. You do mention that you use some loops in IML. Quite often, one can write code which avoids the use of loops and instead performs matrix operations. That can significantly improve the speed of your process. Also, if you must invert large matrices which follow some specific structure, then such inversions can often be performed with greater precision and at lightning fast speeds by coding your own solution. Suppose, for instance, that you have a matrix

M = | V1 r1V1 ... r1V1 0 0 ... 0 | | r1V1 V1 ... r1V1 0 0 ... 0 | | ... ... ... ... ... ... ... ... | | r1V1 r1V1 ... V1 0 0 ... 0 | | 0 0 ... 0 V2 r2V2 ... r2V2 | | 0 0 ... 0 r2V2 V2 ... r2V2 | | ... ... ... ... ... ... ... ... | | 0 0 ... ... r2V2 r2V2 ... V2 |

We know that the inverse of this matrix will be of the form

Minv = | a b ... b 0 0 ... 0 | | b a ... b 0 0 ... 0 | | ... ... ... ... ... ... ... ... | | b b ... a 0 0 ... 0 | | 0 0 ... 0 c d ... d | | 0 0 ... 0 d c ... d | | ... ... ... ... ... ... ... ... | | 0 0 ... 0 d d ... c |

If you multiply M*Minv, you get equations of the form

1 = a*V1 + (k1-1)*b*r1*V1 0 = V1*b + r1*V1*a + (k1-2)*b*r1*V1 1 = c*V2 + (k2-1)*d*r2*V2 0 = V2*d + r2*V2*c + (k2-2)*b*r2*V2

where k1 and k2 are the number of rows (columns) in each of the two blocks having zero covariance. Now, if there are hundreds of rows/columns in your matrix, and you can simplify the inverse solution to a set of four equations in four unknowns, then you can achieve dramatic improvements in efficiency. Simply rewriting the code in C will not achieve much improvement in efficiency.

I guess that what I am saying is that one needs to know exactly what operations are the time consuming part of the code. Examine those operations carefully to see if there isn't some clever way to achieve the same result but with a lot less work. Sometimes you can find some clever rewrite. Other times, it may simply be impossible to find such a rewrite.

Best wishes,

Dale

--- Tanja Repsilber <Tanja.Repsilber@UNI-DUESSELDORF.DE> wrote: > Hallo, > > I have to fit a non-linear function to experimental data. This > function > is defined by a differential equation system. I use a combination of > ODE, NLPNMS and own function definitions with some loops in Proc IML, > which works very well, only it needs weeks for calculation. So I > think > of programming it in C. Is there anybody experienced with such a > problem? Will it be much faster programming it directly? Or is there > a > possibility of speeding-up IML? > > Tanja Repsilber

===== --------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@fhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com


Back to: Top of message | Previous page | Main SAS-L page