File:  [CENS] / python / pyGiNaC / wrappers / varidx.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: varidx.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.
#
# TODO:
#   varidx.printraw is missing in GiNaC. Ask for it.

depends = ['idx']
uses = ['ex']

wrapperclass = '''
class varidx_w : public GiNaC::varidx {
  PyObject * self;
public:
  varidx_w(python::ref r) {
    DEBUG_C("varidx_w(raw:ref)");
    PyErr_SetString(PyExc_NotImplementedError, "varidx(raw:ref)");
    throw python::error_already_set();
  }

  varidx_w(PyObject * self_, const GiNaC::ex & v, const GiNaC::ex & dim)
  : GiNaC::varidx(v,dim), self(self_) {
    DEBUG_C("varidx_w(ex,ex)");
  }
  varidx_w(PyObject * self_, const GiNaC::ex & v, const GiNaC::ex & dim, bool covariant)
  : GiNaC::varidx(v,dim,covariant), self(self_) {
    DEBUG_C("varidx_w(ex,ex,bool)");
  }
  varidx_w(PyObject * self_, const GiNaC::varidx & i)
  : GiNaC::varidx(i), self(self_) {
    DEBUG_C("varidx_w(varidx)");
  }
  varidx_w(PyObject * self_, const GiNaC::ex & i)
  : GiNaC::varidx(ex_to_varidx_w(i)), self(self_) {
    DEBUG_C("varidx_w(ex)");
  }  
  varidx_w(PyObject * self_, python::ref v, python::ref dim)
  : GiNaC::varidx(ex_w(v),ex_w(dim)), self(self_) {
    DEBUG_C("varidx_w(ref,ref)");
  }
  varidx_w(PyObject * self_, python::ref v, python::ref dim, bool covariant)
  : GiNaC::varidx(ex_w(v),ex_w(dim), covariant), self(self_) {
    DEBUG_C("varidx_w(ref,ref,bool)");
  }
  ~varidx_w() {
    DEBUG_C("varidx_w::~varidx_w()");
  }

};

'''

builder = '''
python::class_builder<varidx_w> varidx_w_class(this_module, "_varidx_w");
python::class_builder<GiNaC::varidx, varidx_w> varidx_class(this_module, "varidx");
varidx_py_class = python::as_object(varidx_class.get_extension_class());
varidx_class.declare_base(varidx_w_class);
varidx_class.declare_base(idx_class);
'''

constructors = '''
varidx_class.def(python::constructor<const GiNaC::varidx &>());
varidx_class.def(python::constructor<const GiNaC::ex &>());
varidx_class.def(python::constructor<const GiNaC::ex &,const GiNaC::ex>());
varidx_class.def(python::constructor<python::ref, python::ref>());
varidx_class.def(python::constructor<const GiNaC::ex &,const GiNaC::ex, bool>());
varidx_class.def(python::constructor<python::ref, python::ref, bool>());
'''

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

varidx_class.def(&varidx_w::is_covariant, "is_covariant");
varidx_class.def(&varidx_w::is_contravariant, "is_contravariant");
varidx_class.def(&varidx_w::toggle_variance, "toggle_variance");
'''

implementation = '''
EX_TO_BASIC(varidx)
'''

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