1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __INTERPKERNELFUNCTION_HXX__
22 #define __INTERPKERNELFUNCTION_HXX__
24 #include "INTERPKERNELDefines.hxx"
25 #include "InterpKernelException.hxx"
29 namespace INTERP_KERNEL
34 class INTERPKERNEL_EXPORT FunctionsFactory
37 static Function *buildFuncFromString(const char *type, int nbOfParams);
38 static Function *buildUnaryFuncFromString(const char *type);
39 //static Function *buildUnaryFuncFromString(char type);
40 static Function *buildBinaryFuncFromString(const char *type);
41 static Function *buildBinaryFuncFromString(char type);
42 static Function *buildTernaryFuncFromString(const char *type);
45 class INTERPKERNEL_EXPORT Function
49 virtual int getNbInputParams() const = 0;
50 virtual void operate(std::vector<Value *>& stck) const = 0;
51 virtual void operateX86(std::vector<std::string>& asmb) const = 0;
52 virtual void operateStackOfDouble(std::vector<double>& stck) const = 0;
53 virtual void operateStackOfDoubleSafe(std::vector<double>& stck) const { operateStackOfDouble(stck); }
54 virtual const char *getRepr() const = 0;
55 virtual bool isACall() const = 0;
56 virtual Function *deepCopy() const = 0;
59 class INTERPKERNEL_EXPORT UnaryFunction : public Function
62 int getNbInputParams() const;
65 class INTERPKERNEL_EXPORT IdentityFunction : public UnaryFunction
69 void operate(std::vector<Value *>& stck) const;
70 void operateX86(std::vector<std::string>& asmb) const;
71 void operateStackOfDouble(std::vector<double>& stck) const;
72 const char *getRepr() const;
74 IdentityFunction *deepCopy() const { return new IdentityFunction; }
76 static const char REPR[];
79 class INTERPKERNEL_EXPORT PositiveFunction : public UnaryFunction
83 void operate(std::vector<Value *>& stck) const;
84 void operateX86(std::vector<std::string>& asmb) const;
85 void operateStackOfDouble(std::vector<double>& stck) const;
86 const char *getRepr() const;
88 PositiveFunction *deepCopy() const { return new PositiveFunction; }
90 static const char REPR[];
93 class INTERPKERNEL_EXPORT NegateFunction : public UnaryFunction
97 void operate(std::vector<Value *>& stck) const;
98 void operateX86(std::vector<std::string>& asmb) const;
99 void operateStackOfDouble(std::vector<double>& stck) const;
100 const char *getRepr() const;
101 bool isACall() const;
102 NegateFunction *deepCopy() const { return new NegateFunction; }
104 static const char REPR[];
107 class INTERPKERNEL_EXPORT CosFunction : public UnaryFunction
111 void operate(std::vector<Value *>& stck) const;
112 void operateX86(std::vector<std::string>& asmb) const;
113 void operateStackOfDouble(std::vector<double>& stck) const;
114 const char *getRepr() const;
115 bool isACall() const;
116 CosFunction *deepCopy() const { return new CosFunction; }
118 static const char REPR[];
121 class INTERPKERNEL_EXPORT SinFunction : public UnaryFunction
125 void operate(std::vector<Value *>& stck) const;
126 void operateX86(std::vector<std::string>& asmb) const;
127 void operateStackOfDouble(std::vector<double>& stck) const;
128 const char *getRepr() const;
129 bool isACall() const;
130 SinFunction *deepCopy() const { return new SinFunction; }
132 static const char REPR[];
135 class INTERPKERNEL_EXPORT TanFunction : public UnaryFunction
139 void operate(std::vector<Value *>& stck) const;
140 void operateX86(std::vector<std::string>& asmb) const;
141 void operateStackOfDouble(std::vector<double>& stck) const;
142 const char *getRepr() const;
143 bool isACall() const;
144 TanFunction *deepCopy() const { return new TanFunction; }
146 static const char REPR[];
149 class INTERPKERNEL_EXPORT ACosFunction : public UnaryFunction
153 void operate(std::vector<Value *>& stck) const;
154 void operateX86(std::vector<std::string>& asmb) const;
155 void operateStackOfDouble(std::vector<double>& stck) const;
156 void operateStackOfDoubleSafe(std::vector<double>& stck) const;
157 const char *getRepr() const;
158 bool isACall() const;
159 ACosFunction *deepCopy() const { return new ACosFunction; }
161 static const char REPR[];
164 class INTERPKERNEL_EXPORT ASinFunction : public UnaryFunction
168 void operate(std::vector<Value *>& stck) const;
169 void operateX86(std::vector<std::string>& asmb) const;
170 void operateStackOfDouble(std::vector<double>& stck) const;
171 void operateStackOfDoubleSafe(std::vector<double>& stck) const;
172 const char *getRepr() const;
173 bool isACall() const;
174 ASinFunction *deepCopy() const { return new ASinFunction; }
176 static const char REPR[];
179 class INTERPKERNEL_EXPORT ATanFunction : public UnaryFunction
183 void operate(std::vector<Value *>& stck) const;
184 void operateX86(std::vector<std::string>& asmb) const;
185 void operateStackOfDouble(std::vector<double>& stck) const;
186 const char *getRepr() const;
187 bool isACall() const;
188 ATanFunction *deepCopy() const { return new ATanFunction; }
190 static const char REPR[];
193 class INTERPKERNEL_EXPORT CoshFunction : public UnaryFunction
197 void operate(std::vector<Value *>& stck) const;
198 void operateX86(std::vector<std::string>& asmb) const;
199 void operateStackOfDouble(std::vector<double>& stck) const;
200 const char *getRepr() const;
201 bool isACall() const;
202 CoshFunction *deepCopy() const { return new CoshFunction; }
204 static const char REPR[];
207 class INTERPKERNEL_EXPORT SinhFunction : public UnaryFunction
211 void operate(std::vector<Value *>& stck) const;
212 void operateX86(std::vector<std::string>& asmb) const;
213 void operateStackOfDouble(std::vector<double>& stck) const;
214 const char *getRepr() const;
215 bool isACall() const;
216 SinhFunction *deepCopy() const { return new SinhFunction; }
218 static const char REPR[];
221 class INTERPKERNEL_EXPORT TanhFunction : public UnaryFunction
225 void operate(std::vector<Value *>& stck) const;
226 void operateX86(std::vector<std::string>& asmb) const;
227 void operateStackOfDouble(std::vector<double>& stck) const;
228 const char *getRepr() const;
229 bool isACall() const;
230 TanhFunction *deepCopy() const { return new TanhFunction; }
232 static const char REPR[];
235 class INTERPKERNEL_EXPORT SqrtFunction : public UnaryFunction
239 void operateX86(std::vector<std::string>& asmb) const;
240 void operate(std::vector<Value *>& stck) const;
241 void operateStackOfDouble(std::vector<double>& stck) const;
242 void operateStackOfDoubleSafe(std::vector<double>& stck) const;
243 const char *getRepr() const;
244 bool isACall() const;
245 SqrtFunction *deepCopy() const { return new SqrtFunction; }
247 static const char REPR[];
250 class INTERPKERNEL_EXPORT AbsFunction : public UnaryFunction
254 void operate(std::vector<Value *>& stck) const;
255 void operateX86(std::vector<std::string>& asmb) const;
256 void operateStackOfDouble(std::vector<double>& stck) const;
257 const char *getRepr() const;
258 bool isACall() const;
259 AbsFunction *deepCopy() const { return new AbsFunction; }
261 static const char REPR[];
264 class INTERPKERNEL_EXPORT ExpFunction : public UnaryFunction
268 void operate(std::vector<Value *>& stck) const;
269 void operateX86(std::vector<std::string>& asmb) const;
270 void operateStackOfDouble(std::vector<double>& stck) const;
271 const char *getRepr() const;
272 bool isACall() const;
273 ExpFunction *deepCopy() const { return new ExpFunction; }
275 static const char REPR[];
278 class INTERPKERNEL_EXPORT LnFunction : public UnaryFunction
282 void operate(std::vector<Value *>& stck) const;
283 void operateX86(std::vector<std::string>& asmb) const;
284 void operateStackOfDouble(std::vector<double>& stck) const;
285 void operateStackOfDoubleSafe(std::vector<double>& stck) const;
286 const char *getRepr() const;
287 bool isACall() const;
288 LnFunction *deepCopy() const { return new LnFunction; }
290 static const char REPR[];
293 class INTERPKERNEL_EXPORT LogFunction : public UnaryFunction
297 void operate(std::vector<Value *>& stck) const;
298 void operateX86(std::vector<std::string>& asmb) const;
299 void operateStackOfDouble(std::vector<double>& stck) const;
300 void operateStackOfDoubleSafe(std::vector<double>& stck) const;
301 const char *getRepr() const;
302 bool isACall() const;
303 LogFunction *deepCopy() const { return new LogFunction; }
305 static const char REPR[];
308 class INTERPKERNEL_EXPORT Log10Function : public UnaryFunction
312 void operate(std::vector<Value *>& stck) const;
313 void operateX86(std::vector<std::string>& asmb) const;
314 void operateStackOfDouble(std::vector<double>& stck) const;
315 void operateStackOfDoubleSafe(std::vector<double>& stck) const;
316 const char *getRepr() const;
317 bool isACall() const;
318 Log10Function *deepCopy() const { return new Log10Function; }
320 static const char REPR[];
323 class INTERPKERNEL_EXPORT BinaryFunction : public Function
326 int getNbInputParams() const;
329 class PlusFunction : public BinaryFunction
333 void operate(std::vector<Value *>& stck) const;
334 void operateX86(std::vector<std::string>& asmb) const;
335 void operateStackOfDouble(std::vector<double>& stck) const;
336 const char *getRepr() const;
337 bool isACall() const;
338 PlusFunction *deepCopy() const { return new PlusFunction; }
340 static const char REPR[];
343 class INTERPKERNEL_EXPORT MinusFunction : public BinaryFunction
347 void operate(std::vector<Value *>& stck) const;
348 void operateX86(std::vector<std::string>& asmb) const;
349 void operateStackOfDouble(std::vector<double>& stck) const;
350 const char *getRepr() const;
351 bool isACall() const;
352 MinusFunction *deepCopy() const { return new MinusFunction; }
354 static const char REPR[];
357 class INTERPKERNEL_EXPORT MultFunction : public BinaryFunction
361 void operate(std::vector<Value *>& stck) const;
362 void operateX86(std::vector<std::string>& asmb) const;
363 void operateStackOfDouble(std::vector<double>& stck) const;
364 const char *getRepr() const;
365 bool isACall() const;
366 MultFunction *deepCopy() const { return new MultFunction; }
368 static const char REPR[];
371 class INTERPKERNEL_EXPORT DivFunction : public BinaryFunction
375 void operate(std::vector<Value *>& stck) const;
376 void operateX86(std::vector<std::string>& asmb) const;
377 void operateStackOfDouble(std::vector<double>& stck) const;
378 void operateStackOfDoubleSafe(std::vector<double>& stck) const;
379 const char *getRepr() const;
380 bool isACall() const;
381 DivFunction *deepCopy() const { return new DivFunction; }
383 static const char REPR[];
386 class INTERPKERNEL_EXPORT PowFunction : public BinaryFunction
390 void operate(std::vector<Value *>& stck) const;
391 void operateX86(std::vector<std::string>& asmb) const;
392 void operateStackOfDouble(std::vector<double>& stck) const;
393 void operateStackOfDoubleSafe(std::vector<double>& stck) const;
394 const char *getRepr() const;
395 bool isACall() const;
396 PowFunction *deepCopy() const { return new PowFunction; }
398 static const char REPR[];
401 class INTERPKERNEL_EXPORT MaxFunction : public BinaryFunction
405 void operate(std::vector<Value *>& stck) const;
406 void operateX86(std::vector<std::string>& asmb) const;
407 void operateStackOfDouble(std::vector<double>& stck) const;
408 const char *getRepr() const;
409 bool isACall() const;
410 MaxFunction *deepCopy() const { return new MaxFunction; }
412 static const char REPR[];
415 class INTERPKERNEL_EXPORT MinFunction : public BinaryFunction
419 void operate(std::vector<Value *>& stck) const;
420 void operateX86(std::vector<std::string>& asmb) const;
421 void operateStackOfDouble(std::vector<double>& stck) const;
422 const char *getRepr() const;
423 bool isACall() const;
424 MinFunction *deepCopy() const { return new MinFunction; }
426 static const char REPR[];
429 class INTERPKERNEL_EXPORT GreaterThanFunction : public BinaryFunction
432 ~GreaterThanFunction();
433 void operate(std::vector<Value *>& stck) const;
434 void operateX86(std::vector<std::string>& asmb) const;
435 void operateStackOfDouble(std::vector<double>& stck) const;
436 const char *getRepr() const;
437 bool isACall() const;
438 GreaterThanFunction *deepCopy() const { return new GreaterThanFunction; }
440 static const char REPR[];
443 class INTERPKERNEL_EXPORT LowerThanFunction : public BinaryFunction
446 ~LowerThanFunction();
447 void operate(std::vector<Value *>& stck) const;
448 void operateX86(std::vector<std::string>& asmb) const;
449 void operateStackOfDouble(std::vector<double>& stck) const;
450 const char *getRepr() const;
451 bool isACall() const;
452 LowerThanFunction *deepCopy() const { return new LowerThanFunction; }
454 static const char REPR[];
457 class INTERPKERNEL_EXPORT TernaryFunction : public Function
460 int getNbInputParams() const;
463 class INTERPKERNEL_EXPORT IfFunction : public TernaryFunction
467 void operate(std::vector<Value *>& stck) const;
468 void operateX86(std::vector<std::string>& asmb) const;
469 void operateStackOfDouble(std::vector<double>& stck) const;
470 void operateStackOfDoubleSafe(std::vector<double>& stck) const;
471 const char *getRepr() const;
472 bool isACall() const;
473 IfFunction *deepCopy() const { return new IfFunction; }
475 static const char REPR[];