lorenzo bolla’s blog

April 25, 2007

papers about Python and scientific computing

Filed under: links, programming — lbolla @ 7:16 pm

here is a list of articles about Python and scientific computing appeared in Computing in Science and Engineering, available online:

happy reading!

April 17, 2007

binary hand counting

Filed under: italiano, nice words — lbolla @ 6:29 pm

binary hand counting

ecco un modo molto comodo di contare da 0 a 31 usando una mano sola. avendone a disposizione due, si puo’ arrivare a 1023…

ho ideato il metodo mentre mi annoiavo a ripetere lo stesso esercizio 30 volte e, distraendomi, perdevo il conto. naturalmente, qualcuno ci aveva gia’ pensato e qualcun’altro ci ha anche fatto delle magliette…

praticamente, ogni dito della mano ha due stati: CHIUSO (0) o APERTO (1). 5 dita danno 32 possibili stadi, numerabili da 0 a 31. 10 dita danno 1024 stadi, numerabili da 0 a 1023. usando i piedi, le possibilita’ aumentano…

April 11, 2007

numerical computing: matlab vs python+numpy+weave

Filed under: programming — lbolla @ 12:06 pm

recently, I’ve discovered the power of python for numerical computing. being a slave of matlab for many years, I’ve decided to give python (and it’s numerical module numpy) a try, comparing its numerical crounching capabilities versus matlab’s.

the tests are heavily insipired by Prabhu Ramachandran. I’ve only added matlab to complete his comparisons. Here is a short description of the test, taken from here:
The example we will consider is a very simple (read, trivial) case of solving the 2D Laplace equation using an iterative finite difference scheme (four point averaging, Gauss-Seidel or Gauss-Jordan). The formal specification of the problem is as follows. We are required to solve for some unknown function u(x,y) such that \nabla^2 u = 0 with a boundary condition specified. For convenience the domain of interest is considered to be a rectangle and the boundary values at the sides of this rectangle are given.

all the tests have been run on a Pentium IV Xeon 2GHz, with 1Gb of RAM.
here is the matlab script I used laplace.m (it’s a doc file: sorry for that, but I’m only allowed to upload docs and images on this blog).

time spent by different solvers

matlab and numpy have pretty much the same performances. any form of optimization on python code does better than matlab. only the simple python (without numpy) is slower than matlab (note the logarithmic y scale to fit also the “slow” algorithm).

speed factor with respect to matlab

blitz is roughly twice as fast as matlab. inline, fastinline, fortran and pyrex only differ appreciably for small grids: for 500×500 grids they are around 10x faster than matlab.

here is some other digits, not included in the graphs:

  • numpy with psyco runs 5% faster than numpy alone;
  • weave and psyco (blitz, inline and fastinline) fails with following polite error: local variables of functions run by Psyco cannot be accessed in any way, sorry;
  • octave runs twice as slow as numpy and matlab.

pretty amazing, if you think that optimizing python, most of the time, is really trivial. moreover, python is free and easily parallelizable with MPI (I’ll show some performances in a future post).

tests have been run also on an SGI Altix with Itanium2 processors, on a single CPU. the graphs are reported in the following thumbnails.

time spent by different solversspeed factor with respect to matlab

April 8, 2007

autoreferenza

Filed under: italiano, nice words — lbolla @ 12:45 pm

altan

si applica anche a questo post?

April 7, 2007

riprendiamoci telecom!

Filed under: italiano, links, personal — lbolla @ 10:23 am

sarei tentato di comprare azioni telecom solo per poter partecipare! se non fosse che il mio LCA mi constringera’ a letto in quei giorni… restero’ aggiornato via blog!

Blog at WordPress.com.