From: us on
"David Romero-Antequera"
> > % displays:
> > timea =
> > 0.873374775
> > timeb =
> > 9.3843e-005
> > timec =
> > 4.9347e-005
>
> This helped a little. Thanks!

a ...LITTLE... (!?)...

ta=0.873374775;
tb=9.3843e-005;
tc=4.9347e-005;
r=ta./[tb,tc]
% r = 9306.8 17699 % <- speed gain...

us
From: dpb on
us wrote:
> "David Romero-Antequera"
>> > % displays:
>> > timea =
>> > 0.873374775
>> > timeb =
>> > 9.3843e-005
>> > timec =
>> > 4.9347e-005
>>
>> This helped a little. Thanks!
>
> a ...LITTLE... (!?)...
>
> ta=0.873374775;
> tb=9.3843e-005;
> tc=4.9347e-005;
> r=ta./[tb,tc]
> % r = 9306.8 17699 % <- speed gain...
>
> us

Stating the obvious, but... :)

Removing all the overhead of a small fraction of the total runtime still
results in only a small percentage gain overall... :(

Which is, of course, the suggestion of "profile first".

Not that there isn't some value in shaving time where it's obviously
possible, but it isn't fruitful to spend hours trying to optimize
something that isn't going to make a great deal of difference
regardless...old lessons are often worth repeating.

Again, know you know it us, just wanted to make the emphasis again.

--
From: Walter Roberson on
David Romero-Antequera wrote:

> On the other hand, there's another part where I compute something like:
>
> exp(1i*t*M);
>
> where t is an scalar and M, in the worst case, is a complex matrix
> (relatively big). So, is there any way to speed this computing? Can I
> compute the value of the matrix faster based on some previous state?
> (because t will vary monotonically).

Is M being held constant? Is t equally spaced?

If the answer to the both of the above is Yes, then if you taylor
exp(i*(t+dt)*(a+b*i)) it appears that you might be able to calculate the
expression at t+dt, t+2*dt and so on using a recurrence relationship that can
possibly be simplified to polynomials. The number of steps that you could take
before you had to update to a new base t value would depend upon your accuracy
requirements -- and it would not at all surprise me if the number of
operations involved in calculation of the taylor coefficients swamped any
savings you got from doing this.
From: us on
dpb <none(a)non.net> wrote in message <i3ci70$tus$1(a)news.eternal-september.org>...
> us wrote:
> > "David Romero-Antequera"
> >> > % displays:
> >> > timea =
> >> > 0.873374775
> >> > timeb =
> >> > 9.3843e-005
> >> > timec =
> >> > 4.9347e-005
> >>
> >> This helped a little. Thanks!
> >
> > a ...LITTLE... (!?)...
> >
> > ta=0.873374775;
> > tb=9.3843e-005;
> > tc=4.9347e-005;
> > r=ta./[tb,tc]
> > % r = 9306.8 17699 % <- speed gain...
> >
> > us
>
> Stating the obvious, but... :)
>
> Removing all the overhead of a small fraction of the total runtime still
> results in only a small percentage gain overall... :(
>
> Which is, of course, the suggestion of "profile first".

i fully second your statement(!)...
but, let's also keep in mind
....look after the pennies and the pounds will look after themselves...

:-)
us
From: David Romero-Antequera on
Walter Roberson <roberson(a)hushmail.com> wrote in message <i3ciu3$m85$1(a)canopus.cc.umanitoba.ca>...
> David Romero-Antequera wrote:
>
> > On the other hand, there's another part where I compute something like:
> >
> > exp(1i*t*M);
> >
> > where t is an scalar and M, in the worst case, is a complex matrix
> > (relatively big). So, is there any way to speed this computing? Can I
> > compute the value of the matrix faster based on some previous state?
> > (because t will vary monotonically).
>
> Is M being held constant? Is t equally spaced?
>
> If the answer to the both of the above is Yes, then if you taylor
> exp(i*(t+dt)*(a+b*i)) it appears that you might be able to calculate the
> expression at t+dt, t+2*dt and so on using a recurrence relationship that can
> possibly be simplified to polynomials. The number of steps that you could take
> before you had to update to a new base t value would depend upon your accuracy
> requirements -- and it would not at all surprise me if the number of
> operations involved in calculation of the taylor coefficients swamped any
> savings you got from doing this.

Yes, M is held constant, no t it is not equally spaced. I was thinking about that idea, but it is not clear to me how to choose how many terms in my taylor expansion should I pick up. Is there any starting point to read about the accuracy? For example, how do I know how accurate is the exp function in MATLAB?

By the way, thanks to everyone, this has been very helpful.
 |  Next  |  Last
Pages: 1 2 3
Prev: why it is invalid syntax
Next: Matlab & Threads ?