Numarray, numeric, NumPy, scpy_core ??!!

Robert Kern robert.kern at gmail.com
Sat Jan 21 14:27:59 EST 2006


J wrote:
> Ok, I will look at NumPy ...
> 
> I have another question about performance. Are the array operations
> such as matrix multiplication implemented in
> python or in C ? I was under the impression that the function calls in
> numarray are only wrappers to C code, but now I suspect that matrix
> multiplicaiton is implemented in python and executed in the
> interpreter. Is that true ?

No, not at all. In fact, if an optimized BLAS is available on your system, you
can make numpy (or numarray or Numeric) use that to do your matrix
multiplications much faster.

> Can someone also please point me to examples of how I could make my own
> array classes. Basically all I need is vectors and 3x3 matrices. I
> already have all of the multiplication code in my C++ classes and only
> need wrappers. But how can I create an array class and intercept
> operators calls like * + -. This is not neccessarily a solution that I
> want to follow, but it may be what
> I have to do for now.

It's a difficult problem, since you have to overload nearly every operation in
order to return arrays of your subclass, not the basic array class. numpy has a
new mechanism to try to alleviate this. You should look at the matrix subclass
in numpy/core/defmatrix.py .

-- 
Robert Kern
robert.kern at gmail.com

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list