Fast Array Addition

BlitzPlus Forums/BlitzPlus Programming/Fast Array Addition

Kevin_(Posted 2005) [#1]
Hi folks.

I used to know of a very quick method of incrementing each value in an array without using a loop. Has anyone got this code?

example (old way).....

Dim Alien(1000,2)
for a = 1 to 1000
Alien(a,1)=Alien(a,1)+1
Alien(a,2)=Alien(a,2)+1
next


Any help would be great.

Thanks.


Kevin_(Posted 2005) [#2]
Forget the post above. I've sorted it.


aab(Posted 2005) [#3]
er...What was your 'very quick method of incrementing each value in an array without using a loop'?


Kevin_(Posted 2005) [#4]
Sorry, it doesn't :/

Just tried it and it doesn't work in Blitz because you cannot use an array by just using its brackets.

It used to work in fortran (and probably other languages) where you could say....

a[]=a[]+1

and that would increment each element by 1.

I think the only way to do it in Blitz is to copy a block of memory onto another block of memory using a mask. I'm working on it....


WolRon(Posted 2005) [#5]
What's wrong with using a loop? I'm not sure that you can find a faster way...