File:  [CENS] / python / pyGiNaC / wrappers / clifford.py
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Wed Apr 11 20:31:30 2001 UTC (16 years, 7 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
Exposed lots of functions. Documented most important classes/functions. minor_version = 2

# This file is part of the PyGiNaC package.
# http://cens.ioc.ee/projects/pyginac/
#
# $Revision: 1.3 $
# $Id: clifford.py,v 1.3 2001-04-11 20:31:30 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 = ['indexed']

uses = ['ex']

wrapperclass = '''

static GiNaC::clifford ex_to_clifford_or_ex_w(const GiNaC::ex &);

class clifford_w : public GiNaC::clifford {
  PyObject * self;
public:
  clifford_w(python::ref v)
  : GiNaC::clifford(ex_w(v)) {
    DEBUG_C("clifford_w(raw:ref)");
  }
  clifford_w(PyObject * self_, const GiNaC::ex & m)
  : GiNaC::clifford(ex_to_clifford_or_ex_w(m)), self(self_) {
    DEBUG_C("clifford_w(ex(clifford|*))");
  }
  clifford_w(PyObject * self_, const GiNaC::basic & m)
  : GiNaC::clifford(ex_to_clifford_or_ex_w(GiNaC::ex(m))), self(self_) {
    DEBUG_C("clifford_w(basic)");
  }
  clifford_w(PyObject * self_, python::ref m)
  : GiNaC::clifford(exvector_w(m)), self(self_) {
    DEBUG_C("clifford_w(ref)");
  }
  clifford_w(PyObject * self_, python::ref b, python::ref mu)
  : GiNaC::clifford(ex_w(b),ex_w(mu)), self(self_) {
    DEBUG_C("clifford_w(ref,ref)");
  }
  ~clifford_w() {
    DEBUG_C("clifford_w::~clifford_w()");
  }
};

inline UNEX_RET dirac_one_w(void) { return UNEX(GiNaC::dirac_one()); }
inline UNEX_RET dirac_gamma_w(python::ref mu) { return UNEX(GiNaC::dirac_gamma(ex_w(mu))); }
'''

builder = '''
python::class_builder<clifford_w> clifford_w_class(this_module, "_clifford_w");
python::class_builder<GiNaC::clifford, clifford_w> clifford_class(this_module, "clifford");
clifford_py_class = python::as_object(clifford_class.get_extension_class());
clifford_class.declare_base(clifford_w_class);
clifford_class.declare_base(indexed_class);
clifford_class.declare_base(basic_class);
'''

constructors = '''
clifford_class.def(python::constructor<const GiNaC::basic &>());
clifford_class.def(python::constructor<const GiNaC::ex &>());
clifford_class.def(python::constructor<python::ref>());
clifford_class.def(python::constructor<python::ref, python::ref>());
'''

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

this_module.def(dirac_one_w,"dirac_one");
this_module.def(dirac_gamma_w,"dirac_gamma");
'''

protos = '''
'''

implementation = '''
EX_TO_BASIC(clifford)

static GiNaC::clifford ex_to_clifford_or_ex_w(const GiNaC::ex & ib) {
  if (is_ex_exactly_of_type(ib, clifford))
    return GiNaC::ex_to_clifford(ib);
  else
    return GiNaC::clifford(ib);
}
'''

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