[SciPy-user] Mathematica Element-wise Multiplication
Brian Blais
bblais@bryant....
Mon Dec 17 09:29:13 CST 2007
On Dec 17, 2007, at Dec 17:2:49 AM, Johann Cohen-Tanugi wrote:
> Matthieu Brucher wrote:
>>
>>
>> 2007/12/17, Johann Cohen-Tanugi <cohen@slac.stanford.edu
>> <mailto:cohen@slac.stanford.edu>>:
>>
>> thanks for these precisions, David. Reading it, I still come
>> to think
>> that it is a potential source of confusion to let a "row
>> array" have a
>> transpose or T method, that essentially does nothing.
>>
>>
>>
>> In object oriented code, this can happen often, but it is not a
>> problem. It does what you want : inverse the axis, even if there is
>> only one axis.
> hmmm...... okay... What I wanted was to transpose a 1D array into a
> vector, or vice-versa, with the linear algebra behavior in mind.
if you have linear algebra in mind, then you can use a matrix...it
works the way you expect:
In [1]:from numpy import *
In [2]:a=array([1,2,3,4])
In [3]:a.shape
Out[3]:(4,)
In [4]:b=a.T
In [5]:b.shape
Out[5]:(4,)
In [6]:a=matrix([1,2,3,4])
In [7]:a.shape
Out[7]:(1, 4)
In [8]:b=a.T
In [9]:b.shape
Out[9]:(4, 1)
In [10]:a
Out[10]:matrix([[1, 2, 3, 4]])
In [11]:b
Out[11]:
matrix([[1],
[2],
[3],
[4]])
bb
--
Brian Blais
bblais@bryant.edu
http://web.bryant.edu/~bblais
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20071217/7a6e6d8c/attachment.html
More information about the SciPy-user
mailing list