[Numpy-discussion] Changing a matrix element into a scalar

Joshua Holbrook josh.holbrook@gmail....
Tue Aug 3 12:29:21 CDT 2010


I don't think I've ever actually seen someone use the matrix datatype
instead of the array datatype.

Hopefully nobody minds me asking the noob question: What's the
advantage of the matrix datatype?

--Josh

On Tue, Aug 3, 2010 at 8:59 AM, Wayne Watson
<sierra_mtnview@sbcglobal.net> wrote:
> Thank you. That's  almost amusing. Too logical for Python. I fully
> expected something like m{0}[0](0)[0:0]. :-)
>
> I don't think the tentative Numpy tutorial mentions it.
>
> On 8/3/2010 9:28 AM, PHobson@Geosyntec.com wrote:
>> Wayne,
>>
>> Matrices are two dimensional arrays so you need two indices to access an individual element:
>>
>> In [1]: from numpy import matrix
>>
>> In [2]: m = matrix([[1.2],[2.3]])
>>
>> In [3]: m[0,0]
>> Out[3]: 1.2
>>
>> -paul
>>
>> -----Original Message-----
>> From: numpy-discussion-bounces@scipy.org [mailto:numpy-discussion-bounces@scipy.org] On Behalf Of Wayne Watson
>> Sent: Tuesday, August 03, 2010 9:24 AM
>> To: Discussion of Numerical Python
>> Subject: [Numpy-discussion] Changing a matrix element into a scalar
>>
>> How do I access 1.2 in such a way as to end up with a float? I keep
>> getting a matrix.
>> from numpy import matrix
>> m = matrix([[1.2],[2.3]])
>>
>>
>
> --
>            Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>
>              (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
>               Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet
>
>              "Republicans are always complaining that government is
>               out of control. If they get into power, they will
>               prove it." -- R. J. Rourke
>
>
>                     Web Page:<www.speckledwithstars.net/>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list