-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "InterpKernelValue.hxx"
#include <cmath>
+#include <limits>
using namespace INTERP_KERNEL;
const char IfFunction::REPR[]="if";
-Function *FunctionsFactory::buildFuncFromString(const char *type, int nbOfParams) throw(INTERP_KERNEL::Exception)
+Function *FunctionsFactory::buildFuncFromString(const char *type, int nbOfParams)
{
switch(nbOfParams)
{
}
}
-Function *FunctionsFactory::buildUnaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception)
+Function *FunctionsFactory::buildUnaryFuncFromString(const char *type)
{
std::string tmp(type);
if(tmp.empty())
throw INTERP_KERNEL::Exception(msg.c_str());
}
-Function *FunctionsFactory::buildBinaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception)
+Function *FunctionsFactory::buildBinaryFuncFromString(const char *type)
{
std::string tmp(type);
if(tmp==PositiveFunction::REPR)
throw INTERP_KERNEL::Exception(msg.c_str());
}
-Function *FunctionsFactory::buildTernaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception)
+Function *FunctionsFactory::buildTernaryFuncFromString(const char *type)
{
std::string tmp(type);
if(tmp==IfFunction::REPR)
throw INTERP_KERNEL::Exception(msg.c_str());
}
-Function *FunctionsFactory::buildBinaryFuncFromString(char type) throw(INTERP_KERNEL::Exception)
+Function *FunctionsFactory::buildBinaryFuncFromString(char type)
{
char tmp[2]; tmp[0]=type; tmp[1]='\0';
return buildBinaryFuncFromString(tmp);
{
}
-void IdentityFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void IdentityFunction::operate(std::vector<Value *>& stck) const
{
}
-void IdentityFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void IdentityFunction::operateX86(std::vector<std::string>& asmb) const
+{
+}
+
+void IdentityFunction::operateStackOfDouble(std::vector<double>& stck) const
{
}
return 1;
}
-void PositiveFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void PositiveFunction::operate(std::vector<Value *>& stck) const
{
}
-void PositiveFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void PositiveFunction::operateX86(std::vector<std::string>& asmb) const
+{
+}
+
+void PositiveFunction::operateStackOfDouble(std::vector<double>& stck) const
{
}
{
}
-void NegateFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void NegateFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->negate();
}
-void NegateFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void NegateFunction::operateX86(std::vector<std::string>& asmb) const
{
asmb.push_back("fchs");
}
+void NegateFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=-v;
+}
+
const char *NegateFunction::getRepr() const
{
return REPR;
{
}
-void CosFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void CosFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->cos();
}
-void CosFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void CosFunction::operateX86(std::vector<std::string>& asmb) const
{
asmb.push_back("fcos");
}
+void CosFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=cos(v);
+}
+
const char *CosFunction::getRepr() const
{
return REPR;
{
}
-void SinFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void SinFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->sin();
}
-void SinFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void SinFunction::operateX86(std::vector<std::string>& asmb) const
{
asmb.push_back("fsin");
}
+void SinFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=sin(v);
+}
+
const char *SinFunction::getRepr() const
{
return REPR;
{
}
-void TanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void TanFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->tan();
}
-void TanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void TanFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void TanFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=tan(v);
+}
+
const char *TanFunction::getRepr() const
{
return REPR;
{
}
-void ACosFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void ACosFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->acos();
}
-void ACosFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void ACosFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void ACosFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=acos(v);
+}
+
+void ACosFunction::operateStackOfDoubleSafe(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ if(fabs(v)>1.)
+ throw INTERP_KERNEL::Exception("acos on a value which absolute is > 1 !");
+ stck.back()=acos(v);
+}
+
const char *ACosFunction::getRepr() const
{
return REPR;
{
}
-void ASinFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void ASinFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->asin();
}
-void ASinFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void ASinFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void ASinFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=asin(v);
+}
+
+void ASinFunction::operateStackOfDoubleSafe(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ if(fabs(v)>1.)
+ throw INTERP_KERNEL::Exception("asin on a value which absolute is > 1 !");
+ stck.back()=asin(v);
+}
+
const char *ASinFunction::getRepr() const
{
return REPR;
{
}
-void ATanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void ATanFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->atan();
}
-void ATanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void ATanFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void ATanFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=atan(v);
+}
+
const char *ATanFunction::getRepr() const
{
return REPR;
{
}
-void CoshFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void CoshFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->cosh();
}
-void CoshFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void CoshFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void CoshFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=cosh(v);
+}
+
const char *CoshFunction::getRepr() const
{
return REPR;
{
}
-void SinhFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void SinhFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->sinh();
}
-void SinhFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void SinhFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void SinhFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=sinh(v);
+}
+
const char *SinhFunction::getRepr() const
{
return REPR;
{
}
-void TanhFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void TanhFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->tanh();
}
-void TanhFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void TanhFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void TanhFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=tanh(v);
+}
+
const char *TanhFunction::getRepr() const
{
return REPR;
{
}
-void SqrtFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void SqrtFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->sqrt();
}
-void SqrtFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void SqrtFunction::operateX86(std::vector<std::string>& asmb) const
{
asmb.push_back("fsqrt");
}
+void SqrtFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=sqrt(v);
+}
+
+void SqrtFunction::operateStackOfDoubleSafe(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ if(v<0.)
+ throw INTERP_KERNEL::Exception("sqrt on a value < 0. !");
+ stck.back()=sqrt(v);
+}
+
const char *SqrtFunction::getRepr() const
{
return REPR;
{
}
-void AbsFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void AbsFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->abs();
}
-void AbsFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void AbsFunction::operateX86(std::vector<std::string>& asmb) const
{
asmb.push_back("fabs");
}
+void AbsFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=fabs(v);
+}
+
const char *AbsFunction::getRepr() const
{
return REPR;
return false;
}
-void ExpFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void ExpFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->exp();
}
-void ExpFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void ExpFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void ExpFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=std::exp(v);
+}
+
const char *ExpFunction::getRepr() const
{
return REPR;
{
}
-void LnFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void LnFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->ln();
}
-void LnFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void LnFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void LnFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=std::log(v);
+}
+
+void LnFunction::operateStackOfDoubleSafe(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ if(v<0.)
+ throw INTERP_KERNEL::Exception("ln on a value < 0. !");
+ stck.back()=std::log(v);
+}
+
const char *LnFunction::getRepr() const
{
return REPR;
{
}
-void LogFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void LogFunction::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->ln();
}
-void LogFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void LogFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly for log Not implemented yet !");
}
+void LogFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=std::log(v);
+}
+
+void LogFunction::operateStackOfDoubleSafe(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ if(v<0.)
+ throw INTERP_KERNEL::Exception("log on a value < 0. !");
+ stck.back()=std::log(v);
+}
+
const char *LogFunction::getRepr() const
{
return REPR;
{
}
-void Log10Function::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void Log10Function::operate(std::vector<Value *>& stck) const
{
- Value *val=stack.back();
+ Value *val=stck.back();
val->log10();
}
-void Log10Function::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void Log10Function::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly for log Not implemented yet !");
}
+void Log10Function::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ stck.back()=std::log10(v);
+}
+
+void Log10Function::operateStackOfDoubleSafe(std::vector<double>& stck) const
+{
+ double v(stck.back());
+ if(v<0.)
+ throw INTERP_KERNEL::Exception("log10 on a value < 0. !");
+ stck.back()=std::log10(v);
+}
+
const char *Log10Function::getRepr() const
{
return REPR;
{
}
-void PlusFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void PlusFunction::operate(std::vector<Value *>& stck) const
{
- Value *val1=stack.back();
- stack.pop_back();
- Value *& val2=stack.back();
+ Value *val1=stck.back();
+ stck.pop_back();
+ Value *& val2=stck.back();
Value *val3;
try
{
val2=val3;
}
-void PlusFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void PlusFunction::operateX86(std::vector<std::string>& asmb) const
{
asmb.push_back("faddp st1");
}
+void PlusFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ stck.back()=a+stck.back();
+}
+
const char *PlusFunction::getRepr() const
{
return REPR;
{
}
-void MinusFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void MinusFunction::operate(std::vector<Value *>& stck) const
{
- Value *val1=stack.back();
- stack.pop_back();
- Value *& val2=stack.back();
+ Value *val1=stck.back();
+ stck.pop_back();
+ Value *& val2=stck.back();
Value *val3;
try
{
val2=val3;
}
-void MinusFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void MinusFunction::operateX86(std::vector<std::string>& asmb) const
{
asmb.push_back("fsubp st1");
}
+void MinusFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ stck.back()=a-stck.back();
+}
+
const char *MinusFunction::getRepr() const
{
return REPR;
{
}
-void MultFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void MultFunction::operate(std::vector<Value *>& stck) const
{
- Value *val1=stack.back();
- stack.pop_back();
- Value *& val2=stack.back();
+ Value *val1=stck.back();
+ stck.pop_back();
+ Value *& val2=stck.back();
Value *val3=val1->mult(val2);
delete val1;
delete val2;
val2=val3;
}
-void MultFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void MultFunction::operateX86(std::vector<std::string>& asmb) const
{
asmb.push_back("fmulp st1");
}
+void MultFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ stck.back()=a*stck.back();
+}
+
const char *MultFunction::getRepr() const
{
return REPR;
{
}
-void DivFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void DivFunction::operate(std::vector<Value *>& stck) const
{
- Value *val1=stack.back();
- stack.pop_back();
- Value *& val2=stack.back();
+ Value *val1=stck.back();
+ stck.pop_back();
+ Value *& val2=stck.back();
Value *val3;
try
{
val2=val3;
}
-void DivFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void DivFunction::operateX86(std::vector<std::string>& asmb) const
{
asmb.push_back("fdivp st1");
}
+void DivFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ stck.back()=a/stck.back();
+}
+
+void DivFunction::operateStackOfDoubleSafe(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ if(stck.back()==0.)
+ throw INTERP_KERNEL::Exception("division by 0. !");
+ stck.back()=a/stck.back();
+}
+
const char *DivFunction::getRepr() const
{
return REPR;
{
}
-void PowFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void PowFunction::operate(std::vector<Value *>& stck) const
{
- Value *val1=stack.back();
- stack.pop_back();
- Value *& val2=stack.back();
+ Value *val1=stck.back();
+ stck.pop_back();
+ Value *& val2=stck.back();
Value *val3;
try
{
val2=val3;
}
-void PowFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void PowFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void PowFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ stck.back()=std::pow(a,stck.back());
+}
+
+void PowFunction::operateStackOfDoubleSafe(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ double b(stck.back());
+ if(a<0.)
+ throw INTERP_KERNEL::Exception("pow with val < 0. !");
+ stck.back()=std::pow(a,b);
+}
+
const char *PowFunction::getRepr() const
{
return REPR;
{
}
-void MaxFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void MaxFunction::operate(std::vector<Value *>& stck) const
{
- Value *val1=stack.back();
- stack.pop_back();
- Value *& val2=stack.back();
+ Value *val1=stck.back();
+ stck.pop_back();
+ Value *& val2=stck.back();
Value *val3;
try
{
val2=val3;
}
-void MaxFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void MaxFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void MaxFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ stck.back()=std::max(stck.back(),a);
+}
+
const char *MaxFunction::getRepr() const
{
return REPR;
{
}
-void MinFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void MinFunction::operate(std::vector<Value *>& stck) const
{
- Value *val1=stack.back();
- stack.pop_back();
- Value *& val2=stack.back();
+ Value *val1=stck.back();
+ stck.pop_back();
+ Value *& val2=stck.back();
Value *val3;
try
{
val2=val3;
}
-void MinFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void MinFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void MinFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ stck.back()=std::min(stck.back(),a);
+}
+
const char *MinFunction::getRepr() const
{
return REPR;
{
}
-void GreaterThanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void GreaterThanFunction::operate(std::vector<Value *>& stck) const
{
- Value *val1=stack.back();
- stack.pop_back();
- Value *& val2=stack.back();
+ Value *val1=stck.back();
+ stck.pop_back();
+ Value *& val2=stck.back();
Value *val3;
try
{
val2=val3;
}
-void GreaterThanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void GreaterThanFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void GreaterThanFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ double b(stck.back());
+ stck.back()=a>b?std::numeric_limits<double>::max():-std::numeric_limits<double>::max();
+}
+
const char *GreaterThanFunction::getRepr() const
{
return REPR;
{
}
-void LowerThanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void LowerThanFunction::operate(std::vector<Value *>& stck) const
{
- Value *val1=stack.back();
- stack.pop_back();
- Value *& val2=stack.back();
+ Value *val1=stck.back();
+ stck.pop_back();
+ Value *& val2=stck.back();
Value *val3;
try
{
val2=val3;
}
-void LowerThanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void LowerThanFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void LowerThanFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double a(stck.back());
+ stck.pop_back();
+ double b(stck.back());
+ stck.back()=a<b?std::numeric_limits<double>::max():-std::numeric_limits<double>::max();
+}
+
const char *LowerThanFunction::getRepr() const
{
return REPR;
{
}
-void IfFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+void IfFunction::operate(std::vector<Value *>& stck) const
{
- Value *val1=stack.back();
- stack.pop_back();
- Value *val2=stack.back();
- stack.pop_back();
- Value *&val3=stack.back();
+ Value *val1=stck.back();
+ stck.pop_back();
+ Value *val2=stck.back();
+ stck.pop_back();
+ Value *&val3=stck.back();
Value *val4;
try
{
val3=val4;
}
-void IfFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+void IfFunction::operateX86(std::vector<std::string>& asmb) const
{
throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
}
+void IfFunction::operateStackOfDouble(std::vector<double>& stck) const
+{
+ double cond(stck.back());
+ stck.pop_back();
+ double the(stck.back());
+ stck.pop_back();
+ if(cond==std::numeric_limits<double>::max())
+ stck.back()=the;
+}
+
+void IfFunction::operateStackOfDoubleSafe(std::vector<double>& stck) const
+{
+ double cond(stck.back());
+ stck.pop_back();
+ double the(stck.back());
+ stck.pop_back();
+ if(cond!=std::numeric_limits<double>::max() && cond!=-std::numeric_limits<double>::max())
+ throw INTERP_KERNEL::Exception("ifFunc : first parameter of ternary func is NOT a consequence of a boolean op !");
+ if(cond==std::numeric_limits<double>::max())
+ stck.back()=the;
+}
+
const char *IfFunction::getRepr() const
{
return REPR;