File:  [CENS] / python / pyGiNaC / wrappers / pseries.py
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Mon Apr 9 21:38:33 2001 UTC (16 years, 7 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
Refined str/repr. Impl. tensor,function etc. support

# This file is part of the PyGiNaC package.
# http://cens.ioc.ee/projects/pyginac/
#
# $Revision: 1.2 $
# $Id: pseries.py,v 1.2 2001-04-09 21:38:33 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 = ['ex','epvector','relational','symbol','numeric']

wrapperclass = '''
class pseries_w : public GiNaC::pseries {
  PyObject * self;
public:
  pseries_w(const GiNaC::pseries & p)
  : GiNaC::pseries(p) {
    DEBUG_C("pseries_w(raw:pseries)");
  }
  pseries_w(python::ref r) {
    DEBUG_C("pseries_w(raw:ref)");
    PyErr_SetString(PyExc_NotImplementedError, "pseries(raw:ref)");
    throw python::error_already_set();
  }
  pseries_w(PyObject * self_, const GiNaC::pseries & p)
  : GiNaC::pseries(p), self(self_) {
    DEBUG_C("pseries_w(pseries)");
  }
  pseries_w(PyObject * self_, const GiNaC::ex & p)
  : GiNaC::pseries(ex_to_pseries_w(p)), self(self_) {
    DEBUG_C("pseries_w(ex)");
  }
  pseries_w(PyObject * self_, const GiNaC::relational & rel, const GiNaC::epvector & ops)
  : GiNaC::pseries(rel,ops), self(self_) {
    DEBUG_C("pseries_w(relational,epvector)");
  }
  pseries_w(PyObject * self_, const GiNaC::ex & rel, const GiNaC::epvector & ops)
  : GiNaC::pseries(ex_to_relational_w(rel),ops), self(self_) {
    DEBUG_C("pseries_w(ex,epvector)");
  }
  pseries_w(PyObject * self_, const GiNaC::ex & rel, python::ref ops)
  : GiNaC::pseries(ex_to_relational_w(rel),as_epvector_w(ops)), self(self_) {
    DEBUG_C("pseries_w(ex,ref)");
  }
  pseries_w(PyObject * self_, const GiNaC::relational & rel, python::ref ops)
  : GiNaC::pseries(rel,as_epvector_w(ops)), self(self_) {
    DEBUG_C("pseries_w(relational,ref)");
  }

  pseries_w(PyObject * self_, const GiNaC::ex & var, const GiNaC::ex & point, python::ref ops)
  : GiNaC::pseries(GiNaC::relational(var, point),as_epvector_w(ops)), self(self_) {
    DEBUG_C("pseries_w(ex,ref)");
  }
  pseries_w(PyObject * self_,
                       python::ref var,
                       python::ref point,
                       python::ref ops)
  : GiNaC::pseries(GiNaC::relational(ex_w(var), ex_w(point)),as_epvector_w(ops)), self(self_) {
    DEBUG_C("pseries_w(ex,ref)");
  }
  
  ~pseries_w() {
    DEBUG_C("~pseries_w()");
  }

};

'''

builder = '''
python::class_builder<pseries_w> pseries_w_class(this_module, "_pseries_w");
python::class_builder<GiNaC::pseries, pseries_w> pseries_class(this_module, "pseries");
pseries_py_class = python::as_object(pseries_class.get_extension_class());
pseries_class.declare_base(pseries_w_class);
pseries_class.declare_base(basic_class);
'''

constructors = '''
pseries_class.def(python::constructor<const GiNaC::pseries &>());
pseries_class.def(python::constructor<const GiNaC::ex &>());
pseries_class.def(python::constructor<const GiNaC::relational &, const GiNaC::epvector &>());
pseries_class.def(python::constructor<const GiNaC::ex &, const GiNaC::epvector &>());
pseries_class.def(python::constructor<const GiNaC::relational &, python::ref>());
pseries_class.def(python::constructor<const GiNaC::ex &, python::ref>());
pseries_class.def(python::constructor<const GiNaC::ex &, const GiNaC::ex &, python::ref>());
pseries_class.def(python::constructor<python::ref, python::ref, python::ref>());
'''

defs = '''
pseries_class.def(&basic_w::python_str, "__str__");
pseries_class.def(&basic_w::python_repr, "__repr__");

pseries_class.def(&pseries_w::convert_to_poly, "convert_to_poly");
pseries_class.def(&pseries_w::is_compatible_to, "is_compatible_to");
pseries_class.def(&pseries_w::is_zero, "is_zero");
pseries_class.def(&pseries_w::is_terminating, "is_terminating");
pseries_class.def(&pseries_w::add_series, "add_series");
pseries_class.def(&pseries_w::mul_const, "mul_const");
pseries_class.def(&pseries_w::mul_series, "mul_series");
pseries_class.def(&pseries_w::power_const, "power_const");
pseries_class.def(&pseries_w::shift_exponents, "shift_exponents");
'''

implementation = '''
EX_TO_BASIC(pseries)
'''

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