PDA

View Full Version : Python --> Timing a Matrix Inversion



danbaron
28-06-2010, 06:47
[font=courier new][size=8pt]I ran the following Python program.

On my computer, which is not very fast, it took 283.3473.. seconds, to fill a 6000 x 6000 matrix with random doubles,
and then to invert it. (When I try doing 7000 x 7000, I get a memory error.)

Python 2.6.5
NumPy 1.4.1

http://www.python.org/download/

You have to install "numpy", separately. It is not included in the Python distribution.
And, you have to use Python 2.6.x, for numpy to work.

http://numpy.scipy.org/


import time
import numpy

t = time.clock()
a = numpy.random.rand(6000, 6000)
a = numpy.linalg.inv(a)
t = time.clock() - t
print t
raw_input()

# Output = 283.3473.. (seconds)


[font=courier new][size=8pt]NumPy, in Python corresponds to, PDL, in Perl.

Look at the link below, to see the results of a similar program, written in Perl.
According to this test, NumPy, is amazingly fast, compared to, PDL.
(I'm sure we all agree, that, NumPy, is a great champion!)

:oops: :x :grrrr:
Dan

http://community.thinbasic.com/index.php?topic=3488.msg25792#msg25792

kryton9
15-07-2010, 19:00
I've tinkered with pyton but not really gotten into it yet. I will however as my current tool chain I am building up, some of the applications allow you to write plugins or scripts in them via python.
The Gimp- an image editor for one and Blender- the 3D modeling animation program. Thanks for the tip about that additional download Dan for NumPy.

danbaron
16-07-2010, 02:23
[font=courier new][size=8pt]You don't like Python, Kent. Or, did you forget?

http://community.thinbasic.com/index.php?topic=3458.0

I will say one thing, if you can get past the underscores, and you are going to use it, then, the Wingware Personal IDE ($35), is pretty nice.

http://wingware.com/

(Maybe you are a sucker for that kind of stuff (candy?), like I am.)

:P :twisted:
Dan

kryton9
16-07-2010, 04:02
I didn't like the underscores, but as Charles and you pointed out... they are used in almost all languages for behind the scene type code for system identifiers. I feel bad for the people having to use them all the time developing those libraries that is for sure.

But I do see that python is used in lots of places, so it will be something I will need to get into more than just dabble in.

Thanks for the link to the ide. I have this idea for a code editor that I work on time to time in freepascal/lazarus. I did a test using the SynEdit control, but I couldn't get the look I wanted, but close enough to know that it is something I want to finish sometime. I hope when and if it ever sees the light of day it will support coding for some of the languages I like.

Right now I am relearning Blender.