Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - newbie doubt ..numpy array

 
Thread Tools Search this Thread
Old 01-21-2008, 06:07 AM   #1
Default newbie doubt ..numpy array


if this is too silly a qn pls forgive
I was learning numpy.ndarrays thru the tutorial.

myarr=numpy.array( [ [10, 20, 30, 40],[1,2,3,4],[5,6,7,8] ] )
if i want to access the element 3 i can do it by myarr[1, 2]

but then myarr[1][2] will also give the same result..is there any
reason why two types of indexing is allowed?
gordon

p.s(i tried to post to numpy grp but it is not appearing there!)


nodrogbrown
  Reply With Quote
Old 01-21-2008, 06:17 AM   #2
Dennis Lee Bieber
 
Posts: n/a
Default Re: newbie doubt ..numpy array
On Sun, 20 Jan 2008 22:07:31 -0800 (PST), nodrogbrown
<> declaimed the following in comp.lang.python:


> myarr=numpy.array( [ [10, 20, 30, 40],[1,2,3,4],[5,6,7,8] ] )
> if i want to access the element 3 i can do it by myarr[1, 2]
>
> but then myarr[1][2] will also give the same result..is there any
> reason why two types of indexing is allowed?
> gordon
>

The first is likely a numpy extension (and corresponds to the syntax
many of the classical number crunching languages support: FORTRAN,
Ada...). The second is Python's native syntax (and corresponds to less
focused languages -- such as C; in which a matrix [2D array] is an array
of arrays). You first retrieve the sublist accessed by [1], and then
access the element addressed by [2]
--
Wulfraed Dennis Lee Bieber KD6MOG

HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-)
HTTP://www.bestiaria.com/


Dennis Lee Bieber
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL and EDK: Custom IP core containing an array as a port using EDK allsey_1987 Hardware 0 10-27-2009 02:26 PM
constants as of array of integers, for loops octavsly Hardware 0 04-25-2009 11:53 AM
Array Programme rits Software 2 03-04-2009 05:18 PM
NEWBIE - DVD burn problem - need help Vic Baron DVD Video 6 09-29-2005 10:56 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46