Re: How can I speed up this 'for' loop?
- From: "Geoff Zilahy" <g_zilahy@xxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 04:01:23 -0400
Ian Cowley wrote:
>
>
> In message XlOFe.161998$tt5.48841@edtnps90, Paul Skoczylas burbled:
>> "Ian Cowley" <me3@xxxxxxxxxxx> wrote in message
>> news:dc875i$9ac$1@xxxxxxxxxxxxxxxxxxxxxxx
>>> In message ef0f0b3.-1@xxxxxxxxxxxxxxxx, Geoff Zilahy
burbled:
>>>> hi everyone, I'm just trying to speed up this for loop:
>>>>
>>>> %
>>>> for m = 1:M
>>>> b = sH_2*u;
>>>> b = b(:);
>>>> u = sH_1\b;
>>>> end
>>>
>>> You're not actually changing anything inside the loop, so
doing
> it
>>> once willgive you the same values of u and b.
>>>
>>> If you post your code with all the bits in it where stuff
is
>>> changing from one loop to the next, then we could help a
bit
> more.
>>> At presetn the code you posted just does the exact same
> calculation
>>> M times, so you can speed it up by a factor of M by just
doing
> it
>>> once :)
>>
>>
>> Either I'm missing something, or Ian is! Assuming that u has a
>> defined value coming into the loop, then b and u both change at
> each
>> iteration.
>
> Ah yes, didn't see that u and b were changing each other. I hadn't
> realised
> it was looping over time - I assumed it was looping over the
> elements of M
> and working something out for each one. My bad :)
>
> --
> Ian Cowley
> Bishop's Stortford/Cambridge, UK
>
> www.iancowley.co.uk/contact
>
>
>
Hi Paul and Ian,
This is the same problem as before (Geoff Halstead), and I was just
looking to see if the b part of the loop could be speeded up in the
same way as the u part.
In terms of the boundary conditions, I'm currently working on
implimenting more specific coefficients for surface and corner nodes.
As far as types of boundaries go, I'm trying to model 3 different
ones at the moment:
boundary at a set temp -
for this one, I'm setting all the elements in the row of the H
matrices which correspond to the boundary node of u to zero. Then
resetting the leading diagonal element of this row to 1 (i.e. no
change)
free boundary (allowed to rise and fall in temp) -
here i'm leaving the row of the H matrices which correspond to the
boundary node of u in it's original state. (not sure if this is
correct)
heat flux in/out -
i'm tring to add a heat flux coefficient to the nodes on this type of
boundary. Not sure how to change the corresponding row of the H
matrices.
Thanks for your help guys,
Geoff Halstead/zilahy :)
.
- Follow-Ups:
- Re: How can I speed up this 'for' loop?
- From: Geoff Halstead
- Re: How can I speed up this 'for' loop?
- References:
- How can I speed up this 'for' loop?
- From: Geoff Zilahy
- Re: How can I speed up this 'for' loop?
- From: Ian Cowley
- Re: How can I speed up this 'for' loop?
- From: Paul Skoczylas
- Re: How can I speed up this 'for' loop?
- From: Ian Cowley
- How can I speed up this 'for' loop?
- Prev by Date: Re: adding a .mat file into nested functions
- Next by Date: Re: How to run matlab in a batch file?
- Previous by thread: Re: How can I speed up this 'for' loop?
- Next by thread: Re: How can I speed up this 'for' loop?
- Index(es):
Relevant Pages
|