[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug/feature in matrix multiply



Mark Fardal (fardal@weka.phast.umass.edu) writes:

> is the following a bug or feature?  I don't understand why changing the
> type of the array changes the dimensions of the result.  Then again,
> it's late on Friday, so my brain might just be mush.
> 
> IDL> junk=fltarr(3)  
> IDL> junk=reform(junk,3,1)
> IDL> help,junk
> JUNK            FLOAT     = Array[3, 1]
> IDL> help,[3.,2.,1.]#junk
> <Expression>    FLOAT     = Array[1]
> IDL> help,[3.d0,2.d0,1.d0]#junk
> <Expression>    DOUBLE    = Array[3, 3]

I don't know if it is a bug or a feature, but I 
agree that it is strange. But so is this command:

   junk = reform(junk, 3, 1)

Do you mean this:

   junk = reform(junk, 1, 3)

The latter will make a column vector, which makes more
sense when multiplied by a row vector. What kind of result
were you expecting? From my reading of the # operator
I think the result with the floating array is correct.
I don't have a clue why the double expression does what
it does. :-(

Cheers,

David

-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155