File:  [CENS] / python / pyGiNaC / wrappers3 / ex_py.hpp
Revision 1.10: download - view: text, annotated - select for diffs - revision graph
Thu May 24 15:03:40 2001 UTC (16 years, 6 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
Added subs(ls,lr,no_pattern) support

/*
# This file is part of the PyGiNaC package.
# http://cens.ioc.ee/projects/pyginac/
#
# $Revision: 1.10 $
# $Id: ex_py.hpp,v 1.10 2001-05-24 15:03:40 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.
#
*/

#ifndef BASIC_PY_H
#define BASIC_PY_H

#include <ginac/ginac.h>
#include <Python.h>
#include <boost/python/class_builder.hpp>
namespace py = boost::python;

#define ExInstance_Check(op) ((!((op)->ob_type == NULL)) && (\
      (op)->ob_type == (PyTypeObject*)ex_py_class))
#define Number_Check(op) (PyInt_Check(op) || PyFloat_Check(op) || PyComplex_Check(op))


namespace pyginac {
  GiNaC::ex ex_from_ref(py::ref obj, bool flag=true);
  GiNaC::exlist exlist_from_ref(py::ref obj);
  GiNaC::exvector exvector_from_ref(py::ref obj);
  GiNaC::ex constant_dummy(void);

  class ex : public GiNaC::ex {
    PyObject * self;
  public:
    ex(PyObject * self_): GiNaC::ex(), self(self_) {}
    ex(PyObject * self_, const GiNaC::ex & o): GiNaC::ex(o), self(self_) {}
    ex(PyObject * self_, py::ref obj): GiNaC::ex(ex_from_ref(obj)), self(self_) {}
    ~ex();
    std::string python_repr(void) const;
    std::string python_str(void) const;
    std::string print_csrc(void) const;
    std::string print_latex(void) const;
    py::tuple coerce(py::ref other) const;
    GiNaC::ex op_pos(void) const;
    GiNaC::ex op_neg(void) const;
    GiNaC::ex op_add(py::ref other) const;
    GiNaC::ex op_sub(py::ref other) const;
    GiNaC::ex op_mul(py::ref other) const;
    GiNaC::ex op_div(py::ref other) const;
    GiNaC::ex op_pow(py::ref other, py::ref m) const;
    GiNaC::ex op_lshift(py::ref other) const;
    GiNaC::ex coeff_1(const GiNaC::ex & sym) const;
    unsigned nops_0(void) const;
    GiNaC::ex op_1 (long i) const;
    GiNaC::ex primpart_2(const GiNaC::symbol & sym, py::ref cont) const;
    GiNaC::ex normal_0(void) const;
    GiNaC::ex eval_0(void) const;
    GiNaC::ex evalf_0(void) const;
    GiNaC::ex diff_1(const GiNaC::symbol & sym) const;
    GiNaC::ex series_2(const GiNaC::relational & rel, int order) const;
    GiNaC::ex series_3(const GiNaC::relational & rel, int order, unsigned options) const;
    GiNaC::ex subs_1(py::ref e) const;
	GiNaC::ex subs_2(const GiNaC::lst & ls, const GiNaC::lst & rs);
	GiNaC::ex subs_3(const GiNaC::lst & ls, const GiNaC::lst & rs, bool no_pattern);
    GiNaC::ex lhs_0(void) const;
    GiNaC::ex rhs_0(void) const;
    bool is_equal_1(py::ref obj) const;
    PyObject* getitem(py::ref index) const;
    void setitem(py::ref index, py::ref other);
    void delitem(py::ref index);
    unsigned len(void) const;

    std::string get_class_name(void) const;
    unsigned get_precedence(void) const;
    PyObject* get_function(void) const;

#define PYGINAC_EX_PROTOS
#include "ex_py_subs.cpp"

  };
}

#endif

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