I was wondering if anyone could provide any tips or tricks to speed up the efficiency of the operation of element by element operations. Please consider the following short program as an example:
Code: Select all
wfcreate u 1 'preamble to set up the question
!size = 100 'preamble to set up the question
matrix(!size,!size) XMAT 'preamble to set up the question
matrix(!size,!size) YMAT = 0 'preamble to set up the question
for !a = 1 to !size 'preamble to set up the question
for !b = 1 to !size 'preamble to set up the question
XMAT(!a,!b) = @nrnd 'preamble to set up the question
next 'preamble to set up the question
next 'preamble to set up the question
for !a = 1 to !size
for !b = 1 to !size
if XMAT(!a,!b)<0.1*@max(XMAT) then
YMAT(!a,!b)=XMAT(!a,!b)
endif
next
next
Does anyone have any ideas on how to speed this kind of thing up? Ive considered some kind of matrix multiplication method with resizing through the 16 decimal place structure, but cant figure out much, or think of anything. As this forum has been a rich treasure chest of tricks for computational efficiency in the past, I would try my luck here, before resorting to another programming language (which might be vectorized like YMAT= XMAT(XMAT > 0.1*max(Xmat)) in another language).
Best wishes!
Charlie
