X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 29 Nov 2016 06:25 AM by  anon
scalar * vector = vector (but not always!)
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
29 Nov 2016 06:25 AM
    Hello Can anyone explain this behaviour in IDL 8.2? IDL> print, tr 0.0875595 IDL> print, yy 1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 9.00000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000 23.0000 24.0000 25.0000 26.0000 27.0000 28.0000 29.0000 30.0000 31.0000 32.0000 33.0000 34.0000 35.0000 36.0000 37.0000 38.0000 39.0000 40.0000 41.0000 42.0000 43.0000 IDL> print, tr*yy 0.0875595 ^Why is this result a scalar, when: IDL> a = 1. IDL> b = [1,5,6] IDL> print, a * b 1.00000 5.00000 6.00000 Is a vector? Not at all what I was expecting : / CW

    Deleted User



    New Member


    Posts:
    New Member


    --
    29 Nov 2016 08:50 AM
    I resolved this. variable 'tr' happened to be an array -- even though it contains just one element. I'd expected IDL to treat it as a scalar, but not the case. if tr = fltarr(1) then you must specify: tr[0] * yy in the operation. Otherwise you'll get a fltarr(1) returned. You live, you learn : )
    You are not authorized to post a reply.