Re: Multiplication changes array dimensions since a scalar and a 1x1 array are not the same [message #53259] |
Sat, 31 March 2007 21:13 |
swingnut
Messages: 30 Registered: September 2005
|
Member |
|
|
Haha. So, all those SIZE statements sunk in. Here's the workaround I
came up with.
;SIZE of testVirtHeight =
; 1 1 4 1
;SIZE of referenceHeight =
; 0 4 1
deltaVirtHeight = testVirtHeight - referenceHeight
signOfDifference -> 1x1 array instead of a scalar.
adjustmentIncrement = adjustmentIncrement * signOfDifference
adjustmentIncrement -> 1x3 array before operation, 1x1 array
afterwards
SOLUTION: Extract scalar from array element -> testVirtHeight =
testVirtHeight[0,0]
----------
Clearly my calculation of deltaVirtHeight assumed that you could treat
a 1x1 scalar, while IDL is treating them as different types of
variables during array multiplications. Now, why a scalar and a 1x1
array are different escapes me, but at least I've found this
workaround and can continue on. And hopefully knowing about this might
help someone else.
|
|
|