[SciPy-user] FW: Vector orientation (pedantry?)

Travis Oliphant oliphant at ee.byu.edu
Mon Nov 25 19:43:18 EST 2002


>
> So [1,2,3] denotes a 'flat' 3-array to Numeric, while [[1,2,3]] denotes
> 1-by-3 array?  Not sure I understand the distinction.

The difference is that [[1,2,3]] is a two-dimensional array while
[1,2,3] is a one-dimensional arryay.  This rank distinction is convenient
for some problems and less convenient for matrix algebra problems.

>
> I agree that SciPy is awkward for linear algebra, but it's mainly syntax
> in my case.  <HERESY> I find typing 'x=[1,2,3;4,5,6;7,8,9]' much more
> straightforward than 'x=array([[1,2,3],[4,5,6],[7,8,9]]), especially
> since Python/SciPy doesn't seem to have a 'blink matching brackets'
> option. </HERESY>
>

There is the option in scipy to use the mat function:

>>> mat('[1,2,3;4,5,6]')
Matrix([[1,2,3],
       [4,5,6]])

This allows that kind of notation input and also gives you a real 2-D
matrix where * means matrix-multiplication.

-Travis Oliphant









More information about the SciPy-User mailing list