[Pyrex] Using pyrex to wrap C++ classes with lots of operators: lots of work?
Robert Bradshaw
robertwb at math.washington.edu
Mon Sep 8 18:13:02 CEST 2008
On Sep 7, 2008, at 7:44 PM, Paul C. Leopardi wrote:
> Hi,
> I'll be attending Sage Days 10 in Nancy next month and was
> wondering how much
> work it would take to wrap my GluCat library for Sage.
> http://wiki.sagemath.org/days10
>
> GluCat ( http://glucat.sf.net ) is a C++ template library with
> classes which
> contain many unary and binary operators. Here is just a taste:
>
> #define _GLUCAT_CLIFFORD_ALGEBRA_OPERATIONS \
> bool operator== (const multivector_t& val)
> const; \
> bool operator== (const Scalar_T& scr)
> const; \
> multivector_t& operator+= (const multivector_t&
> rhs); \
> multivector_t& operator+= (const Scalar_T&
> scr); \
> multivector_t& operator-= (const multivector_t&
> rhs); \
> const multivector_t operator- ()
> const; \
> multivector_t& operator*= (const Scalar_T&
> scr); \
> multivector_t& operator*= (const multivector_t&
> rhs); \
> multivector_t& operator%= (const multivector_t&
> rhs); \
> multivector_t& operator&= (const multivector_t&
> rhs); \
> multivector_t& operator^= (const multivector_t&
> rhs); \
> multivector_t& operator/= (const Scalar_T&
> scr); \
> multivector_t& operator/= (const multivector_t&
> rhs); \
> const multivector_t inv ()
> const; \
> const multivector_t pow (int m)
> const; \
> const multivector_t outer_pow (int m)
> const; \
> Scalar_T operator[] (const index_set_t ist)
> const; \
> Scalar_T scalar()
> const; \
> const multivector_t operator() (index_t grade)
> const; \
> const multivector_t even()
> const; \
> const multivector_t odd()
> const; \
> const vector_t vector_part()
> const; \
> const multivector_t involute()
> const; \
> const multivector_t reverse()
> const; \
> const multivector_t conj()
> const; \
> Scalar_T norm()
> const; \
> Scalar_T quad()
> const; \
> const index_set_t frame()
> const; \
> Scalar_T max_abs()
> const; \
> const multivector_t
> truncated \
> (const Scalar_T& limit = Scalar_T(DEFAULT_TRUNCATION))
> const;\
> bool isnan ()
> const; \
> void write (const std::string& msg="")
> const;\
> void write (std::ofstream& ofile, const
> std::string&
> msg="") const;
>
> Has anyone yet tried to wrap C++ classes with lots of operators?
> How much
> effort is involved?
It's not too much work, basically one has to list each operator as a
method. It would be nice to have notation that allows one to specify
that certain types support the infix format.
> Would *anyone* be able to complete the warpping of such
> classes in the context of a 3 day coding sprint?
I think this could *easily* be done.
- Robert
More information about the Pyrex
mailing list