comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Sky Falling, etc. : Array substitution + addition with plus-equal (+=)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Sky Falling, etc. : Array substitution + addition with plus-equal (+=) [message #52941] Mon, 12 March 2007 14:17 Go to previous message
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
Tentatively filed under "The Sky Is Falling!," and I hope it will be
resolved in the same fashion.

Here is the test case, which gives the correct result:

IDL> test=fltarr(2,2,4)
IDL> testadd=fltarr(2,2,2) + 1
IDL> print,total(test),total(testadd)
0.00000 8.00000
IDL> test[0,0,1] += testadd
IDL> print,total(test),total(testadd)
8.00000 8.00000
IDL> test[0,0,1] += testadd
IDL> print,total(test),total(testadd)
16.0000 8.00000
IDL> print,test
0.00000 0.00000
0.00000 0.00000

2.00000 2.00000
2.00000 2.00000

2.00000 2.00000
2.00000 2.00000

0.00000 0.00000
0.00000 0.00000

That is exactly what I expect from this operation.

Here is another case, with results somewhat different
IDL> test=fltarr(2,2,4)
IDL> testadd=fltarr(2,2,2)
IDL> testadd[0,0,*]=1
IDL> print,total(test),total(testadd)
0.00000 2.00000
IDL> test[0,0,1] += testadd
IDL> print,total(test),total(testadd)
2.00000 2.00000
IDL> print,test
0.00000 0.00000
0.00000 0.00000

1.00000 0.00000
0.00000 0.00000

1.00000 0.00000
0.00000 0.00000

0.00000 0.00000
0.00000 0.00000 ; So far, so good
IDL> test[0,0,1] += testadd ; Now, let's add again
IDL> print,total(test),total(testadd)
10.0000 2.00000 ; Pardon the
expression, WTF?
IDL> print,test
0.00000 0.00000
0.00000 0.00000

2.00000 1.00000
1.00000 1.00000

2.00000 1.00000
1.00000 1.00000

0.00000 0.00000
0.00000 0.00000 ; Not even JD Smith
expected _that_.

Any ideas?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: randomn problem
Next Topic: Re: Array resize with arbitrary arithmetic

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:18:46 PDT 2025

Total time taken to generate the page: 0.00598 seconds