Are structures really slower than numeric variables?
- From: "Akim " <aaa@xxxxxxx>
- Date: Thu, 12 Feb 2009 11:07:02 +0000 (UTC)
Dear all,
I have the following "bottleneck" line in a loop,
U = sum(Pu .* [n.K ; U]);
where, for a large integer N,
U is an Nx1 matrix,
n.K is an Nx2 matrix, part of a large structure n
Pu is an Nx3 matrix.
It appears that if I 'extract' the array K beforehand,
K=n.K;
the resulting code
U=sum( Pu .* [K ; U]);
runs significantly faster.
Am I imagining this, or is there an explanation? I would rather avoid duplicating n.K, to save memory.
Thanks for your help.
Akim
.
- Follow-Ups:
- Re: Are structures really slower than numeric variables?
- From: Matt
- Re: Are structures really slower than numeric variables?
- From: Rune Allnor
- Re: Are structures really slower than numeric variables?
- Prev by Date: Re: UNIQUE too slow
- Next by Date: Re: plot a point in 3D
- Previous by thread: user configuration
- Next by thread: Re: Are structures really slower than numeric variables?
- Index(es):
Relevant Pages
|