Matrix multiplication

John Nagle nagle at animats.com
Tue Jan 4 22:46:10 EST 2011


On 1/4/2011 2:15 AM, Ulrich Eckhardt wrote:
> Zdenko wrote:
>> Please, can anybody write me a simple recursive matrix multiplication
>> using multiple threads in Python, or at least show me some guidelines
>> how to write it myself
>
> No problem, I just need your bank account data to withdraw the payment and
> the address of your teacher whom to send the results. ;^)
>
> Seriously, things don't work like this. If you show effort, you will get
> help, but you don't get working solutions without even a bit of effort on
> your own.
>
> Start with a recursive algorithm, then make it multithreaded. Be prepared to
> make some experiments on how to distribute tasks to threads and collect
> them again.

     If you want to do matrix multiplication from Python, use NumPy.
Anything you write in Python itself and run in CPython will be far,
far slower.  CPython without NumPy is about 60x slower than C on
basic array math.

     Writing high-speed parallel number-crunching code that outperforms
off the shelf libraries is typically non-trivial.  If there's some
easy way to make a simple operation like matrix multiply go faster,
it's probably been done already.

     If you're really into this, look into the Unified Parallel C effort 
and its libraries.  The supercomputer types spend their lives doing this
sort of thing.

				John Nagle



More information about the Python-list mailing list