File:  [CENS] / python / pyGiNaC / wrappers / mul.py
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Tue Apr 17 22:39:25 2001 UTC (16 years, 7 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
Fixed bugs. Exposed/checked functions. Started testing framework.

# This file is part of the PyGiNaC package.
# http://cens.ioc.ee/projects/pyginac/
#
# $Revision: 1.4 $
# $Id: mul.py,v 1.4 2001-04-17 22:39:25 pearu Exp $
#
# Copyright 2001 Pearu Peterson all rights reserved,
# Pearu Peterson <pearu@cens.ioc.ee>
# Permission to use, modify, and distribute this software is given under the
# terms of the LGPL.  See http://www.fsf.org
#
# NO WARRANTY IS EXPRESSED OR IMPLIED.  USE AT YOUR OWN RISK.
#

depends = ['basic']

uses = ['exvector','epvector']

#STARTPROTO

class mul(expairseq):
    """Product of expressions."""
    def __init__(self,*args):
        """mul() - construct empty product (equivalent to 0)
    mul(e1,e2) - construct a product e1*e2
    mul(seq)   - construct a product seq[0]*seq[1]*...*seq[-1]
    mul(vp,coeff) - construct a product from epvector vp and coeff.
    mul(ex(mul(...))) - returns mul(...)
    """

#ENDPROTO

wrapperclass = '''
class mul_w : public GiNaC::mul {
  PyObject * self;
public:
  mul_w(python::ref v)
  : GiNaC::mul(exvector_w(v)) {
    DEBUG_C("mul_w(raw:ref)");
  }

  mul_w(PyObject * self_)
  : GiNaC::mul(), self(self_) {
    DEBUG_C("mul_w()");
  }
  mul_w(PyObject * self_, const GiNaC::mul & m)
  : GiNaC::mul(m), self(self_) {
    DEBUG_C("mul_w(mul)");
  }
  mul_w(PyObject * self_, const GiNaC::ex & m)
  : GiNaC::mul(ex_to_mul_w(m)), self(self_) {
    DEBUG_C("mul_w(ex)");
  }
  
  mul_w(PyObject * self_, const GiNaC::ex & lh, const GiNaC::ex & rh)
  : GiNaC::mul(lh,rh), self(self_) {
    DEBUG_C("mul_w(ex,ex)");
  }
  mul_w(PyObject * self_, const GiNaC::epvector & v, const GiNaC::ex & oc)
  : GiNaC::mul(v,oc), self(self_) {
    DEBUG_C("mul_w(epvector,ex)");
  }
  mul_w(PyObject * self_, const GiNaC::exvector & v)
  : GiNaC::mul(v), self(self_) {
    DEBUG_C("mul_w(exvector)");
  }
  mul_w(PyObject * self_, python::ref lh, python::ref rh)
  : GiNaC::mul(ex_w(lh),ex_w(rh)), self(self_) {
    DEBUG_C("mul_w(ref,ref)");
  }
  mul_w(PyObject * self_, const GiNaC::epvector & v, python::ref oc)
  : GiNaC::mul(v,ex_w(oc)), self(self_) {
    DEBUG_C("mul_w(epvector,ref)");
  }
  mul_w(PyObject * self_, python::ref v)
  : GiNaC::mul(exvector_w(v)), self(self_) {
    DEBUG_C("mul_w(ref)");
  }
  ~mul_w() {
    DEBUG_C("~mul_w()");
  }
};

'''

builder = '''
python::class_builder<mul_w> mul_w_class(this_module, "_mul_w");
python::class_builder<GiNaC::mul, mul_w> mul_class(this_module, "mul");
mul_py_class = python::as_object(mul_class.get_extension_class());
mul_class.declare_base(mul_w_class);
mul_class.declare_base(basic_class);
'''

constructors = '''
mul_class.def(python::constructor<>());
mul_class.def(python::constructor<const GiNaC::mul &>());
mul_class.def(python::constructor<const GiNaC::ex &>());
mul_class.def(python::constructor<const GiNaC::ex &, const GiNaC::ex>());
mul_class.def(python::constructor<const GiNaC::epvector &, const GiNaC::ex>());
mul_class.def(python::constructor<const GiNaC::epvector &, python::ref>());
mul_class.def(python::constructor<python::ref, python::ref>());
mul_class.def(python::constructor<const GiNaC::exvector &>());
mul_class.def(python::constructor<python::ref>());
'''

defs = '''
mul_class.def(&basic_w::python_str, "__str__");
mul_class.def(&basic_w::python_repr, "__repr__");
mul_class.def(&basic_w::coerce, "__coerce__");
BASIC_OPS(mul)
'''

implementation = '''
EX_TO_BASIC(mul)
'''

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>