Autoconf

Bernard Parisse Bernard.Parisse at ujf-grenoble.fr
Fri Nov 17 09:55:51 CET 2000


> 
> Sure.  The other clean option would be that you provide us with a method
> sitting in expariseq, add and mul which maps the object to a data
> structure that you need and we'll simply put that into GiNaC.  Maybe this
> is what should be done.

I'm not sure it is easy because we need to find an intermediate data
representation. This could be an idea:
provide the ex class with a splitting function
oper split(const ex & e, vector<ex> & v)
that splits e in its arguments and the operator you must apply to get e
from the argument list. 
oper would be a class like:
  struct oper {
    ex (* op) (const vector<ex> & arg); 
    oper(const ex (* myop) (const vector<ex> & )) : op(myop) {}
    ex operator () (const vector<ex> & arg) const;
  };

  ex oper::operator () (const vector<ex> & arg) const{
    return op(arg);
  }

Then we would define the usual operators, e.g. for +

  const ex __plus(const vector<ex> & args){
    vector<ex>::const_iterator it=args.begin(), itend=args.end();
    ex sum;
    for (;it!=itend;++it)
      sum += (*it);
    return sum;
  }

  oper _plus(__plus);

An example of usage of split, testing that the operator is + 
  ...
  ex e;
  vector<ex> v;
  oper o=split(e,v);
  if (o.op==__plus){ // or if (o==_plus), provided == is defined
  ...

Any suggestions?

Regards,
Bernard



More information about the GiNaC-devel mailing list