On Tue, 2002-11-19 at 08:58, Federico Balbi wrote:
> > Suppose M is a matrix of records (m,f,u). I'm trying to understand
> > whether it's worth, from the viewpoint of execution speed, to rewrite
> > the line
> >
> > M[i,j].u := M[i,j].f/M[i,j].m
> > as
> > t := M[i,j]; t.u := t.f/t.m
> >
> > Does anyone have an opinion on this? Thanks.
>
> but then I guess you will have to do again M[i,j].u=t.u right? So you have
> 2 record copy operations at each iteration. I do not think that it is a
> pointer to M[]. You save one pair of indexes but I am not sure how much
> time you are going to save. You should probably run some tests and compare
> the execution time. I'll be curios to know about any gain/loss in
> performance.
Actually, there are no record copies involved, so adding M[i,j].u := t.u
isn't needed. Records, like other structures, are represented by
descriptors (typed pointers), so after t := M[i,j], both t and M[i,j]
reference the same descriptor.
t := M[i,j]; t.u := t.f/t.m
should be faster, but I'll be little surprised if you can see
the difference in any real-world application (that's likely to
be a pretty small fraction of the total time, even if the above
code is in a tight loop).
--
Steve Wampler -- [EMAIL PROTECTED]
Quantum materiae materietur marmota monax si marmota
monax materiam possit materiari?
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group