File:  [CENS] / python / pyGiNaC / wrappers4 / ex.cpp
Revision 1.9: download - view: text, annotated - select for diffs - revision graph
Wed Nov 28 05:58:04 2001 UTC (15 years, 11 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
Some cleanup

/*
  This file is part of the PyGiNaC package.
  http://cens.ioc.ee/projects/pyginac/

  $Revision: 1.9 $
  $Id: ex.cpp,v 1.9 2001-11-28 05:58:04 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 PYGINAC_EX_CPP
#define PYGINAC_EX_CPP
/* prototypes */

GiNaC::ex ex_primpart(const GiNaC::ex &,
		      const GiNaC::symbol &);
bool ex_match(const GiNaC::ex &,
	      const GiNaC::ex &,
	      GiNaC::lst &);
GiNaC::ex ex_to_rational(const GiNaC::ex & self,
			 GiNaC::lst & repl_lst);
GiNaC::ex ex_op(const GiNaC::ex & e,
		int i);
GiNaC::ex ex_subs(const GiNaC::ex &,
		  const GiNaC::ex &);

//GiNaC::ex ex_diff(const GiNaC::ex & e, const GiNaC::symbol & x,unsigned nth);

#else
#ifndef PYGINAC_EX_CPP_1
#define PYGINAC_EX_CPP_1
/* definitions */

//TODO: map,info,get_free_indices,simplify_indexed
//      symmetrize,antisymmetrize,simplify_ncmul,return_type,return_type_tinfo

ex_class.def(&GiNaC::ex::swap, "swap");
ex_class.def(&GiNaC::ex::expand, "expand");
ex_class.def(&GiNaC::ex::has, "has");
ex_class.def(&GiNaC::ex::find, "find");

ex_class.def(&GiNaC::ex::degree, "degree");
ex_class.def(&GiNaC::ex::ldegree, "ldegree");
ex_class.def(&GiNaC::ex::coeff, "coeff");
ex_class.def(&GiNaC::ex::lcoeff, "lcoeff");
ex_class.def(&GiNaC::ex::tcoeff, "tcoeff");
ex_class.def(&GiNaC::ex::numer, "numer");
ex_class.def(&GiNaC::ex::denom, "denom");
ex_class.def(&GiNaC::ex::numer_denom, "numer_denom");
ex_class.def(&GiNaC::ex::unit, "unit");
ex_class.def(&GiNaC::ex::content, "content");
ex_class.def(&GiNaC::ex::integer_content, "integer_content");
ex_class.def(ex_primpart, "primpart");
ex_class.def(&GiNaC::ex::normal, "normal");
ex_class.def(&GiNaC::ex::smod, "smod");
ex_class.def(&GiNaC::ex::max_coefficient, "max_coefficient");
ex_class.def(&GiNaC::ex::collect, "collect");
ex_class.def(&GiNaC::ex::eval, "eval");
ex_class.def(&GiNaC::ex::evalf, "evalf");
ex_class.def(&GiNaC::ex::evalm, "evalm");
ex_class.def(&GiNaC::ex::diff, "diff");
//ex_class.def(ex_diff, "diff");
ex_class.def(&GiNaC::ex::series, "series");
ex_class.def(ex_match, "match");
ex_class.def(ex_to_rational, "to_rational");

ex_class.def(&GiNaC::ex::nops, "nops");
ex_class.def(ex_op, "op");
ex_class.def(ex_subs, "subs");

//ex_class.def(&GiNaC::ex::compare, "compare"); //for GiNaC internal use only
ex_class.def(&GiNaC::ex::is_equal, "is_equal");
ex_class.def(&GiNaC::ex::is_zero, "is_zero");
ex_class.def(&GiNaC::ex::gethash, "get_hash");

#else
/* implementation */

GiNaC::ex ex_primpart(const GiNaC::ex & e,
		      const GiNaC::symbol & x) {
  return e.primpart(x);
}

GiNaC::ex ex_subs(const GiNaC::ex & e,
		  const GiNaC::ex & x) {
  return e.subs(x);
}

bool ex_match(const GiNaC::ex & e,
	      const GiNaC::ex & pattern,
	      GiNaC::lst & repl_lst) {
  return e.match(pattern, repl_lst);
}

GiNaC::ex ex_to_rational(const GiNaC::ex & self,
			 GiNaC::lst & repl_lst) {
  return self.to_rational(repl_lst);
}

GiNaC::ex ex_op(const GiNaC::ex & e,int i) {
  unsigned n = e.nops();
  if (i<0 || i>=(signed)n) {
    PyErr_SetString(PyExc_IndexError, "op(): index out of range");
    throw py::error_already_set();
  }
  return e.op(i);
}

/*
  GiNaC::ex ex_diff(const GiNaC::ex & e, const GiNaC::symbol & x,unsigned nth) {
  cout << "diff_in:" << e << ", " << x << ", " << nth << endl;
  GiNaC::ex r = e.diff(x,nth);
  cout << "diff_out:" << r << endl;
  return r;
  }
*/

#endif
#endif

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