Hi,

is it possible (or planned) to add operators to a ctypdef struct?

Using the WrappingCPlusPlus example I would like to be able to do:
cdef c_Rectangle a = c_Rectangle(1,2,3,4)
a=a+a

but adding
c_Rectangle __add__ "operator+"(c_Rectangle right)
to c_Rectange does not work.

I don't want to use the Python wrapper class because I don't want the
operator to produce a PyNumber_Add call.

Will it be in the long run possible to wrap a C++ linear algebra
template library like Eigen (1) or NT2 (2)? This would be very nice
because one could very easy speed up numpy code.

E.g. in numpy
a,b,c,d=[N.random.random(100000) for i in range(4)] #just creating sample data
a*b*c*d #element wise multiplication

is pretty slow because the multiplications are done after each other
and thus cache is used poorly. By doing the same expression with
either template library, the expression templates make it just one
for-loop and even SIMD it.

Roland

Links:
1) eigen.tuxfamily.org/
2) nt2.sourceforge.net/
-- 
ORNL/UT Center for Molecular Biophysics cmb.ornl.gov
865-241-1537, ORNL PO BOX 2008 MS6309
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to