1 // -*- Mode : c++ -*-
2 //
3 // SUMMARY  :
4 // USAGE    :
5 // ORG      :
6 // AUTHOR   : Frederic Hecht
7 // E-MAIL   : hecht@ann.jussieu.fr
8 //
9 
10 /*
11 
12  This file is part of Freefem++
13 
14  Freefem++ is free software; you can redistribute it and/or modify
15  it under the terms of the GNU Lesser General Public License as published by
16  the Free Software Foundation; either version 2.1 of the License, or
17  (at your option) any later version.
18 
19  Freefem++  is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  GNU Lesser General Public License for more details.
23 
24  You should have received a copy of the GNU Lesser General Public License
25  along with Freefem++; if not, write to the Free Software
26  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27  */
28 //#pragma dont_inline on
29 //#pragma inline_depth(1)
30 
31 //  for bessel function
32 // c++11   => __STRICT_ANSI__ => error FH..
33 #ifdef __STRICT_ANSI__
34 #undef __STRICT_ANSI__
35 #endif
36 
37 // TODO: remove this block as soon as autoconf is removed from FreeFem++
38 #ifndef CMAKE
39 #include <config.h>
40 #endif
41 
42 #include <cmath>
43 #include <complex>
44 //  put here some def dur to c++11
45 // problem with mixed with using namespace std;
46 // to correct bug in g++ v 4.8.1 add std
47 #if defined (_WIN32  ) || (__GNUC__ >=5) || __llvm__
48 #define NM_STD std::
49 #else
50 #define NM_STD
51 #endif
isNaN(double x)52 long isNaN(double x){return NM_STD isnan(x);}
isInf(double x)53 long isInf(double x){return NM_STD isinf(x);}
isNormal(double x)54 long isNormal(double x){return std::isnormal(x);}
55 #ifdef HAVE_JN
myyn(long n,double x)56 double myyn(long n, double x){ return yn((int)n,x);}
myjn(long n,double x)57 double myjn(long n, double x){ return jn((int) n,x);}
58 #endif
59 //int  ShowAlloc(const char *s, size_t lg);
60 
61 // F. Hecht fev. 2015 ...
62 #include "AFunction.hpp"
63 #include <cstdarg>
64 #include <cstring>
65 #include "error.hpp"
66 #include "lex.hpp"
67 
68 #include "RNM.hpp"
69 
70 #include "Operator.hpp"
71 // for exec routine
72 #include "rgraph.hpp"
73 #include "InitFunct.hpp"
74 #include <queue>
75 
76 #include "array_init.hpp"
77 #include "AFunction_ext.hpp"
78 // Add FH to get memroy used in test .. march 2014
79 #if __APPLE__
80 #include <malloc/malloc.h>
81 #elif HAVE_MALLOC_H
82 #include <malloc.h>
83 #endif
84 #ifdef HAVE_TIMES
85 #include <ctime>
86 #endif
storageused()87 long storageused()
88 {
89 #if HAVE_MSTATS
90     struct mstats mem1;
91     mem1 = mstats();
92     return mem1.bytes_used;
93 #elif HAVE_MALLINFO
94     struct mallinfo mem1;
95     mem1=mallinfo();
96     return mem1.uordblks;
97 #else
98     return 0;
99 #endif
100 
101 }
storagetotal()102 long storagetotal()
103 {
104 #if HAVE_MSTATS
105     struct mstats mem1;
106     mem1 = mstats();
107     return mem1.bytes_total;
108 #elif HAVE_MALLINFO
109     struct mallinfo mem1;
110     mem1=mallinfo();
111     return mem1.keepcost;
112 #else
113     return 0;
114 #endif
115 }
116 // end add mach 2014 ...
117 extern Map_type_of_map map_type_of_map ; //  to store te type
118 extern Map_type_of_map map_pair_of_type ; //  to store te type
119 
120 extern basicForEachType *  typevarreal,  * typevarcomplex;  //  type of real and complex variable
121 
122 extern int TheCurrentLine; // unset: by default
123 extern long mpisize,mpirank;
124 
125 // rand generator ---
126 extern long genrand_int31(void);
127 extern double genrand_real1(void);
128 extern double genrand_real2(void);
129 extern double genrand_real3(void);
130 extern double  genrand_res53(void) ;
131 
132 
133 // FH  for g++ 3.4  the prototypage  have change
134 double  VersionNumber();
Imag(const complex<double> & z)135 double Imag(const  complex<double> & z){ return imag(z);}
Real(const complex<double> & z)136 double Real(const  complex<double> & z){ return real(z);}
137 const  basicForEachType * basicForEachType::type_C_F0 =0; //  for any type un formal operation .... FH add 09/2012
138 
139 // FH
140 
Max(const T & a,const T & b)141 template<class T> inline T Max (const T &a,const T & b){return a > b ? a : b;}
Min(const T & a,const T & b)142 template<class T> inline T Min (const T &a,const T & b){return a < b ? a : b;}
Abs(const T & a)143 template<class T> inline T Abs (const T &a){return a <0 ? -a : a;}
Max(const T & a,const T & b,const T & c)144 template<class T> inline T Max (const T &a,const T & b,const T & c){return Max(Max(a,b),c);}
Min(const T & a,const T & b,const T & c)145 template<class T> inline T Min (const T &a,const T & b,const T & c){return Min(Min(a,b),c);}
Min(const T & a,const T & b,const T & c,const T & d)146 template<class T> inline T Min (const T &a,const T & b,const T & c,const T & d){return Min(Min(a,b),Min(c,d));}
Max(const T & a,const T & b,const T & c,const T & d)147 template<class T> inline T Max (const T &a,const T & b,const T & c,const T & d){return Max(Max(a,b),Max(c,d));}
148 
Square(const T & a)149 template<class T> inline T Square (const T &a){return a*a;}
150 
151 struct SubArray2: public binary_function<long,long,SubArray> {
fSubArray2152   static SubArray f(const long & a,const long & b)  {
153     return SubArray(b-a+1,a);} };
154 struct SubArray3: public ternary_function<long,long,long,SubArray> {
fSubArray3155   static SubArray f(Stack s,const long & a,const long & b,const long & c)  {
156    return SubArray((b-a+1)/c,a,c);} };
157 
158 #ifdef OLDCPP
159 template<class T> inline
polar(const T & r,const T & theta)160 complex<T> polar(const T& r, const T& theta)
161 {
162 	return complex<T>(r * cos(theta), r * sin(theta));
163 }
164 #endif
165 
166 
preal(Complex * const & p)167 double preal( Complex * const& p){return real(*p);}
168 
169 
170 template<class A,class B>  A Build(B b) {  return A(b);}
171 
172 
173 
174 
Exit(long i)175 long Exit(long i) {throw(ErrorExit("Exit",i));return 0;}
Assert(bool b)176 bool Assert(bool b) {if (!b) throw(ErrorExec("exec assert",1));return true;}
177 
MyAssert(int i,char * ex,char * file,long line)178 inline void MyAssert(int i,char * ex,char * file,long line)
179 {if (i) {
180     cout << "CompileError assertion :  " << ex << " in file " << file << "  line = " << line << endl;
181      CompileError();}
182  }
183 
184 template<class R>
185 class  OneOperatorConst : public OneOperator {
186     E_F0 * e;
187     public:
code(const basicAC_F0 &) const188     E_F0 * code(const basicAC_F0 & ) const  { return  e;}
OneOperatorConst(E_F0 * ee)189     OneOperatorConst(E_F0 * ee):  OneOperator(map_type[typeid(R).name()]),e(ee){}
190 };
191 
192 class  OneOperator_array : public OneOperator {public:
code(const basicAC_F0 & a) const193     E_F0 * code(const basicAC_F0 & a) const
194      { return  new E_Array(a);}
OneOperator_array()195     OneOperator_array(): OneOperator(atype<E_Array>(),true) {}
196 };
197 class  OneOperator_border : public OneOperator {public:
code(const basicAC_F0 & a) const198     E_F0 * code(const basicAC_F0 & a) const {
199         if (a.size()==1 && a[0].left()==atype<E_Array>() )
200             return new E_Border(dynamic_cast<const E_Array*>(a[0].LeftValue()));
201         else
202             return  new E_Border(a);}
OneOperator_border()203     OneOperator_border(): OneOperator(atype<const E_Border *>(),true) {}
204 };
205 
206 class  OneOperator_border_label : public OneOperator {public:
207   class Op : public E_F0 {public:
208    const  E_Border *b;
Op(const E_Border * bb)209       Op( const  E_Border *bb) : b(bb) {}
operator ()(Stack) const210       AnyType operator()(Stack)  const { return SetAny<long>(b->label);}
211    };
code(const basicAC_F0 & a) const212     E_F0 * code(const basicAC_F0 & a) const
213      {  const  E_Border * b = dynamic_cast<const E_Border *>(a[0].LeftValue());
214         return new Op(b);}
OneOperator_border_label()215     OneOperator_border_label(): OneOperator(atype<long>(),atype<const E_Border *>()) {}
216 };
217 
LIncremantation(RR * a)218 template<class RR> RR LIncremantation(RR* a){ return ++(*a);}
RIncremantation(RR * a)219 template<class RR> RR RIncremantation(RR* a){ return (*a)++;}
LDecremantation(RR * a)220 template<class RR> RR LDecremantation(RR* a){ return --(*a);}
RDecremantation(RR * a)221 template<class RR> RR RDecremantation(RR* a){ return (*a)--;}
222 
223 template<class RR,class B>
224  RR * New_form_string(string * s) {B * r=  new B(s);freestring(s);return r;}// correct Mars 2011 remove * if delete
225 
get_elements(MyMap<String,String> * const & a,string * const & b)226 inline   string ** get_elements( MyMap<String,String> *  const  &  a,string*  const   & b)
227  { String* Sret=  &((*a)[*b]); // correction FH feb 2004
228     return Sret->getap();}
229 
Abs(RR a)230 template<class RR> RR Abs(RR a) { return a<0?-a:a;}
231 
232 template<class R,class A,class B>
233 R *MakePtrWithDel( A  const & a)
234 { R *r= new B(a->c_str());
235   delete a;
236   return r;}
237 
238 template<class R,class RR>
239 struct Op1_new_pstring: public unary_function<string*,R> {
fOp1_new_pstring240   static R f(string * const & a)  {R r =  new RR(a->c_str());
241     return r;} };
242 
243 template<class R,class RR>
244 struct Op2_set_pstring: public binary_function<R,string*,R> {
fOp2_set_pstring245   static R  f(R const & p,string * const & a)  {*p =  new RR(a->c_str());
246    if ( !*p || !**p) {
247        cerr << " Error opening file " << *a << endl;
248        ExecError("Error opening file");}
249    return p;} };
250 
251 template<class R,class RR>
252 struct Op2_set_pstringiomode: public ternary_function<R,string*,ios::openmode,R> {
fOp2_set_pstringiomode253   static R  f(Stack s,R const & p,string * const & a,const ios::openmode & mode)
254    {*p =  new RR(a->c_str(),mode);
255     return p;} };
256 
FWhile(Stack s,Expression test,Expression ins)257 AnyType FWhile(Stack s ,Expression test,Expression ins)
258 {
259   bool sptrclean=true;
260   AnyType a;
261   StackOfPtr2Free * sptr = WhereStackOfPtr2Free(s);
262   while ( GetAny<bool>((*test)(s)))
263      try  {
264         a=(*ins)(s);
265         if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006  clean Ptr
266        }
267      catch ( E_exception & e) {
268         if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006  clean Ptr
269        if (e.code == E_exception::e_break) break;
270        else if  (e.code == E_exception::e_continue) continue;
271        else throw e;
272        }
273   return a;
274 }
275 
FFor(Stack s,Expression i0,Expression i1,Expression i2,Expression ins)276 AnyType FFor(Stack s ,Expression i0,Expression i1,Expression i2,Expression ins)
277 {
278   bool sptrclean=true;
279   AnyType a;
280      StackOfPtr2Free * sptr = WhereStackOfPtr2Free(s);
281   for ( (*i0)(s);GetAny<bool>((*i1)(s));(*i2)(s))
282    {
283      try  {
284         a=(*ins)(s);
285         if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006  clean Ptr
286        }
287      catch ( E_exception & e) {
288         if (verbosity>50)
289           cerr << "FFor " << e.what() << e.code << endl;
290         if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006  clean Ptr
291        if (e.code == E_exception::e_break) break;
292        else if  (e.code == E_exception::e_continue) continue;
293        else throw e;
294        }
295    }
296   return a;
297 }
298 
TTry(Stack s,Expression ins,Expression ccatch,Expression fin,Expression notused)299 AnyType TTry(Stack s ,Expression ins,Expression ccatch,Expression fin,Expression notused)
300 {
301   assert(notused == 0);
302   AnyType a;
303      try  {a=(*ins)(s);}
304      catch ( E_exception & e) {
305         throw e;
306        }
307      catch(...) {
308         if(verbosity> 2) cerr << "Try:: catch (...) exception " << endl;
309         a=(*ccatch)(s);
310      }
311    if(fin)  a=(*fin)(s);
312   return a;
313 }
314 
FIf(Stack s,Expression test,Expression i1,Expression i2,Expression)315 AnyType FIf(Stack s ,Expression test,Expression i1,Expression i2,Expression )
316  {  AnyType a;
317    if (GetAny<bool>((*test)(s)))
318      {
319        if(i1) a=(*i1)(s);//Add if FH oct 2010
320      }
321       else if (i2)
322     {
323      if(i2) a=(*i2)(s); //Add if FH oct 2010
324     }
325 
326   return a;
327  }
328 
329 
330 
TypeArray(aType b,aType a)331 aType TypeArray(aType b,aType a)
332 { // type of  b[a]
333    aType r=map_type_of_map[make_pair(a->right(),b->right())];
334    if (!r) {
335       cerr << "Sorry is not possible to make a map "<< *b->right() << " [" << *a->right() << "]" << endl;
336       cerr << " list: " << endl;
337       Map_type_of_map::const_iterator i;
338       for(i=map_type_of_map.begin();i!=map_type_of_map.end();i++)
339         cerr << "\t " << *i->first.second << " [" << *i->first.first << "]" << "=" << *i->second << endl;
340       CompileError();
341    }
342    return r;
343 }
344 
TypeTemplate(aType b,aType a)345 aType TypeTemplate(aType b,aType a)
346 { // type of  b[a]
347    aType r=map_type_of_map[make_pair(b,a)];
348    if (!r) {
349       cerr << "Sorry is not possible to make a map "<< *b << "<" << *a << ">" << endl;
350       cerr << " list: " << endl;
351       Map_type_of_map::const_iterator i;
352       for(i=map_type_of_map.begin();i!=map_type_of_map.end();i++)
353         cerr << "\t " << *i->first.second << " <" << *i->first.first << ">" << "=" << *i->second << endl;
354       CompileError();
355    }
356    return r;
357 }
TypeArray(aType c,aType b,aType a)358 aType TypeArray(aType c,aType b,aType a)
359 {
360    // type of  c[ b, a]
361    aType ba=map_pair_of_type[make_pair(b->right(),a->right())];
362    if (!ba) {
363       cerr << "Sorry is not possible to make a type of pair  "<< *b->right() << ", " << *c->right() << " " << endl;
364       cerr << " list: " << endl;
365       Map_type_of_map::const_iterator i;
366       for(i=map_pair_of_type.begin();i!=map_pair_of_type.end();i++)
367         cerr << "\t (" << *i->first.second << " , " << *i->first.first << ") " << "=" << *i->second << endl;
368       CompileError();
369    }
370    return TypeArray(c,ba);
371 }
372 
373 
ShowOn_cerr(const pair<const char *,const OneOperator * > & i)374 inline  void ShowOn_cerr(const pair<const char * ,const OneOperator *> & i)
375 {
376    cerr << "\t" <<  *i.first << ":" <<  endl;
377    i.second->Show(cerr);
378 }
379 
ShowKeyWord(ostream & f)380 void ShowKeyWord(ostream & f )
381  {
382    zzzfff->dump(f);
383 
384  }
385 
386 // <<dumptable>>
dumptable(ostream * f)387 ostream* dumptable(ostream* f)
388 {
389 
390   *f << " the keywords " << endl;
391   ShowKeyWord(*f);
392   *f << " the types " << endl;
393   ShowType(*f);
394    ListOfTOfId::const_iterator i=tables_of_identifier.begin();
395    for(;i!=tables_of_identifier.end();++i)
396     {
397       cout << "  --------- table of identifier ---------\n";
398       TableOfIdentifier * ti=*i;
399       TableOfIdentifier::const_iterator mc=ti->m.begin();
400       TableOfIdentifier::const_iterator end=ti->m.end();
401       for (;mc != end;mc++)
402        {
403          *f  << "  - " << mc->first << ",  type :" <<  *mc->second.first << endl;
404          const Polymorphic * op =dynamic_cast<const Polymorphic *>(mc->second.second) ;
405          if ( op )  *f << *op << endl;
406        }
407 
408      }
409 
410   return f;
411 }
412 
413 
exec(string * s)414 long exec(string *s)
415     {
416       int r=execute(s->c_str());
417     //  delete s;    modif mars 2006 FH
418       return r;}
419 
420  class ostream_precis { public:
ostream_precis(ostream * ff)421  ostream_precis(ostream * ff) :f(ff) {}
422   ostream * f;
operator long() const423    operator long () const {return f->precision();}
424  };
425 
426 
427 class OP_setw { public:
428     long w;
OP_setw(long ww)429     OP_setw(long ww) :w(ww) {}
operator <<(ostream & f,const OP_setw & op)430     friend   ostream & operator<<(ostream & f,const OP_setw& op) { return f << setw(op.w);}
431 };
defOP_setw(long i)432  OP_setw defOP_setw(long i) {return OP_setw(i);}
433 
434 
ostream_precision(ostream ** f)435  ostream_precis ostream_precision(ostream **f){ return ostream_precis(*f);}
ostream_precision(ostream * f)436   ostream_precis ostream_precision(ostream *f){ return ostream_precis(f);}
get_precis(ostream_precis pf)437  long get_precis( ostream_precis  pf) { return pf.f->precision();}
set_precis(ostream_precis pf,long l)438  long set_precis( ostream_precis  pf, long  l) { return pf.f->precision(l);}
439 
440 class ostream_seekp { public:
ostream_seekp(ostream * ff)441     ostream_seekp(ostream * ff) :f(ff) {}
442     ostream * f;
operator long() const443     operator long () const {return f->tellp();}
444 };
445 
446 
447 class istream_seekg { public:
istream_seekg(istream * ff)448     istream_seekg(istream * ff) :f(ff) {}
449     istream * f;
operator long() const450     operator long () const {return f->tellg();}
451 };
452 
ff_oseekp(ostream ** f)453 ostream_seekp ff_oseekp(ostream **f){ return ostream_seekp(*f);}
ff_oseekp(ostream * f)454 ostream_seekp ff_oseekp(ostream *f){ return ostream_seekp(f);}
ff_iseekg(istream ** f)455 istream_seekg ff_iseekg(istream **f){ return istream_seekg(*f);}
ff_iseekg(istream * f)456 istream_seekg ff_iseekg(istream *f){ return istream_seekg(f);}
457 
ffseekp(ostream_seekp pf,long l)458 long ffseekp( ostream_seekp  pf, long  l) {  pf.f->clear();long ll= pf.f->tellp(); return pf.f->seekp(l),ll;}
fftellp(ostream_seekp pf)459 long fftellp( ostream_seekp  pf) { pf.f->clear(); return pf.f->tellp() ;}
ffseekg(istream_seekg pf,long l)460 long ffseekg( istream_seekg  pf, long  l) { pf.f->clear(); return pf.f->seekg(l),l;}
fftellg(istream_seekg pf)461 long fftellg( istream_seekg  pf) { return pf.f->tellg() ;}
462 
463  class istream_good { public:
istream_good(istream * ff)464   istream_good(istream * ff) :f(ff) {}
465   istream * f;
operator bool() const466   operator bool () const {return f->good();}
467  };
to_istream_good(istream ** f)468  inline istream_good to_istream_good(istream **f){ return istream_good(*f);}
to_istream_good(istream * f)469  inline istream_good to_istream_good(istream *f){ return istream_good(f);}
470 
get_good(istream_good pf)471   inline long get_good( istream_good  pf) { return pf.f->good();}
get_eof(istream ** p)472   inline bool get_eof(istream ** p){ return (**p).eof();}
filelength(istream ** p)473   long filelength(istream ** p) {
474       istream *f = *p;
475       long where=f->tellg();
476       f->seekg (0, f->end);
477       long length =f->tellg();
478       f->seekg (where);
479       return length;
480   }
eatspace(istream ** p)481   bool eatspace(istream ** p){
482     istream *f = *p;
483     int c;
484      while ( (c=f->peek())!=EOF)
485          if ( !isspace(c)) break;
486          else f->get();
487      return c != EOF;}
488 
489 typedef ios_base& ( * ostream_manipulateur )(ios_base&);
490 
default1(ios_base & f)491 ios_base&  default1(ios_base& f)
492 {
493     f.flags( (ios_base::fmtflags) 0 ) ; // (/*ios_base::scientific | */ios_base::fixed) );
494     return f;
495 }
496 
497 
498 template< ostream_manipulateur pf>
set_os(ostream ** f)499 inline ostream **set_os(ostream **f)
500 {
501     **f << pf  ; return f;
502 }
503 
set_os_flush(ostream ** f)504 inline ostream **set_os_flush(ostream **f)
505 {
506     (**f).flush()  ; return f;
507 }
set_os_flush(ostream * f)508 inline ostream *set_os_flush(ostream *f)
509 {
510     (*f).flush()  ; return f;
511 }
512 template< ostream_manipulateur pf>
set_os1(ostream * f)513 inline ostream *set_os1(ostream *f)
514 {
515     *f << pf  ; return f;
516 }
517 
518 
519 template<class R>
520 class  OneOperator_0 : public OneOperator {
521   class E_F0_F :public  E_F0mps { public:
522     typedef  R (*func)( ) ;
523     func f;
E_F0_F(func ff)524     E_F0_F(func ff)  : f(ff) {}
operator ()(Stack) const525     AnyType operator()(Stack )  const {return SetAny<R>( f()) ;}
operator aType() const526     operator aType () const { return atype<R>();}
527 
528   };
529 
530   typedef  R (*func)() ;
531   func  f;
532 public:
code(const basicAC_F0 &) const533   E_F0 * code(const basicAC_F0 & ) const
534   { return  new E_F0_F(f);}
OneOperator_0(func ff)535   OneOperator_0(func  ff): OneOperator(map_type[typeid(R).name()]),f(ff){}
536 };
537 
538 
539 void init_by_array(unsigned long init_key[], int key_length);
540 long genrand_int32(void);
541 void init_genrand(unsigned long);
genrandint(long s)542 long genrandint (long  s) { init_genrand( (unsigned long ) s); return 0;}
genrandint32()543 long genrandint32 () {return (long)  genrand_int32();}
544 
545 template<class A,class B,bool RO=true>
546 struct  MIMul {
MeshIndependentMIMul547   static bool MeshIndependent(Expression a,Expression b)
548    {
549     bool mia= a->MeshIndependent() ;
550     bool mib= b->MeshIndependent();
551     if ( mia && mib) return true;
552     else
553       {
554         if (mia && a->EvaluableWithOutStack() )
555           {
556             A va = GetAny<A>((*a)(NullStack));
557             if ( va == A() )
558              {
559                return true;
560              }
561           }
562         if (mib && b->EvaluableWithOutStack() )
563           {
564             B vb = GetAny<B>((*b)(NullStack));
565             if ( vb == B() )
566             {
567              return true; }
568            }
569          return false;
570         }
571 
572     }
ReadOnlyMIMul573   static bool ReadOnly() { return RO;}
574 
575 };
576 
577 
578 // add frev 2007
579 class opTrans : public OneOperator{
580 public:
operator ()(Stack s) const581     AnyType operator()(Stack s)  const {ffassert(0);return 0L;}
opTrans()582     opTrans():   OneOperator(atype<TransE_Array>(),atype<E_Array>()  ) {}
code(const basicAC_F0 & args) const583     E_F0 * code(const basicAC_F0 & args) const {
584 	  return new TransE_Array(dynamic_cast<const E_Array*>((Expression) args[0])); }
585 };
586 
587 class opDot : public OneOperator{
588 public:
operator ()(Stack s) const589     AnyType operator()(Stack s)  const {ffassert(0);return 0L;}
MeshIndependent() const590     bool MeshIndependent() const { return false;}
591 
opDot(aType A,aType B)592     opDot(aType A, aType B): OneOperator(atype<C_F0>(),A,B) {}
opDot()593     opDot(): OneOperator(atype<C_F0>(),atype<TransE_Array >(),atype<E_Array>()  ) {}
594 
code(const basicAC_F0 &) const595     E_F0 *  code(const basicAC_F0 & ) const {ffassert(0);}
596     C_F0  code2(const basicAC_F0 &args) const;
597 };
598 
599 class opColumn : public OneOperator{
600 public:
operator ()(Stack s) const601     AnyType operator()(Stack s)  const {ffassert(0);return 0L;}
MeshIndependent() const602     bool MeshIndependent() const { return false;}
603 
opColumn(aType A,aType B)604     opColumn(aType A, aType B): OneOperator(atype<C_F0>(),A,B) {if( A== basicForEachType::type_C_F0)pref=-100;}
opColumn(aType A)605     opColumn(aType A): OneOperator(atype<C_F0>(),ArrayOfaType(A,true)) {pref=-100;}
606 
code(const basicAC_F0 &) const607     E_F0 *  code(const basicAC_F0 & ) const {ffassert(0);}
608     C_F0  code2(const basicAC_F0 &args) const;
609 };
610 
611 class opSum : public OneOperator{
612 public:
613     const char * op;
operator ()(Stack s) const614     AnyType operator()(Stack s)  const {ffassert(0);return 0L;}
MeshIndependent() const615     bool MeshIndependent() const { return false;}
616 
opSum(const char * opp,aType A,aType B)617     opSum(const char *opp,aType A, aType B): OneOperator(atype<C_F0>(),A,B),op(opp) {}
618 
code(const basicAC_F0 &) const619     E_F0 *  code(const basicAC_F0 & ) const {ffassert(0);}
620     C_F0  code2(const basicAC_F0 &args) const;
621 };
622 
623 class opFormal : public OneOperator{
624 public:
operator ()(Stack s) const625     AnyType operator()(Stack s)  const {ffassert(0);return 0L;}
MeshIndependent() const626     bool MeshIndependent() const { return false;}
627     C_F0  (*thecode2)(const basicAC_F0 &args);
opFormal(aType A,C_F0 (c2)(const basicAC_F0 & args))628     opFormal(aType A,C_F0  (c2)(const basicAC_F0 &args) ): OneOperator(atype<C_F0>(),A),thecode2(c2) {}
code(const basicAC_F0 &) const629     E_F0 *  code(const basicAC_F0 & ) const {ffassert(0);}
code2(const basicAC_F0 & args) const630     C_F0  code2(const basicAC_F0 &args) const { return (*thecode2)(args);}
631 };
632 // fin frev 2007
633 // nov 2007   v[i]
634 class opVI : public OneOperator{
635 public:
operator ()(Stack s) const636     AnyType operator()(Stack s)  const {ffassert(0);return 0L;}
MeshIndependent() const637     bool MeshIndependent() const { return false;}
638 
opVI(aType A)639     opVI(aType A): OneOperator(atype<C_F0>(),A,atype<long>()) {}
640 
code(const basicAC_F0 &) const641     E_F0 *  code(const basicAC_F0 & ) const {ffassert(0);}
642     C_F0  code2(const basicAC_F0 &args) const;
643 };
644 
645 
formalMatCofactor(const basicAC_F0 & args)646 C_F0  formalMatCofactor(const basicAC_F0 &args)
647 {
648     bool ta =args[0].left()==atype<TransE_Array>();
649     const TransE_Array * tea=0;
650     const E_Array * ea=0;
651     if( ta)  tea = dynamic_cast<const TransE_Array*>((Expression) args[0]);
652     else ea = dynamic_cast<const E_Array*>((Expression) args[0]);
653     assert( ea || tea );
654     const E_Array & a=  ta ? *tea->v : *ea;
655     int ma =1;
656     int na=a.size();
657     if(na <1 ) CompileError(" Cofactor  ([ ...])  ");
658     bool maa= a[0].left()==atype<E_Array>();
659     if(maa) {
660 	ma= a[0].LeftValue()->nbitem();
661 	for (int i=1;i<na;i++)
662 	    if( ma != (int) a[i].LeftValue()->nbitem())
663 		CompileError(" a matrix with variable number of columm");
664 
665     }
666 
667     int na1=na,ma1=ma;
668     if(ta) RNM::Exchange(na1,ma1);
669     if(na1 != ma1) CompileError(" CoFactor:  no square matrix ");
670     if(na1 > 3 || ( na1 <1) ) CompileError(" CoFactor:   square matrix size is more then 3   ");
671     KNM<CC_F0> A(na1,na1);
672     KNM<CC_F0> C(na1,na1);
673     if(maa)
674 	for (int i=0;i<na;++i)
675 	{
676 	    const E_Array * li=  dynamic_cast<const E_Array *>(a[i].LeftValue());
677 	    ffassert(li);
678 	    for (int j=0; j<ma;++j)
679 		if(!ta)  A(i,j) = (*li)[j];
680 		else     A(j,i) = TryConj((*li)[j]);
681 	}
682     else
683         for (int i=0;i<na;++i)
684             if(!ta)  A(i,0) = a[i];
685             else     A(0,i) = TryConj(a[i]);
686 
687 
688     AC_F0  v,cc;
689     if(na1==2)
690     {
691       for(int i=0;i<na1;++i)
692         for(int j=0;j<na1;++j)
693           if( (i+j) %2 == 0)
694             C(i,j) = A(1-i,1-j);
695           else
696             C(i,j) = C_F0(TheOperators,"-",A(1-i,1-j));
697     }
698     else if( na1 ==3)
699     {
700         int i1,i2,j1,j2;
701         for(int i=0;i<3;++i)
702           for(int j=0;j<3;++j)
703           {
704               i1 = (i+1)%3;
705               i2 = (i+2)%3;
706               j1 = (j+1)%3;
707               j2 = (j+2)%3;
708 
709             C(i,j) = A(i1,j1)*A(i2,j2)-A(i1,j2)*A(i2,j1);
710           }
711     }
712     v=C(0,0);
713 
714     for (int i=0;i<na1;++i)
715     {  cc = C(i,0);
716         for (int j=1;j<ma1;++j)
717             cc+= C(i,j);
718         C_F0  vi(TheOperators,"[]",cc);
719         if(i==0) v=vi;
720         else v+= vi;
721     }
722     return C_F0(TheOperators,"[]",v);
723 
724 
725 }
726 
formalMatTrace(const basicAC_F0 & args)727 C_F0  formalMatTrace(const basicAC_F0 &args)
728 {
729     bool ta =args[0].left()==atype<TransE_Array>();
730     const TransE_Array * tea=0;
731     const E_Array * ea=0;
732 	if( ta)  tea = dynamic_cast<const TransE_Array*>((Expression) args[0]);
733     else ea = dynamic_cast<const E_Array*>((Expression) args[0]);
734     assert( ea || tea );
735     const E_Array & a=  ta ? *tea->v : *ea;
736     int ma =1;
737     int na=a.size();
738     if(na <1 ) CompileError(" trace  [ ...]  ");
739     bool maa= a[0].left()==atype<E_Array>();
740     if(maa) {
741 	ma= a[0].LeftValue()->nbitem();
742 	for (int i=1;i<na;i++)
743 	    if( ma != (int) a[i].LeftValue()->nbitem())
744 		CompileError(" first matrix with variable number of columm");
745 
746     }
747 
748     int na1=na,ma1=ma;
749     if(ta) RNM::Exchange(na1,ma1);
750     if(na1 != ma1) CompileError(" trace:  no square matrix ");
751     KNM<CC_F0> A(na1,ma1);
752 
753     if(maa)
754 	for (int i=0;i<na;++i)
755 	{
756 	    const E_Array * li=  dynamic_cast<const E_Array *>(a[i].LeftValue());
757 	    ffassert(li);
758 	    for (int j=0; j<ma;++j)
759 		if(!ta)  A(i,j) = (*li)[j];
760 		else     A(j,i) = TryConj((*li)[j]);
761 	}
762 	    else
763 		for (int i=0;i<na;++i)
764 		    if(!ta)  A(i,0) = a[i];
765 		    else     A(0,i) = TryConj(a[i]);
766 
767 
768     CC_F0 s;
769     s= A(0,0); // correction feb. 2016 Thank to O. Pironneau
770     for (int i=1;i<na1;++i)
771 	s = C_F0(TheOperators,"+",s,A(i,i));
772     return  s;
773 
774 }
775 
776 
formalMatDet(const basicAC_F0 & args)777 C_F0  formalMatDet(const basicAC_F0 &args)
778 {
779     bool ta =args[0].left()==atype<TransE_Array>();
780     const TransE_Array * tea=0;
781     const E_Array * ea=0;
782     if( ta)  tea = dynamic_cast<const TransE_Array*>((Expression) args[0]);
783     else ea = dynamic_cast<const E_Array*>((Expression) args[0]);
784     assert( ea || tea );
785     const E_Array & a=  ta ? *tea->v : *ea;
786     int ma =1;
787     int na=a.size();
788     if(na <1 ) CompileError(" trace  [ ...]  ");
789     bool maa= a[0].left()==atype<E_Array>();
790     if(maa) {
791 	ma= a[0].LeftValue()->nbitem();
792 	for (int i=1;i<na;i++)
793 	    if( ma != (int) a[i].LeftValue()->nbitem())
794 		CompileError("  matrix with variable number of columm");
795 
796     }
797 
798     int na1=na,ma1=ma;
799     if(ta) RNM::Exchange(na1,ma1);
800     if(na1 != ma1) CompileError(" trace:  no square matrix ");
801     KNM<CC_F0> A(na1,ma1);
802 
803     if(maa)
804 	for (int i=0;i<na;++i)
805 	{
806 	    const E_Array * li=  dynamic_cast<const E_Array *>(a[i].LeftValue());
807 	    ffassert(li);
808 	    for (int j=0; j<ma;++j)
809 		if(!ta)  A(i,j) = (*li)[j];
810 		else     A(j,i) = TryConj((*li)[j]);
811 	}
812 	    else
813 		for (int i=0;i<na;++i)
814 		    if(!ta)  A(i,0) = a[i];
815 		    else     A(0,i) = TryConj(a[i]);
816 
817 
818     if(na1==1)
819       return  A(0,0);
820     else if( na1==2 )
821     {
822 	C_F0 s1(TheOperators,"*",A(0,0),A(1,1));
823 	C_F0 s2(TheOperators,"*",A(0,1),A(1,0));
824 	return C_F0(TheOperators,"-",s1,s2);
825     }
826     else if( na1==3 )
827     {
828         int i=0,ii=(i+1)%3,iii=(i+2)%3;
829         A(i,0)*A(i,0);
830         C_F0 det = A(i,0)*A(ii,1)*A(iii,2) - A(i,0)*A(ii,2)*A(iii,1);
831         i++;ii=(i+1)%3,iii=(i+2)%3;
832         det +=  A(i,0)*A(ii,1)*A(iii,2) - A(i,0)*A(ii,2)*A(iii,1);
833         i++;ii=(i+1)%3,iii=(i+2)%3;
834         det +=  A(i,0)*A(ii,1)*A(iii,2) - A(i,0)*A(ii,2)*A(iii,1);
835         return det;
836     }
837     else
838     {
839 	CompileError("FH: sorry only det of 1x1 and 2x2 matrix ");
840     }
841     return  C_F0();
842 
843 }
844 
845 //  Add juin  2007
846 template<class A,class B=A,class R=A>
847 struct evalE_mul {
evalevalE_mul848     static AnyType eval(Stack s,const E_F0 * ab,const E_F0 * a,const E_F0 * b, bool & meshidenp)
849     {
850 	A aa = GetAny<A>((*a)(s)) ;
851 	B bb = GetAny<B>((*b)(s)) ;
852 	R rr(aa*bb);
853 	bool mia=a->MeshIndependent();
854 	bool mib=b->MeshIndependent();
855 
856 	if (( aa == A()) && mia ) meshidenp=true;
857 	else if(( bb == B()) && mib ) meshidenp=true;
858         else meshidenp = mib && mia;
859 	cout << " meshidenp ??? " << meshidenp << " " << rr << endl;
860 	return SetAny<R>(static_cast<R>(rr));
861     }
862 };
Getline(istream * f,string ** s)863 istream *Getline(istream * f, string ** s)
864 {
865     if( *s==0) *s=newstring();
866     getline(*f,**s);
867     size_t l = (**s).length();
868     if( l > 0 && ((**s)[l-1]=='\r')) (**s).resize(l-1); //
869        return f;
870 }
871 // Fin Add ne marche pas ....
872 // fiun avril 2007
873 //  Hack to Bypass a bug in freefem FH  ...
874 template<>
875 class ForEachType<void *>:  public basicForEachType{public:// correction july 2009..... FH  Hoooo....  (Il y a un bug DUR DUR FH  ...)
ForEachType(Function1 iv=0,Function1 id=0,Function1 OOnReturn=0)876     ForEachType(Function1 iv=0,Function1 id=0,Function1 OOnReturn=0):basicForEachType(typeid(void *),sizeof(void *),0,0,iv,id,OOnReturn) { }
877 };
878 
walltime()879 inline double walltime(){
880     // add for Pichon mars 2010
881     time_t currentWallTime;
882     time(&currentWallTime);
883     return (double)currentWallTime;
884 }
885 
fftime()886 inline long fftime()
887 {
888     time_t tloc;
889     return time(&tloc);
890 }
ffstrtol(string * p)891 long ffstrtol(string* p)
892 {
893     char * pe;
894     const char *pp=p->c_str();
895     long r = strtol(pp,&pe,10);
896     const char *ppe = pe, *pppe= pp+p->size();
897     assert(ppe <= pppe);
898     for(const char *ppe = pe; ppe < pppe; ++ppe)
899         ffassert(isspace(*ppe));
900     return r;
901 
902 }
ffstrtol(string * p,long d)903 long ffstrtol(string* p,long d)
904 {
905     char * pe;
906     const char *pp=p->c_str();
907     long r = strtol(pp,&pe,d);
908     const char *ppe = pe, *pppe= pp+p->size();
909     ffassert(ppe <= pppe);
910     for(const char *ppe = pe; ppe < pppe; ++ppe)
911         ffassert(isspace(*ppe));
912     return r;
913 }
914 
ffstrtod(string * p)915 double ffstrtod(string* p)
916 {
917     char * pe;
918     const char *pp=p->c_str();
919     double r = strtod(pp,&pe);
920     const char *ppe = pe, *pppe= pp+p->size();
921     ffassert(ppe <= pppe);
922     for(const char *ppe = pe; ppe < pppe; ++ppe)
923         ffassert(isspace(*ppe));
924     return r;
925 
926 }
927 
atoi(string * p)928 long atoi(string* p) {return atol(p->c_str());}// add march 2010
atof(string * p)929 double atof(string* p) {return atof(p->c_str());}// add march 2010
NaN(string * p)930 double NaN(string* p) {
931 return nan(p->c_str());}// add march 2012
NaN()932 double NaN() {return nan("");}// add march 2012
933 int ShowAlloc(const char *s,size_t & lg);
ShowAlloc1(string * s,long * np)934 long ShowAlloc1(string *  s,long * np) { size_t lg; long  n= ShowAlloc(s->c_str(),lg); *np=lg; return n;}
ShowAlloc1(string * s)935 long ShowAlloc1(string *  s) { size_t lg; long  n= ShowAlloc(s->c_str(),lg); return n;}
936 
937 class E_ForAllLoopMapSS
938 {  public:
939     typedef String K;
940     typedef String V;
941     typedef string *KK;
942     typedef string *VV;
943 
944     typedef MyMap<K,V>  *Tab;
945     typedef   MyMap<K,V>::iterator TabI ;
946 
947     typedef  ForAllLoopOpBase DataL;
948     const DataL *data;
E_ForAllLoopMapSS(const DataL * t)949     E_ForAllLoopMapSS(const DataL *t): data(t){}
f(Stack s) const950     AnyType f(Stack s) const {
951         TabI  ii;
952         Tab t= GetAny<Tab >(data->tab(s));
953 
954         KK * i   =   GetAny<KK* >(data->i(s));
955         VV * v   =   GetAny<VV* >(data->v(s));
956         if(verbosity>1000) {
957             cout << " i " << (char*) (void *) i -  (char*)(void*) s ;
958             cout << " vi " <<  (char*) (void *) v -  (char*)(void*) s ;
959             cout << endl;}
960 
961 
962         ffassert(i && v);
963         if(t->m)
964             ii=t->m->begin();
965         bool ok = true;
966         while(ok)
967         {
968             if(verbosity>99999) cout << " new n";
969             TabI iip=ii++;
970             ok = ii != t->m->end();
971             String  kk = iip->first;
972             String  vv = iip->second;
973             const string * pvo=iip->second;
974 
975             *i =  kk;
976             *v =  vv;
977             const string * pv =*v;
978             // for  Windows otherwise trap ???? FH. march 2016
979             if(verbosity>99999) cout << "  b:" << i << " "<< v  << " "  << kk << " " <<  vv << endl;
980 
981             data->code(s);
982             if(verbosity>99999) cout << "  a:" << i << " "<< v  << " "  << kk << " " <<  **v << endl;
983             if( pvo  == (const string *) iip->second) // no  change m[i]=
984             {if( *v != pv ) //  v change
985                 iip->second  = **v;
986             }
987             else if( *v != pv )
988             {//  v change
989                 cerr << " Erreur forall change m[i] and mi (stupide please choosse) \n";
990                 ffassert(0);
991             }
992             if(verbosity>99999) cout << " A;" << i << " "<< v  << " "  << kk << " " <<  vv << " ok =" << ok << endl;
993 
994             *i=0;
995             *v=0;
996             if(verbosity>99999)
997             {
998                 cout << " 0:" << i << " "<< v  << " "  << kk << " " <<  vv << endl;
999                 for (TabI iii=t->m->begin();iii!= t->m->end();++iii)
1000                     cout << " map =" << iii->first << " -> " << iii->second << endl;
1001                 cout << " end of map " << endl;
1002             }
1003         }
1004         return Nothing  ;
1005     }
1006 
1007 };
projection(const double & aa,const double & bb,const double & x)1008 double projection(const double & aa, const double & bb, const double & x )
1009 { double a=aa,b=bb; if(a>b) std::swap(a,b); return min(max(a,x),b);}
dist(const double & aa,const double & bb)1010 double dist(const double & aa, const double & bb) { return sqrt( aa*aa+bb*bb);}
dist(const double & aa,const double & bb,const double & cc)1011 double dist(const double & aa, const double & bb,const double & cc) { return sqrt(aa*aa+bb*bb+cc*cc);}
1012 // Add Jan 2017 FH
diffpos(const double & aa,const double & bb)1013 double diffpos(const double & aa, const double & bb) { return aa<bb ? bb-aa : 0.;}
invdiffpos(const double & aa,const double & bb)1014 double invdiffpos(const double & aa, const double & bb) { return aa<bb ? 1./(bb-aa) : 0.;}
diffnp(const double & aa,const double & bb)1015 double diffnp(const double & aa, const double & bb) { return aa<0. && 0.<bb ? bb-aa : 0.;}//  Corr 08/18  G. Sadaka
invdiffnp(const double & aa,const double & bb)1016 double invdiffnp(const double & aa, const double & bb) { return aa<0. && 0.<bb  ? 1./max(bb-aa,1e-30) : 0.;}//  Corr 08/18  G. Sadaka
invdiff(const double & aa,const double & bb)1017 double invdiff(const double & aa, const double & bb) { double d= aa-bb; return abs(d) < 1e-30 ? d : 1/d;}
invdiff(const double & aa,const double & bb,const double & eps)1018 double invdiff(const double & aa, const double & bb,const double &eps) { double d= aa-bb; return abs(d) < eps ? d : 1/d;}
1019 extern double ff_tgv; // Add FH jan 2018
sign(double x)1020 double sign(double x){return (x>0.)-(x<0.); }// Add FH jan 2018
sign(long x)1021 long sign(long x){return (x>0)-(x<0); }// Add FH jan 2018
ffsignbit(long x)1022 bool ffsignbit(long x){return signbit(x);}
ffsignbit(double x)1023 bool ffsignbit(double x){return signbit(x);}
1024 template<typename T>
pswap(T * a,T * b)1025 bool  pswap(T *a,T *b) {swap(*a,*b);return 0; }
1026 
Init_map_type()1027 void Init_map_type()
1028 {
1029    TheOperators=new Polymorphic(),
1030    TheRightOperators=new Polymorphic();
1031     map_type[typeid(AnyType).name()] = new ForTypeAnyType();
1032     map_type[typeid(void).name()] = new ForTypeVoid();
1033        InitLoop();
1034     Dcl_Type<Expression>(0);
1035     Dcl_TypeandPtr<double>(0,0,::InitializeDef<double>,0);
1036     Dcl_TypeandPtr<long>(0,0,::InitializeDef<long>,0);
1037     Dcl_TypeandPtr<bool>(0,0,::InitializeDef<bool>,0);
1038     Dcl_TypeandPtr<Complex>(0,0,::InitializeDef<Complex>,0);
1039     Dcl_Type<void*>(); // add FH ...  for mpi comm world
1040     Dcl_Type<char*>();
1041     Dcl_Type<const char *>();
1042     Dcl_Type<char>();
1043     Dcl_TypeandPtr<string*>(0,0,::InitializePtr<string*>,::DeletePtr<string*>);
1044     Dcl_TypeandPtr<ostream*>(0,0,::InitializePtr<ostream*>,::DeletePtr<ostream*>);
1045     Dcl_TypeandPtr<istream*>(0,0,::InitializePtr<istream*>,::DeletePtr<istream*>);
1046     Dcl_Type< ostream_precis > ();
1047     Dcl_Type< ostream_seekp > ();
1048     Dcl_Type< istream_seekg > ();
1049     Dcl_Type< istream_good > ();
1050     Dcl_Type< NothingType > ();
1051     Dcl_Type<OP_setw>();
1052     Dcl_Type<Polymorphic*>();
1053 
1054     basicForEachType::type_C_F0 = map_type[typeid(C_F0).name()] =  new TypeLineFunction;
1055     Dcl_Type<E_Array>();
1056     Dcl_Type<TransE_Array >();// add
1057     Dcl_Type<const E_Border *>();
1058     Dcl_Type<const E_BorderN *>();
1059     typedef MyMap<String,String> MyMapSS;
1060     map_type[typeid(MyMapSS*).name()] = new ForEachType<MyMapSS*>(Initialize<MyMapSS >,Delete<MyMapSS >) ;
1061     map_type_of_map[make_pair(atype<string*>(),atype<string*>())]=atype<MyMapSS*>();
1062 
1063 
1064     Dcl_Type<SubArray>();
1065     Dcl_Type<pair<long,long> >();
1066 
1067     initArrayDCLlong();
1068     initArrayDCLdouble();
1069     initArrayDCLComplex();
1070 
1071     Dcl_Type<ios::openmode>();
1072 
1073     // <<known_variable_types>> les types des variables
1074 
1075   zzzfff->Add("real",typevarreal=atype<double*>());
1076   zzzfff->Add("int",atype<long*>());
1077   zzzfff->Add("complex",typevarcomplex=atype<Complex*>());
1078   zzzfff->Add("bool",atype<bool*>());
1079   zzzfff->Add("string",atype<string**>());
1080   zzzfff->Add("ifstream",atype<istream**>());
1081   zzzfff->Add("ofstream",atype<ostream**>());
1082   zzzfff->AddF("func",atype<C_F0>());
1083 
1084 
1085 
1086 //  end of know types
1087 
1088      map_type[typeid(bool).name()]->AddCast(
1089        new E_F1_funcT<bool,bool*>(UnRef<bool>),
1090        new E_F1_funcT<bool,long>(Cast<bool,long>),
1091        new E_F1_funcT<bool,double>(Cast<bool,double>)
1092        );
1093 
1094 
1095      map_type[typeid(long).name()]->AddCast(
1096        new E_F1_funcT<long,long*>(UnRef<long>),
1097        new E_F1_funcT<long,double>(Cast<long,double>),
1098        new E_F1_funcT<long,bool>(Cast<long,bool>),
1099        new E_F1_funcT<long,ostream_precis>(Cast<long,ostream_precis>),
1100        new E_F1_funcT<long,ostream_seekp>(Cast<long,ostream_seekp>),
1101        new E_F1_funcT<long,istream_seekg>(Cast<long,istream_seekg>)
1102        );
1103 
1104 
1105      map_type[typeid(double).name()]->AddCast(
1106        new E_F1_funcT<double,double*>(UnRef<double>),
1107        new E_F1_funcT<double,long>(Cast<double,long>),
1108        new E_F1_funcT<double,bool>(Cast<double,bool>)
1109 
1110        );
1111 
1112      map_type[typeid(Complex).name()]->AddCast(
1113        new E_F1_funcT<Complex,Complex*>(UnRef<Complex>),
1114        new E_F1_funcT<Complex,long>(Cast<Complex,long>),
1115        new E_F1_funcT<Complex,double>(Cast<Complex,double>)
1116        );
1117 
1118      map_type[typeid(string*).name()]->AddCast(
1119        new E_F1_funcT<string*,string**>(UnRefCopyPtr<string>),
1120        new E_F1_funcT<string*,long>(FCast<string*,long,toString>),
1121        new E_F1_funcT<string*,double>(FCast<string*,double,toString>),
1122        new E_F1_funcT<string*,bool>(FCast<string*,bool,toString>),
1123        new E_F1_funcT<string*,Complex>(FCast<string*,Complex,toString>)
1124         );
1125      //   a changer ---------------  modif
1126         map_type[typeid(string*).name()]->AddCast(
1127           new E_F1_funcT<string*,char *>(FCast<string*,char *,toStringC>),
1128           new E_F1_funcT<string*,const char *>(FCast<string* ,const char *,toStringCconst>)
1129        );
1130 
1131      map_type[typeid(long).name()]->AddCast(new OneOperator_border_label);
1132 
1133      Global.New("verbosity",CPValue<long>(verbosity));
1134 
1135      Global.New("searchMethod",CPValue<long>(searchMethod)); //pichon
1136      Global.New("tgv",CPValue<double>(ff_tgv));
1137      Global.New("lockOrientation",CPValue<bool>(lockOrientation));
1138      extern long newconvect3;// def in global.cpp
1139      Global.New("newconvect",CPValue<long>(newconvect3)); //pichon
1140 
1141      // <<cout>> uses [[file:AFunction.hpp::CConstant]]
1142      Global.New("cout",CConstant<ostream*>(&cout));
1143 
1144      Global.New("cerr",CConstant<ostream*>(&cerr));// add jan 2014 FH.
1145      Global.New("cin",CConstant<istream*>(&cin));
1146      Global.New("append",CConstant<ios::openmode>(ios::app));
1147      Global.New("binary",CConstant<ios::openmode>(ios::binary)); // add FH april 2014
1148      TheOperators->Add("|",new OneBinaryOperator<Op2_pipe<ios::openmode> >); // add FH april 2014
1149      Global.New("endl",CConstant<const char*>("\n"));
1150      Global.New("true",CConstant<bool>(true));
1151      Global.New("false",CConstant<bool>(false));
1152      Global.New("pi",CConstant<double>(3.14159265358979323846264338328));
1153      Global.New("version",CConstant<double>(VersionNumber()));
1154 
1155      Global.New("showCPU",CPValue<bool>(showCPU));
1156      Global.New("CPUTime",CConstant<bool*>(&showCPU));
1157      // def de Zero et One
1158      pZero = new  C_F0(CConstant<double>(0.0));
1159      pOne = new  C_F0(CConstant<double>(1.0));
1160      pminusOne = new  C_F0(CConstant<double>(-1.0));
1161 
1162      TheOperators->Add(":",
1163        new OneOperatorConst<char>(new EConstant<char>(':')),
1164        new OneBinaryOperator<SubArray2>,
1165        new OneTernaryOperator3<SubArray3>);
1166 
1167 
1168      TheOperators->Add("+",
1169        new OneBinaryOperator<Op2_add<long,long,long> >,
1170        new OneBinaryOperator<Op2_add<double,double,double> >,
1171        new OneBinaryOperator<Op2_add<double,double,long> >,
1172        new OneBinaryOperator<Op2_add<double,long,double> >,
1173        new OneBinaryOperator<Op2_add<long,bool,bool> >,
1174        new OneBinaryOperator<Op2_add<long,long,bool> >,
1175        new OneBinaryOperator<Op2_add<long,bool,long> >,
1176        new OneBinaryOperator<Op2_add<Complex,Complex,Complex> >,
1177        new OneBinaryOperator<Op2_add<Complex,Complex,double> >,
1178        new OneBinaryOperator<Op2_add<Complex,double,Complex> >,
1179        new OneBinaryOperator<Op2_add<Complex,Complex,long> >,
1180        new OneBinaryOperator<Op2_add<Complex,long,Complex> > ,
1181        new OneBinaryOperator_st<Op2_padd<string,string*,string*> >  // a changer to do FH string * mars 2006
1182        );
1183      TheOperators->Add("-",
1184        new OneBinaryOperator<Op2_sub<long,long,long> >,
1185        new OneBinaryOperator<Op2_sub<double,double,double> >,
1186        new OneBinaryOperator<Op2_sub<double,double,long> >,
1187        new OneBinaryOperator<Op2_sub<double,long,double> >,
1188        new OneBinaryOperator<Op2_sub<long,bool,bool> >,
1189        new OneBinaryOperator<Op2_sub<long,long,bool> >,
1190        new OneBinaryOperator<Op2_sub<long,bool,long> >,
1191        new OneBinaryOperator<Op2_sub<Complex,Complex,Complex> >,
1192        new OneBinaryOperator<Op2_sub<Complex,Complex,double> >,
1193        new OneBinaryOperator<Op2_sub<Complex,double,Complex> >,
1194        new OneBinaryOperator<Op2_sub<Complex,Complex,long> >,
1195        new OneBinaryOperator<Op2_sub<Complex,long,Complex> >
1196        );
1197 
1198      TheOperators->Add("*",
1199        new OneBinaryOperator<Op2_mul<bool,bool,bool>,OneBinaryOperatorMI,evalE_mul<bool> >,
1200        new OneBinaryOperator<Op2_mul<long,long,long>,OneBinaryOperatorMI,evalE_mul<long> >,
1201        new OneBinaryOperator<Op2_mul<double,double,double>,MIMul<double,double>,evalE_mul<double> >,
1202        new OneBinaryOperator<Op2_mul<double,double,long>, MIMul<double,long>,evalE_mul<double,long,double> >,
1203        new OneBinaryOperator<Op2_mul<double,long,double>,MIMul<long,double>,evalE_mul<long,double,double>  >,
1204        new OneBinaryOperator<Op2_mul<Complex,Complex,Complex> >,
1205        new OneBinaryOperator<Op2_mul<Complex,Complex,double> >,
1206        new OneBinaryOperator<Op2_mul<Complex,double,Complex> >,
1207        new OneBinaryOperator<Op2_mul<Complex,Complex,long> >,
1208        new OneBinaryOperator<Op2_mul<Complex,long,Complex> >,
1209        new OneBinaryOperator<Op2_mul<long,long,bool> >,
1210        new OneBinaryOperator<Op2_mul<long,bool,long> >
1211        );
1212     // add missing operation jan 2017 FH.
1213     TheOperators->Add("*",
1214                       new OneBinaryOperator<Op2_mul<Complex,Complex,bool> >,
1215                       new OneBinaryOperator<Op2_mul<Complex,bool,Complex> >
1216                       );
1217     TheOperators->Add("+",
1218                       new OneBinaryOperator<Op2_add<Complex,Complex,bool> >,
1219                       new OneBinaryOperator<Op2_add<Complex,bool,Complex> >
1220                       );
1221     TheOperators->Add("-",
1222                       new OneBinaryOperator<Op2_sub<Complex,Complex,bool> >,
1223                       new OneBinaryOperator<Op2_sub<Complex,bool,Complex> >
1224                       );
1225     TheOperators->Add("/",
1226                 //      new OneBinaryOperator<Op2_sub<Complex,Complex,bool> >,
1227                       new OneBinaryOperator<Op2_div<Complex,bool,Complex> >
1228                       );
1229 
1230      TheOperators->Add("/",
1231        new OneBinaryOperator<Op2_div<long,long,long> >,
1232        new OneBinaryOperator<Op2_div<double,double,double> >,
1233        new OneBinaryOperator<Op2_div<double,double,long> >,
1234        new OneBinaryOperator<Op2_div<double,long,double> >,
1235        new OneBinaryOperator<Op2_div<Complex,Complex,Complex> >,
1236        new OneBinaryOperator<Op2_div<Complex,Complex,double> >,
1237        new OneBinaryOperator<Op2_div<Complex,double,Complex> >,
1238        new OneBinaryOperator<Op2_div<Complex,Complex,long> >,
1239        new OneBinaryOperator<Op2_div<Complex,long,Complex> >
1240        );
1241 
1242      TheOperators->Add("%",
1243        new OneBinaryOperator<Op2_mod<long,long,long> >
1244        );
1245 
1246 
1247     TheOperators->Add("+",
1248        new OneUnaryOperator<Op1_plus<double> >,
1249        new OneUnaryOperator<Op1_plus<long> >,
1250        new OneUnaryOperator<Op1_plus<Complex> >);
1251 
1252     TheOperators->Add("-",
1253        new OneUnaryOperator<Op1_neg<double> >,
1254        new OneUnaryOperator<Op1_neg<long> >,
1255        new OneUnaryOperator<Op1_neg<Complex> >);
1256 
1257      TheOperators->Add("^",
1258 		       new OneBinaryOperator<Op2_pow<long,long,long> >,
1259 		       new OneBinaryOperator<Op2_pow<double,double,double> >,
1260 		       new OneBinaryOperator<Op2_pow<double,double,long> >,
1261 		       new OneBinaryOperator<Op2_pow<Complex,Complex,Complex> >
1262      );
1263 
1264      TheOperators->Add("<",
1265        new OneBinaryOperator<Op2_lt<long,long> >,
1266        new OneBinaryOperator<Op2_lt<double,double> >,
1267        new OneBinaryOperator<Op2_plt<string*,string*> >  //  FH string * mars 2006
1268      );
1269      TheOperators->Add("<=",
1270        new OneBinaryOperator<Op2_le<long,long> >,
1271        new OneBinaryOperator<Op2_le<double,double> >,
1272        new OneBinaryOperator<Op2_ple<string*,string*> >  //  FH string * mars 2006
1273      );
1274      TheOperators->Add(">",
1275        new OneBinaryOperator<Op2_gt<long,long> >,
1276        new OneBinaryOperator<Op2_gt<double,double> >,
1277        new OneBinaryOperator<Op2_pgt<string*,string*> >  //  string * mars 2006
1278      );
1279      TheOperators->Add(">=",
1280        new OneBinaryOperator<Op2_ge<long,long> >,
1281        new OneBinaryOperator<Op2_ge<double,double> >,
1282        new OneBinaryOperator<Op2_pge<string*,string*> >  //  FH string * mars 2006
1283      );
1284      TheOperators->Add("==",
1285        new OneBinaryOperator<Op2_eq<long,long> >,
1286        new OneBinaryOperator<Op2_eq<double,double> >,
1287        new OneBinaryOperator<Op2_eq<Complex,Complex> >,
1288        new OneBinaryOperator<Op2_peq<string*,string*> >  //   FH string * mars 2006
1289      );
1290 
1291      TheOperators->Add("!=",
1292        new OneBinaryOperator<Op2_ne<long,long> >,
1293        new OneBinaryOperator<Op2_ne<double,double> >,
1294        new OneBinaryOperator<Op2_ne<Complex,Complex> >,
1295        new OneBinaryOperator<Op2_pne<string*,string*> >  //  FH string * mars 2006
1296      );
1297 
1298      TheOperators->Add("!",
1299        new OneUnaryOperator<Op1_not<bool > >
1300      );
1301 
1302      TheOperators->Add("&&", new OneBinaryOperator<Op2_and > );
1303      TheOperators->Add("&", new OneBinaryOperator<Op2_and > );
1304      TheOperators->Add("||", new OneBinaryOperator<Op2_or> );
1305      TheOperators->Add("|", new OneBinaryOperator<Op2_or> );
1306 
1307       // Unary_Op_Comparaision
1308 
1309      TheOperators->Add("=",
1310        new OneBinaryOperator<set_eq<bool> ,OneBinaryOperatorMIWO >,
1311        new OneBinaryOperator<set_eq<long> ,OneBinaryOperatorMIWO>,
1312        new OneBinaryOperator<set_eq<double> ,OneBinaryOperatorMIWO>,
1313        new OneBinaryOperator<set_eq<Complex> ,OneBinaryOperatorMIWO>,
1314        new OneBinaryOperator<set_peqstring ,OneBinaryOperatorMIWO>  // FH string * mars 2006
1315        );
1316 
1317      TheOperators->Add("?:",
1318        new Operator_Aritm_If<bool >,
1319        new Operator_Aritm_If<long >,
1320        new Operator_Aritm_If<double >,
1321        new Operator_Aritm_If<Complex >,
1322        new Operator_Aritm_If<string* >  // (OK???)  to do FH string * mars 2006
1323        );
1324 
1325      initArrayOperatorlong();
1326      initArrayOperatordouble();
1327      initArrayOperatorComplex();
1328      initStringOperator();
1329 
1330 
1331      TheOperators->Add("+=",
1332        new OneBinaryOperator<set_eq_add<long>,OneBinaryOperatorMIWO >,
1333        new OneBinaryOperator<set_eq_add<double>,OneBinaryOperatorMIWO >,
1334        new OneBinaryOperator<set_eq_add<Complex>,OneBinaryOperatorMIWO >
1335       );
1336 
1337 
1338      TheOperators->Add("-=",
1339        new OneBinaryOperator<set_eq_sub<long>,OneBinaryOperatorMIWO >,
1340        new OneBinaryOperator<set_eq_sub<double>,OneBinaryOperatorMIWO >,
1341        new OneBinaryOperator<set_eq_sub<Complex>,OneBinaryOperatorMIWO >
1342       );
1343 
1344 
1345 
1346      TheOperators->Add("*=",
1347        new OneBinaryOperator<set_eq_mul<long> ,OneBinaryOperatorMIWO>,
1348        new OneBinaryOperator<set_eq_mul<double>,OneBinaryOperatorMIWO >,
1349        new OneBinaryOperator<set_eq_mul<Complex>,OneBinaryOperatorMIWO >
1350       );
1351 
1352 
1353      TheOperators->Add("/=",
1354        new OneBinaryOperator<set_eq_div<long>,OneBinaryOperatorMIWO >,
1355        new OneBinaryOperator<set_eq_div<double>,OneBinaryOperatorMIWO >,
1356        new OneBinaryOperator<set_eq_div<Complex>,OneBinaryOperatorMIWO >
1357      );
1358 
1359      TheOperators->Add("+",
1360        new AddBorderOperator
1361        );
1362 
1363       // add frev 2007
1364       TheOperators->Add("\'", new opTrans);
1365 
1366     TheOperators->Add("*",new opDot(atype<TransE_Array >(),atype<E_Array>() )   );  // a faire mais dur
1367       TheOperators->Add("*",new opDot(atype<E_Array >(),atype<E_Array>() )   );  // a faire mais dur
1368       TheOperators->Add("*",new opColumn(atype<E_Array >() )   );  //  [ ]* C_F0 (all)
1369       TheOperators->Add("*",new opColumn(basicForEachType::type_C_F0,atype<E_Array >() )   );  //  [ ]* C_F0 (all)
1370       TheOperators->Add("*",new opColumn(basicForEachType::type_C_F0,atype<TransE_Array >() )   );  //  [ ]* C_F0 (all)
1371 //    type_C_F0
1372       TheOperators->Add("::",new opColumn(atype<E_Array >(),atype<E_Array>() )   );  // a faire mais dur
1373       TheOperators->Add("*",new opDot(atype<E_Array >(),atype<TransE_Array>() )   );  // a faire mais dur
1374       TheOperators->Add("*",new opDot(atype<TransE_Array >(),atype<TransE_Array>() )   );  // a faire mais dur
1375 
1376      // car le type de retour depent des objets du tableau
1377       atype<E_Array >()->Add("[","",new opVI(atype<E_Array >())   );
1378       atype<TransE_Array >()->Add("[","",new opVI(atype<TransE_Array >())   );
1379       TheOperators->Add("+",new opSum("+",atype<TransE_Array >(),atype<E_Array>() )   );  // a faire mais dur
1380       TheOperators->Add("+",new opSum("+",atype<E_Array >(),atype<E_Array>() )   );  // a faire mais dur
1381       TheOperators->Add("+",new opSum("+",atype<E_Array >(),atype<TransE_Array>() )   );  // a faire mais dur
1382       TheOperators->Add("+",new opSum("+",atype<TransE_Array >(),atype<TransE_Array>() )   );  // a faire mais dur
1383       TheOperators->Add("-",new opSum("-",atype<TransE_Array >(),atype<E_Array>() )   );  // a faire mais dur
1384       TheOperators->Add("-",new opSum("-",atype<E_Array >(),atype<E_Array>() )   );  // a faire mais dur
1385       TheOperators->Add("-",new opSum("-",atype<E_Array >(),atype<TransE_Array>() )   );  // a faire mais dur
1386       TheOperators->Add("-",new opSum("-",atype<TransE_Array >(),atype<TransE_Array>() )   );  // a faire mais dur
1387       TheOperators->Add(".*",new opSum("*",atype<TransE_Array >(),atype<E_Array>() )   );  // a faire mais dur
1388       TheOperators->Add(".*",new opSum("*",atype<E_Array >(),atype<E_Array>() )   );  // a faire mais dur
1389       TheOperators->Add(".*",new opSum("*",atype<E_Array >(),atype<TransE_Array>() )   );  // a faire mais dur
1390       TheOperators->Add(".*",new opSum("*",atype<TransE_Array >(),atype<TransE_Array>() )   );  // a faire mais dur
1391       TheOperators->Add("./",new opSum("/",atype<TransE_Array >(),atype<E_Array>() )   );  // a faire mais dur
1392       TheOperators->Add("./",new opSum("/",atype<E_Array >(),atype<E_Array>() )   );  // a faire mais dur
1393       TheOperators->Add("./",new opSum("/",atype<E_Array >(),atype<TransE_Array>() )   );  // a faire mais dur
1394     // correct in sept. 2009
1395       TheOperators->Add("./",new opSum("/",atype<TransE_Array >(),atype<TransE_Array>() )   );  // a faire mais dur
1396 
1397 
1398      // il faut refechir  .....  FH
1399      // il faut definir le type d'un tableau bof, bof (atype<C_F0>())
1400      TheOperators->Add(">>",
1401        new OneBinaryOperator<Op_Read<bool>,OneBinaryOperatorMIWO >,
1402        new OneBinaryOperator<Op_Read<long>,OneBinaryOperatorMIWO >,
1403        new OneBinaryOperator<Op_Read<double>,OneBinaryOperatorMIWO >,
1404        new OneBinaryOperator<Op_Read<Complex>,OneBinaryOperatorMIWO >,
1405        new OneBinaryOperator<Op_ReadP<string>,OneBinaryOperatorMIWO >
1406 
1407        );
1408 
1409      TheOperators->Add("<<",
1410        new OneBinaryOperator<Print<bool> >,
1411        new OneBinaryOperator<Print<long> >,
1412        new OneBinaryOperator<Print<double> >,
1413        new OneBinaryOperator<Print<Complex> >,
1414        new OneBinaryOperator<PrintP<string*> >  //  FH string * mars 2006
1415        );
1416 
1417 
1418      TheRightOperators->Add("++",
1419        new OneOperator1<long,long*, E_F_F0<long,long*,false> >(&RIncremantation<long>));
1420      TheRightOperators->Add("--",
1421        new OneOperator1<long,long*, E_F_F0<long,long*,false> >(&RDecremantation<long>));
1422      TheOperators->Add("++",
1423        new OneOperator1<long,long*, E_F_F0<long,long*,false> >(&LIncremantation<long>));
1424      TheOperators->Add("--",
1425        new OneOperator1<long,long*, E_F_F0<long,long*,false> >(&LDecremantation<long>));
1426 //   init
1427      TheOperators->Add("<-",
1428        new OneOperator2<string**,string**,string*>(&set_copyp_new<string>),  //  FH string * mars 2006
1429        new OneOperator2_<double*,double*,double>(&set_copyp),  //
1430        new OneOperator2_<long*,long*,long>(&set_copyp),
1431        new OneOperator2_<bool*,bool*,bool>(&set_copyp), //  mars 2006
1432        new OneOperator2_<Complex*,Complex*,Complex>(&set_copy),
1433        new OneBinaryOperator<Op2_set_pstring<istream**,ifstream> >,  //  FH string * mars 2006
1434        new OneBinaryOperator<Op2_set_pstring<ostream**,ofstream> >,  //  FH string * mars 2006
1435        new OneTernaryOperator3<Op2_set_pstringiomode<ostream**,ofstream> >  ,    //  FH string * mars 2006
1436        new OneTernaryOperator3<Op2_set_pstringiomode<istream**,ifstream> >   //  FH string * april  2014
1437        );
1438 
1439      atype<istream* >()->AddCast( new E_F1_funcT<istream*,istream**>(UnRef<istream* >));
1440      atype<ostream* >()->AddCast( new E_F1_funcT<ostream*,ostream**>(UnRef<ostream* >));
1441 
1442      Add<ostream**>("<-","(", new OneUnaryOperator<Op1_new_pstring<ostream*,ofstream> >);  //  FH string * mars 2006
1443 
1444      Add<ostream**>("precision",".",new OneOperator1<ostream_precis,ostream**>(ostream_precision));
1445      Add<ostream*>("precision",".",new OneOperator1<ostream_precis,ostream*>(ostream_precision));
1446 
1447     // add FH jan 2010 ...
1448     Add<ostream**>("seekp",".",new OneOperator1<ostream_seekp,ostream**>(ff_oseekp));
1449     Add<ostream*>("seekp",".",new OneOperator1<ostream_seekp,ostream*>(ff_oseekp));
1450 
1451     Add<istream**>("seekg",".",new OneOperator1<istream_seekg,istream**>(ff_iseekg));
1452     Add<istream*>("seekg",".",new OneOperator1<istream_seekg,istream*>(ff_iseekg));
1453     Add<ostream**>("tellp",".",new OneOperator1<ostream_seekp,ostream**>(ff_oseekp));
1454     Add<ostream*>("tellp",".",new OneOperator1<ostream_seekp,ostream*>(ff_oseekp));
1455 
1456     Add<istream**>("tellg",".",new OneOperator1<istream_seekg,istream**>(ff_iseekg));
1457     Add<istream*>("tellg",".",new OneOperator1<istream_seekg,istream*>(ff_iseekg));
1458 
1459     Add<ostream_seekp>("(","",new OneOperator1<long,ostream_seekp>(fftellp),
1460 		       new OneOperator2<long,ostream_seekp,long>(ffseekp));
1461     Add<istream_seekg>("(","",new OneOperator1<long,istream_seekg>(fftellg),
1462 		       new OneOperator2<long,istream_seekg,long>(ffseekg));
1463     // end add  jan 2010 ..
1464     Add<ostream_precis>("(","",new OneOperator1<long,ostream_precis>(get_precis),
1465                                 new OneOperator2<long,ostream_precis,long>(set_precis));
1466 //  add v 1.41
1467      Add<istream**>("good",".",new OneOperator1<istream_good,istream**>(to_istream_good));
1468      Add<istream*>("good",".",new OneOperator1<istream_good,istream*>(to_istream_good));
1469      Add<istream*>("good",".",new OneOperator1<istream_good,istream*>(to_istream_good));
1470      Add<istream_good>("(","",new OneOperator1<long,istream_good>(get_good));
1471 
1472      Add<istream**>("eof",".",new OneOperator1<bool,istream**>(get_eof));
1473 // add v 4.5 jan 2020 FH.
1474         Add<istream**>("eatspace",".",new OneOperator1<bool,istream**>(eatspace));
1475        Add<istream**>("length",".",new OneOperator1<long,istream**>(filelength));
1476 // add v 2.8
1477      Add<ostream**>("scientific",".",new OneOperator1<ostream**,ostream**>(set_os<scientific>));
1478      Add<ostream**>("fixed",".",new OneOperator1<ostream**,ostream**>(set_os<fixed>));
1479      Add<ostream**>("showbase",".",new OneOperator1<ostream**,ostream**>(set_os<showbase>));
1480      Add<ostream**>("noshowbase",".",new OneOperator1<ostream**,ostream**>(set_os<noshowbase>));
1481      Add<ostream**>("showpos",".",new OneOperator1<ostream**,ostream**>(set_os<showpos>));
1482      Add<ostream**>("noshowpos",".",new OneOperator1<ostream**,ostream**>(set_os<noshowpos>));
1483      Add<ostream**>("default",".",new OneOperator1<ostream**,ostream**>(set_os<default1>));
1484      Add<ostream**>("flush",".",new OneOperator1<ostream**,ostream**>(set_os_flush));// ADD may 2010
1485 
1486      Add<ostream*>("scientific",".",new OneOperator1<ostream*,ostream*>(set_os1<scientific>));
1487      Add<ostream*>("fixed",".",new OneOperator1<ostream*,ostream*>(set_os1<fixed>));
1488      Add<ostream*>("showbase",".",new OneOperator1<ostream*,ostream*>(set_os1<showbase>));
1489      Add<ostream*>("noshowbase",".",new OneOperator1<ostream*,ostream*>(set_os1<noshowbase>));
1490      Add<ostream*>("showpos",".",new OneOperator1<ostream*,ostream*>(set_os1<showpos>));
1491      Add<ostream*>("noshowpos",".",new OneOperator1<ostream*,ostream*>(set_os1<noshowpos>));
1492      Add<ostream*>("default",".",new OneOperator1<ostream*,ostream*>(set_os1<default1>));
1493      Add<ostream*>("flush",".",new OneOperator1<ostream*,ostream*>(set_os_flush));// ADD may 2010
1494 
1495     Global.Add("getline","(",new OneOperator2<istream*,istream*,string **>(Getline));
1496 // add 2.16
1497      Global.Add("trace","(",new opFormal(atype<E_Array>(),formalMatTrace ));
1498      Global.Add("det","(",new opFormal(atype<E_Array>(),formalMatDet ));
1499 // end add
1500 
1501     // add 3.20
1502     Global.Add("Cofactor","(",new opFormal(atype<E_Array>(),formalMatCofactor ));
1503 
1504      TheOperators->Add("[]",new OneOperator_array );
1505      TheOperators->Add("[border]",new OneOperator_border );
1506 
1507      Global.Add("cos","(",new OneOperator1<double>(cos));
1508     Global.Add("square","(",new OneOperator1<long,long,E_F_F0<long,const long &> >(Square));// add FH Mai 2011
1509     Global.Add("square","(",new OneOperator1<double,double,E_F_F0<double,const double &> >(Square));
1510     Global.Add("square","(",new OneOperator1<Complex,Complex,E_F_F0<Complex,const Complex &> >(Square));// add FH Mai 2011
1511  //add for Olivier FH July 2014
1512     Global.Add("sqr","(",new OneOperator1<long,long,E_F_F0<long,const long &> >(Square));//
1513     Global.Add("sqr","(",new OneOperator1<double,double,E_F_F0<double,const double &> >(Square));
1514     Global.Add("sqr","(",new OneOperator1<Complex,Complex,E_F_F0<Complex,const Complex &> >(Square));//
1515 
1516      Global.Add("round","(",new OneOperator1<double>(round)); // add june 2007
1517      Global.Add("lround","(",new OneOperator1<long,double>(lround)); // add june 2007
1518      Global.Add("floor","(",new OneOperator1<double>(floor)); // add march 2006
1519      Global.Add("ceil","(",new OneOperator1<double>(ceil));  // add march 2006
1520     Global.Add("rint","(",new OneOperator1<double>(rint));  // add june 2006
1521      Global.Add("lrint","(",new OneOperator1<long,double>(lrint));  // add mars  2014
1522 
1523      Global.Add("sin","(",new OneOperator1<double>(sin));
1524      Global.Add("tan","(",new OneOperator1<double>(tan));
1525      Global.Add("atan","(",new OneOperator1<double>(atan));
1526      Global.Add("sinh","(",new OneOperator1<double>(sinh));
1527      Global.Add("cosh","(",new OneOperator1<double>(cosh));
1528      Global.Add("tanh","(",new OneOperator1<double>(tanh));
1529 
1530     Global.Add("atoi","(",new OneOperator1<long,string*>(atoi));// add march 2010
1531     Global.Add("atol","(",new OneOperator1<long,string*>(atoi));// add march 2010
1532     Global.Add("atof","(",new OneOperator1<double,string*>(atof));// add march 2010
1533 
1534     Global.Add("strtol","(",new OneOperator1<long,string*>(ffstrtol));// add march 2017
1535     Global.Add("strtol","(",new OneOperator2<long,string*,long>(ffstrtol));// add march 2017
1536     Global.Add("strtod","(",new OneOperator1<double,string*>(ffstrtod));// add march 2017
1537 
1538      Global.Add("atanh","(",new OneOperator1<double>(atanh));
1539      Global.Add("asin","(",new OneOperator1<double>(asin));
1540      Global.Add("acos","(",new OneOperator1<double>(acos));
1541      Global.Add("asinh","(",new OneOperator1<double>(asinh));
1542      Global.Add("acosh","(",new OneOperator1<double>(acosh));
1543 #ifdef HAVE_ERFC
1544      Global.Add("erf","(",new OneOperator1<double>(erf));
1545      Global.Add("erfc","(",new OneOperator1<double>(erfc));
1546 #endif
1547 #ifdef HAVE_TGAMMA
1548      Global.Add("tgamma","(",new OneOperator1<double>(tgamma));
1549      Global.Add("lgamma","(",new OneOperator1<double>(lgamma));
1550 #endif
1551      //  function de bessel j0, j1, jn, y0, y1, yn -- bessel functions of first and second kind
1552 #ifdef HAVE_JN
1553       Global.Add("j0","(",new OneOperator1<double>(j0));
1554       Global.Add("j1","(",new OneOperator1<double>(j1));
1555       Global.Add("jn","(",new OneOperator2<double,long,double>(myjn));
1556       Global.Add("y0","(",new OneOperator1<double>(y0));
1557       Global.Add("y1","(",new OneOperator1<double>(y1));
1558       Global.Add("yn","(",new OneOperator2<double,long,double>(myyn));
1559 #endif
1560      Global.Add("exp","(",new OneOperator1<double>(exp));
1561      Global.Add("log","(",new OneOperator1<double>(log));
1562      Global.Add("log10","(",new OneOperator1<double>(log10));
1563      Global.Add("pow","(",new OneOperator2<double,double>(pow));
1564 //     Global.Add("pow","(",new OneOperator2<double,double,long>(pow));
1565      Global.Add("max","(",new OneOperator2_<double,double>(Max<double> ));
1566      Global.Add("min","(",new OneOperator2_<double,double>(Min<double> ));
1567     Global.Add("diffpos","(",new OneOperator2_<double,double>(diffpos )); // jan 2018 FH
1568     Global.Add("invdiffpos","(",new OneOperator2_<double,double>(invdiffpos )); // jan 2018 FH
1569     Global.Add("diffnp","(",new OneOperator2_<double,double>(diffnp )); // jan 2018 FH
1570     Global.Add("invdiffnp","(",new OneOperator2_<double,double>(invdiffnp )); // jan 2018 FH
1571     Global.Add("invdiff","(",new OneOperator2_<double,double>(invdiff )); // jan 2018 FH
1572     Global.Add("invdiff","(",new OneOperator3_<double,double,double>(invdiff )); // jan 2018 FH
1573 
1574      Global.Add("max","(",new OneOperator2_<long,long>(Max));
1575      Global.Add("min","(",new OneOperator2_<long,long>(Min));
1576     Global.Add("max","(",new OneOperator3_<double,double>(Max<double> ));
1577     Global.Add("min","(",new OneOperator3_<double,double>(Min<double> ));
1578     Global.Add("max","(",new OneOperator3_<long,long>(Max));
1579     Global.Add("min","(",new OneOperator3_<long,long>(Min));
1580     Global.Add("max","(",new OneOperator4_<long,long>(Max));
1581     Global.Add("min","(",new OneOperator4_<long,long>(Min));
1582     Global.Add("max","(",new OneOperator4_<double,double>(Max));
1583     Global.Add("min","(",new OneOperator4_<double,double>(Min));
1584 
1585     Global.Add("atan2","(",new OneOperator2<double>(atan2));
1586     Global.Add("fmod","(",new OneOperator2<double>(fmod));// add sep 2017
1587     Global.Add("fdim","(",new OneOperator2<double>(fdim));// add sep 2017
1588     Global.Add("fmax","(",new OneOperator2<double>(fmax));// add sep 2017
1589     Global.Add("fmin","(",new OneOperator2<double>(fmin));// add sep 2017
1590 
1591     Global.Add("hypot","(",new OneOperator2<double>(hypot));// add Jan 2014
1592 
1593      Global.Add("atan","(",new OneOperator2<double>(atan2));
1594      Global.Add("sqrt","(",new OneOperator1<double>(sqrt,2));
1595      Global.Add("abs","(",new OneOperator1<double>(Abs));
1596      Global.Add("abs","(",new OneOperator1<long>(Abs));
1597      Global.Add("cos","(",new OneOperator1_<Complex>(cos));
1598      Global.Add("sin","(",new OneOperator1_<Complex>(sin));
1599      Global.Add("sinh","(",new OneOperator1_<Complex>(sinh));
1600      Global.Add("cosh","(",new OneOperator1_<Complex>(cosh));
1601      Global.Add("tanh","(",new OneOperator1_<Complex>(tanh));// Add June 2016 FH..
1602      Global.Add("log","(",new OneOperator1_<Complex>(log));
1603      Global.Add("tan","(",new OneOperator1_<Complex>(tan));
1604      Global.Add("exp","(",new OneOperator1_<Complex>(exp));
1605 
1606     Global.Add("pow","(",new OneBinaryOperator<Op2_pow<Complex,Complex,Complex> >);
1607                 //new OneOperator2_<Complex,Complex>(pow ));
1608      Global.Add("sqrt","(",new OneOperator1_<Complex>(sqrt,0));
1609      Global.Add("conj","(",new OneOperator1_<Complex>(conj,0));
1610      Global.Add("conj","(",new OneOperator1_<double>(RNM::conj,1));
1611      TheOperators->Add("\'",new OneOperator1_<Complex>(conj,0));
1612      TheOperators->Add("\'",new OneOperator1_<double>(RNM::conj,1));       //  add F.  Feb 2010  of conj of varf..
1613 
1614 
1615      Global.Add("imag","(",new OneOperator1_<double,Complex>(Imag));
1616      //  Big probleme  real is a type
1617      Add<double>("<--","(",new OneOperator1_<double,Complex>(Real));
1618 
1619      Global.Add("abs","(",new OneOperator1_<double,Complex>(abs));
1620 
1621      Global.Add("arg","(",new OneOperator1_<double,Complex>(arg));
1622      Global.Add("norm","(",new OneOperator1_<double,Complex>(norm));
1623      Global.Add("exit","(",new OneOperator1<long>(Exit));
1624      Global.Add("assert","(",new OneOperator1<bool>(Assert));
1625 
1626      Global.Add("clock","(",new OneOperator0<double>(CPUtime));
1627     Global.Add("time","(",new OneOperator0<double>(walltime));// add mars 2010 for Pichon.
1628     Global.Add("ltime","(",new OneOperator0<long>(fftime));// add mars 2014 ( the times unix fonction)
1629     Global.Add("storageused","(",new OneOperator0<long>(storageused));
1630     Global.Add("storagetotal","(",new OneOperator0<long>(storagetotal));
1631 
1632      Global.Add("dumptable","(",new OneOperator1<ostream*,ostream*>(dumptable));
1633      Global.Add("exec","(",new OneOperator1<long,string* >(exec));  //FH string * mars 2006
1634      Global.Add("system","(",new OneOperator1<long,string* >(exec));  //FH string fevr 2011
1635 
1636      Global.Add("polar","(",new OneOperator2_<Complex,double,double>(polar));
1637  // rand generator ---
1638   unsigned long init[4]={0x123, 0x234, 0x345, 0x456}, length=4;
1639   init_by_array(init, length);
1640 
1641   Global.Add("randint32","(",new OneOperator_0<long>(genrandint32));
1642   Global.Add("randint31","(",new OneOperator_0<long>(genrand_int31));
1643   Global.Add("randreal1","(",new OneOperator_0<double>(genrand_real1));
1644   Global.Add("randreal2","(",new OneOperator_0<double>(genrand_real2));
1645   Global.Add("randreal3","(",new OneOperator_0<double>(genrand_real3));
1646   Global.Add("randres53","(",new OneOperator_0<double>(genrand_res53));
1647   Global.Add("randinit","(",new OneOperator1<long>(genrandint));
1648 
1649   //  NaN and Inf
1650   Global.Add("ShowAlloc","(",new OneOperator1<long,string*>(ShowAlloc1));// debuging
1651   Global.Add("ShowAlloc","(",new OneOperator2<long,string*,long*>(ShowAlloc1));// debuging
1652   Global.Add("NaN","(",new OneOperator0<double>(NaN));
1653 
1654   Global.Add("NaN","(",new OneOperator1<double,string*   >(NaN));
1655   Global.Add("isNaN","(",new OneOperator1<long,double>(isNaN));
1656   Global.Add("copysign","(",new OneOperator2<double>(copysign));// Add jan 2018 FH
1657   Global.Add("sign","(",new OneOperator1<double>(sign));// Add jan 2018 FH
1658   Global.Add("sign","(",new OneOperator1<long>(sign));// Add jan 2018 FH
1659   Global.Add("signbit","(",new OneOperator1<bool,long>(ffsignbit));// Add jan 2018 FH
1660   Global.Add("signbit","(",new OneOperator1<bool,double>(ffsignbit));// Add jan 2018 FH
1661 
1662   Global.Add("isInf","(",new OneOperator1<long,double>(isInf));
1663   Global.Add("isNormal","(",new OneOperator1<long,double>(isNormal));
1664   Global.Add("chtmpdir","(",new OneOperator0<long>(ffapi::chtmpdir));
1665   Global.Add("projection","(",new OneOperator3_<double,double   >(projection));
1666   Global.Add("dist","(",new OneOperator2_<double,double>(dist));
1667   Global.Add("dist","(",new OneOperator3_<double,double>(dist));
1668   Global.Add("swap","(",new OneOperator2<bool,double*>(pswap));
1669   Global.Add("swap","(",new OneOperator2<bool,long*>(pswap));
1670   Global.Add("swap","(",new OneOperator2<bool,bool*>(pswap));
1671   Global.Add("swap","(",new OneOperator2<bool,Complex*>(pswap));
1672   Global.Add("swap","(",new OneOperator2<bool,string**>(pswap));
1673 
1674 
1675   atype<MyMapSS*>()->Add("[","",new OneOperator2_<string**,MyMapSS*,string*>(get_elements));
1676 
1677   atype<MyMapSS*>()->SetTypeLoop(atype<string**>(),atype<string**>());
1678 
1679 
1680   tables_of_identifier.push_back(&Global);
1681 
1682   TheOperators->Add("<<",new OneBinaryOperator<PrintP<MyMapSS*> >);
1683 
1684   TheOperators->Add("{}",new ForAllLoop<E_ForAllLoopMapSS >);
1685   // add setw feb 2015 FH
1686   Global.Add("setw","(",new OneOperator1<OP_setw,long>(defOP_setw));
1687   TheOperators->Add("<<", new OneBinaryOperator<Print<OP_setw> >);
1688 
1689 }
1690 
1691 
1692 
1693 
ClearMem()1694  void ClearMem()
1695  {
1696      size_t lg;
1697      ShowAlloc("ClearMem: begin" , lg);
1698      delete pZero;
1699      delete pOne;
1700      delete pminusOne;
1701 
1702      tables_of_identifier.clear();
1703      for (map<const string,basicForEachType *>::iterator i=map_type.begin();i!=map_type.end();++i)
1704         delete i->second;
1705 
1706      map_type.clear();
1707      map_type_of_map.clear();
1708      map_pair_of_type.clear();
1709      Global.clear();
1710      if(TheOperators)
1711        TheOperators->clear();
1712      if(TheRightOperators)
1713        TheRightOperators->clear();
1714 
1715      CodeAlloc::clear();
1716      ShowAlloc("ClearMem: end" , lg);
1717 
1718  }
1719 
1720 // <<addingInitFunct>>
1721 static addingInitFunct TheaddingInitFunct(-10000,Init_map_type);
1722 
code2(const basicAC_F0 & args) const1723 C_F0  opVI::code2(const basicAC_F0 &args) const
1724 {
1725     Expression p=args[1];
1726     if ( ! p->EvaluableWithOutStack() )
1727     {
1728         CompileError(" [...][p], The p must be a constant , sorry");
1729     }
1730     int pv = GetAny<long>((*p)(NullStack));
1731     bool ta =args[0].left()==atype<TransE_Array>();
1732     const TransE_Array * tea=0;
1733     const E_Array * ea=0;
1734     if( ta)  tea = dynamic_cast<const TransE_Array*>((Expression) args[0]);
1735     else ea = dynamic_cast<const E_Array*>((Expression) args[0]);
1736     assert( ea || tea );
1737     const E_Array & a=  ta ? *tea->v : *ea;
1738     if(tea){
1739         AC_F0  v  ;
1740         for (int i=0;i<a.size();++i)
1741         {
1742             const E_Array * li=  dynamic_cast<const E_Array *>(a[i].LeftValue());
1743             ffassert(li && (li->size() >pv));
1744 
1745             const C_F0 vi = TryConj( (*li)[pv]);
1746             if(i==0) v=vi;
1747             else v+= vi;
1748 
1749         }
1750 
1751         return C_F0(TheOperators,"[]",v);
1752 
1753     }
1754 
1755     if(!(pv >=0 && pv <a.size()))
1756     {
1757         cerr << "\n\nerror [ ... ][" << pv <<" ] " << " the  size of [ ...]  is "<< a.size() << endl;
1758         lgerror(" bound of  [ .., .. , ..][ . ] operation  ");
1759     }
1760 
1761     return (* a.v)[pv];
1762 }
1763 
code2(const basicAC_F0 & args) const1764 C_F0  opDot::code2(const basicAC_F0 &args) const
1765 {
1766     bool ta =args[0].left()==atype<TransE_Array>();
1767     bool tb = args[1].left()==atype<TransE_Array>();
1768     const TransE_Array * tea=0;
1769     const TransE_Array * teb=0;
1770     const E_Array * ea=0;
1771     const E_Array * eb=0;// E_F0
1772 	if( ta)  tea = dynamic_cast<const TransE_Array*>((Expression) args[0]);
1773     else ea = dynamic_cast<const E_Array*>((Expression) args[0]);
1774     if( tb)  teb = dynamic_cast<const TransE_Array*>((Expression) args[1]);
1775     else eb = dynamic_cast<const E_Array*>((Expression) args[1]);
1776     assert( ea || tea );
1777     assert( eb || teb );
1778     const E_Array & a=  ta ? *tea->v : *ea;
1779     const E_Array & b=  tb ? *teb->v : *eb;
1780     int ma =1;
1781     int mb =1;
1782     int na=a.size();
1783     int nb=b.size();
1784     if(na <1 && nb < 1) CompileError(" empty array  [ ...]'*[ ...  ]  ");
1785     bool mab= b[0].left()==atype<E_Array>();
1786     bool maa= a[0].left()==atype<E_Array>();
1787     if(maa) {
1788 	ma= a[0].LeftValue()->nbitem();
1789 	for (int i=1;i<na;i++)
1790 	    if( ma != (int) a[i].LeftValue()->nbitem())
1791 		CompileError(" first matrix with variable number of columm");
1792 
1793     }
1794     if(mab) {
1795 	mb= b[1].LeftValue()->nbitem();
1796 	for (int i=1;i<nb;i++)
1797 	    if( mb != (int) b[i].LeftValue()->nbitem())
1798 		CompileError(" second matrix with variable number of columm");
1799     }
1800     int na1=na,ma1=ma,nb1=nb,mb1=mb;
1801     if(ta) RNM::Exchange(na1,ma1);
1802     if(tb) RNM::Exchange(nb1,mb1);
1803 
1804     KNM<CC_F0> A(na1,ma1), B(nb1,mb1);
1805     if ( A.M() != B.N())
1806     {
1807 	cout << "   formal prod array or matrix : [ .. ] * [ .. ]   " << endl;
1808 	cout << " first  array :  matrix " << maa << " trans " << ta << " " << na << "x" << ma <<endl;
1809 	cout << " second array :  matrix " << mab << " trans " << tb << " " << nb << "x" << mb <<endl;
1810 	CompileError(" no same size  [ ...]'*[ ...  ] sorry ");
1811     }
1812 
1813     if(maa)
1814 	for (int i=0;i<na;++i)
1815 	{
1816 	    const E_Array * li=  dynamic_cast<const E_Array *>(a[i].LeftValue());
1817 	    ffassert(li);
1818 	    for (int j=0; j<ma;++j)
1819 		if(!ta)  A(i,j) = (*li)[j];
1820 		else     A(j,i) = TryConj((*li)[j]);
1821 	}
1822     else
1823 	for (int i=0;i<na;++i)
1824 	    if(!ta)  A(i,0) = a[i];
1825 	    else     A(0,i) = TryConj(a[i]);
1826 
1827     if(mab)
1828 	for (int i=0;i<nb;++i)
1829 	{
1830 	    const E_Array * li=  dynamic_cast<const E_Array *>(b[i].LeftValue());
1831 	    ffassert(li);
1832 	    for (int j=0; j<mb;++j)
1833 		if(!tb)  B(i,j) = (*li)[j];
1834 		else     B(j,i) = TryConj((*li)[j]);
1835 	}
1836     else
1837 	for (int i=0;i<nb;++i)
1838 	    if(!tb)  B(i,0) = b[i];
1839 	    else     B(0,i) = TryConj(b[i]);
1840 
1841     KNM<CC_F0> C(na1,mb1);
1842     CC_F0 s,abi;
1843     for (int i=0;i<na1;++i)
1844 	for (int j=0;j<mb1;++j)
1845 	{
1846 	    s= C_F0(TheOperators,"*",A(i,0),B(0,j));
1847 	    for (int k=1;k<ma1;++k) {
1848 		abi = C_F0(TheOperators,"*",A(i,k),B(k,j));
1849 		s = C_F0(TheOperators,"+",s,abi);}
1850 	    C(i,j)=s;
1851 	};
1852     if( na1==1 && mb1 ==1)
1853 	return C(0,0);
1854     else if ( mb1 ==1 ) // || (na1==1)) // correct du car ' on conj encore r . mars 2010
1855     {
1856 	AC_F0  v;
1857 	v=C(0,0);
1858 	int i0=na1!=1,j0=mb1!=1, nn= mb1*na1;
1859 	for (int i=1;i<nn;++i)
1860 	    v+=C(i0*i,j0*i);
1861 	C_F0  r(TheOperators,"[]",v);
1862 	if(mb1==1) return r;
1863 	else return C_F0(TheOperators,"\'",r);// Bug car on conj encore r . mars 2010
1864     }
1865     else
1866     {
1867 	AC_F0  v,cc;
1868 	v=C(0,0);
1869 	for (int i=0;i<na1;++i)
1870 	{  cc = C(i,0);
1871 	    for (int j=1;j<mb1;++j)
1872 		cc+= C(i,j);
1873 	    C_F0  vi(TheOperators,"[]",cc);
1874 	    if(i==0) v=vi;
1875 	    else v+= vi;
1876 	}
1877 	return C_F0(TheOperators,"[]",v);
1878     }
1879 
1880     cout << "   formal prod array or matrix : [ .. ] * [ .. ]   " << na << "x" << nb << endl;
1881     cout << "   formal prod array or matrix : [ .. ] * [ .. ]   " <<  endl;
1882     cout << " first  array :  matrix " << maa << " trans " << ta << " " << na << "x" << ma <<endl;
1883     cout << " second array :  matrix " << mab << " trans " << tb << " " << nb << "x" << mb <<endl;
1884     CompileError("  not implemented sorry ..... (FH) to do ???? ");
1885     return C_F0();
1886 
1887 }
code2(const basicAC_F0 & args) const1888 C_F0  opColumn::code2(const basicAC_F0 &args) const
1889 {
1890     bool ta =args[0].left()==atype<TransE_Array>();
1891     bool tb = args[1].left()==atype<TransE_Array>();
1892     const TransE_Array * tea=0;
1893     const TransE_Array * teb=0;
1894     const E_Array * ea=0;
1895     const E_Array * eb=0;// E_F0
1896     if( ta)  tea = dynamic_cast<const TransE_Array*>((Expression) args[0]);
1897     else ea = dynamic_cast<const E_Array*>((Expression) args[0]);
1898     if( tb)  teb = dynamic_cast<const TransE_Array*>((Expression) args[1]);
1899     else eb = dynamic_cast<const E_Array*>((Expression) args[1]);
1900 
1901     if( (eb || teb) && ( ea || tea ) )
1902     {
1903         const E_Array & a=  ta ? *tea->v : *ea;
1904         const E_Array & b=  tb ? *teb->v : *eb;
1905         int ma =1;
1906         int mb =1;
1907         int na=a.size();
1908         int nb=b.size();
1909         if(na <1 && nb < 1) CompileError(" empty array  [ ...]':[ ...  ]  ");
1910         bool mab= b[0].left()==atype<E_Array>();
1911         bool maa= a[0].left()==atype<E_Array>();
1912         if(maa) {
1913             ma= a[0].LeftValue()->nbitem();
1914             for (int i=1;i<na;i++)
1915                 if( ma != (int) a[i].LeftValue()->nbitem())
1916                     CompileError(" first matrix with variable number of columm");
1917 
1918         }
1919         if(mab) {
1920             mb= b[1].LeftValue()->nbitem();
1921             for (int i=1;i<nb;i++)
1922                 if( mb != (int) b[i].LeftValue()->nbitem())
1923                     CompileError(" second matrix with variable number of columm");
1924         }
1925         int na1=na,ma1=ma,nb1=nb,mb1=mb;
1926         if(ta) RNM::Exchange(na1,ma1);
1927         if(tb) RNM::Exchange(nb1,mb1);
1928 
1929         KNM<CC_F0> A(na1,ma1), B(nb1,mb1);
1930         if ( (na1!=nb1 ) || (ma1 != mb1) || (na1 * ma1 ==0)  )
1931         {
1932             cout << "\n   formal  array or matrix : [ .. ] : [ .. ]   " << endl;
1933             cout << " first  array :  matrix " << maa << " trans " << ta << " " << na << "x" << ma <<endl;
1934             cout << " second array :  matrix " << mab << " trans " << tb << " " << nb << "x" << mb <<endl;
1935             CompileError(" no same size  [ ...] : [ ...  ] sorry ");
1936         }
1937 
1938         if(maa)
1939             for (int i=0;i<na;++i)
1940             {
1941                 const E_Array * li=  dynamic_cast<const E_Array *>(a[i].LeftValue());
1942                 ffassert(li);
1943                 for (int j=0; j<ma;++j)
1944                     if(!ta)  A(i,j) = (*li)[j];
1945                     else     A(j,i) = TryConj((*li)[j]);
1946             }
1947         else
1948             for (int i=0;i<na;++i)
1949                 if(!ta)  A(i,0) = a[i];
1950                 else     A(0,i) = TryConj(a[i]);
1951 
1952         if(mab)
1953             for (int i=0;i<nb;++i)
1954             {
1955                 const E_Array * li=  dynamic_cast<const E_Array *>(b[i].LeftValue());
1956                 ffassert(li);
1957                 for (int j=0; j<mb;++j)
1958                     if(!tb)  B(i,j) = (*li)[j];
1959                     else     B(j,i) = TryConj((*li)[j]);
1960             }
1961         else
1962             for (int i=0;i<nb;++i)
1963                 if(!tb)  B(i,0) = b[i];
1964                 else     B(0,i) = TryConj(b[i]);
1965 
1966         CC_F0 s,aibi;
1967 
1968         for (int i=0;i<na1;++i)
1969             for (int j=0;j<ma1;++j)
1970             {
1971                 aibi = C_F0(TheOperators,"*",A(i,j),B(i,j));
1972                 if( (i==0) && (j==0))
1973                     s = aibi;
1974                 else
1975                     s = C_F0(TheOperators,"+",s,aibi);
1976             };
1977         return s;
1978     }
1979     else if ( ea || tea )
1980     { // modif 2 /08/  2013  FH .. bug in [ a0,a1,... ]'*b
1981         //  [a0,a1,... ]*b  or [ a0,a1,... ]'*b  => [ a0*b',a1*b',
1982         const E_Array & a=  ta ? *tea->v : *ea;
1983         int na=a.size();
1984         AC_F0  v;
1985         v = 0; // empty
1986         C_F0 b =ta ? TryConj(args[1]) :args[1];
1987         for (int i=0;i<na;++i)
1988         v += C_F0(TheOperators,"*",a[i],b)  ;
1989         return ta ? C_F0(TheOperators,"\'",C_F0(TheOperators,"[]",v)) :   C_F0(TheOperators,"[]",v);
1990 
1991     }
1992     else if(eb || teb)
1993     {  // modif 2 /08/  2013  FH .. bug in a*[ b0,b1,... ]'
1994         const E_Array & b=  tb ? *teb->v : *eb;
1995         int nb=b.size();
1996         C_F0 a =tb ? TryConj(args[0]) :args[0];
1997         AC_F0  v;
1998         v = 0; // empty
1999         for (int i=0;i<nb;++i)
2000             v += C_F0(TheOperators,"*",a,b[i]) ;
2001         return tb ? C_F0(TheOperators,"\'",C_F0(TheOperators,"[]",v)) :   C_F0(TheOperators,"[]",v);
2002 
2003     }
2004     else ffassert(0);
2005     return C_F0();
2006 }
2007 
2008 
code2(const basicAC_F0 & args) const2009 C_F0  opSum::code2(const basicAC_F0 &args) const
2010 {
2011 
2012     bool ta =args[0].left()==atype<TransE_Array>();
2013     bool tb = args[1].left()==atype<TransE_Array>();
2014     const TransE_Array * tea=0;
2015     const TransE_Array * teb=0;
2016     const E_Array * ea=0;
2017     const E_Array * eb=0;// E_F0
2018     if( ta)  tea = dynamic_cast<const TransE_Array*>((Expression) args[0]);
2019     else ea = dynamic_cast<const E_Array*>((Expression) args[0]);
2020     if( tb)  teb = dynamic_cast<const TransE_Array*>((Expression) args[1]);
2021     else eb = dynamic_cast<const E_Array*>((Expression) args[1]);
2022     assert( ea || tea );
2023     assert( eb || teb );
2024     const E_Array & a=  ta ? *tea->v : *ea;
2025     const E_Array & b=  tb ? *teb->v : *eb;
2026     int na=a.size();
2027     int nb=b.size();
2028     if(na != nb) CompileError(" formal   [ [...] [] ] : [ [..], [..] , ... ]  ");
2029 
2030 
2031     AC_F0  v;
2032     v = 0; // empty
2033 	for (int i=0;i<na;++i)
2034 	    v += C_F0(TheOperators,op,ta ? TryConj(a[i]) : a[i],tb ? TryConj(b[i]): b[i]) ;
2035 	return C_F0(TheOperators,"[]",v);
2036 
2037 }
2038 //  to be sure new and delele be in see dll for windows
newstring()2039 string  *newstring(){string * p=new string();
2040     if(verbosity>999999) cout << p << "=newstring() " <<endl;;
2041       return p ;
2042 }
newstring(const string & c)2043 string  *newstring(const string & c){
2044     string * p=new string(c);
2045     if(verbosity>999999) cout <<  p << "=newstring((string) "<< c << ") \n";
2046    return p;}
newstring(const char * c)2047 string  *newstring(const char * c){
2048      string * p=new string(c);
2049     if(verbosity>999999) cout << p << "=newstring((char*)  "<< c << " ) \n";
2050     return p;}
freestring(const string * c)2051 void   freestring(const string * c){
2052     if(verbosity>999999) cout << c << "freestring(  "<< *c <<") \n";
2053     delete c;}
2054