Re: [cgkit-user] cgkit matrix multiply performance - 25x slower than numpy?
Brought to you by:
mbaas
From: Matthias B. <mat...@gm...> - 2008-09-01 21:42:13
|
Bruce Hahne wrote: > So at least for the test code snippets I used, it seems like numpy's > "array" type does matrix multiplication about 25x faster than cgkit. > [...] > 100000 5.911 0.000 31.295 0.000 mat4.py:161(__mul__) > 100002 4.134 0.000 21.942 0.000 mat4.py:60(__init__) > 1600000 7.171 0.000 7.171 0.000 mat4.py:97(<lambda>) These lines refer to a file mat4.py which indicates that you are using the "light" version of cgkit. In that version, all the vector and matrix types are implemented in pure Python which is why they are so much slower than numpy. You have to install the full version of cgkit to get implementations that are written in C++. When I run your example scripts with that version, cgkit is about twice as fast as numpy over here. By the way, you are also comparing different data types. When you construct the numpy arrays you only pass integers to the array functions which will result in an integer array. You should set the type explicitly to float64, so that the data types are actually the same: mymat1 = array([ [0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0] ], dtype=float64) - Matthias - |