Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 4th, 2013, 10:44 PM
Avichal Avichal is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 19 Avichal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 51 m 41 sec
Reputation Power: 0
Why no 2d array system in python?

I recently started studying python and I am wondering if there is a way to have a 2d array.
As far as I know there is only the concept of list in python.

I am surprised that being a high level language why is it so difficult to do things like matrix multiplication etc(which require 2d arrays)?

Reply With Quote
  #2  
Old January 4th, 2013, 11:50 PM
Lux Perpetua Lux Perpetua is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: San Francisco Bay
Posts: 1,938 Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 h 43 m 16 sec
Reputation Power: 1312
There are only a few programming languages that have nontrivial matrix operations as built-in functionality, and those that do (like Matlab and Mathematica) tend to be awkward for general-purpose (i.e., non-mathematical) programming. The preferred approach in general-purpose languages is to leave matrices and matrix arithmetic to third-party libraries.

In Python, you have multiple options:
- use a list of lists. You'll have to code your own matrix operations, and it won't be very efficient.

- use NumPy, which I highly recommend. This gives you not only two-dimensional arrays, but arrays of arbitrary dimensionality. You also get all the standard matrix operations, including multiplication. The newest version of NumPy also includes the very useful einsum function, which is a generalization of matrix multiplication. (For example, this allows you to matrix-multiply one array of matrices elementwise against another array of matrices in one line of code.)

- use another third-party library that implements some matrix functionality. I don't know of any that are as powerful as NumPy.

Reply With Quote
  #3  
Old January 5th, 2013, 03:00 AM
Avichal Avichal is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 19 Avichal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 51 m 41 sec
Reputation Power: 0
Numpy seems powerful. Thanks for telling

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Why no 2d array system in python?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap