]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Addition of asin,acos,atan,sinh,cosh and tanh
authorageay <ageay>
Wed, 28 Nov 2012 15:52:21 +0000 (15:52 +0000)
committerageay <ageay>
Wed, 28 Nov 2012 15:52:21 +0000 (15:52 +0000)
src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx
src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx
src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx
src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx

index c8e4d5b8dc19b752b0648d6321efe2244f5f1071..6e4f13e7b0fbce0157cfa5374c8ba782f378714a 100644 (file)
@@ -37,6 +37,18 @@ const char SinFunction::REPR[]="sin";
 
 const char TanFunction::REPR[]="tan";
 
+const char ACosFunction::REPR[]="acos";
+
+const char ASinFunction::REPR[]="asin";
+
+const char ATanFunction::REPR[]="atan";
+
+const char CoshFunction::REPR[]="cosh";
+
+const char SinhFunction::REPR[]="sinh";
+
+const char TanhFunction::REPR[]="tanh";
+
 const char SqrtFunction::REPR[]="sqrt";
 
 const char AbsFunction::REPR[]="abs";
@@ -95,6 +107,18 @@ Function *FunctionsFactory::buildUnaryFuncFromString(const char *type) throw(INT
     return new SinFunction;
   if(tmp==TanFunction::REPR)
     return new TanFunction;
+  if(tmp==ACosFunction::REPR)
+    return new ACosFunction;
+  if(tmp==ASinFunction::REPR)
+    return new ASinFunction;
+  if(tmp==ATanFunction::REPR)
+    return new ATanFunction;
+  if(tmp==CoshFunction::REPR)
+    return new CoshFunction;
+  if(tmp==SinhFunction::REPR)
+    return new SinhFunction;
+  if(tmp==TanhFunction::REPR)
+    return new TanhFunction;
   if(tmp==SqrtFunction::REPR)
     return new SqrtFunction;
   if(tmp==AbsFunction::REPR)
@@ -312,6 +336,156 @@ bool TanFunction::isACall() const
   return true;
 }
 
+ACosFunction::~ACosFunction()
+{
+}
+
+void ACosFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+  Value *val=stack.back();
+  val->acos();
+}
+
+void ACosFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+  throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
+}
+
+const char *ACosFunction::getRepr() const
+{
+  return REPR;
+}
+
+bool ACosFunction::isACall() const
+{
+  return true;
+}
+
+ASinFunction::~ASinFunction()
+{
+}
+
+void ASinFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+  Value *val=stack.back();
+  val->asin();
+}
+
+void ASinFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+  throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
+}
+
+const char *ASinFunction::getRepr() const
+{
+  return REPR;
+}
+
+bool ASinFunction::isACall() const
+{
+  return true;
+}
+
+ATanFunction::~ATanFunction()
+{
+}
+
+void ATanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+  Value *val=stack.back();
+  val->atan();
+}
+
+void ATanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+  throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
+}
+
+const char *ATanFunction::getRepr() const
+{
+  return REPR;
+}
+
+bool ATanFunction::isACall() const
+{
+  return true;
+}
+
+CoshFunction::~CoshFunction()
+{
+}
+
+void CoshFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+  Value *val=stack.back();
+  val->cosh();
+}
+
+void CoshFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+  throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
+}
+
+const char *CoshFunction::getRepr() const
+{
+  return REPR;
+}
+
+bool CoshFunction::isACall() const
+{
+  return true;
+}
+
+SinhFunction::~SinhFunction()
+{
+}
+
+void SinhFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+  Value *val=stack.back();
+  val->sinh();
+}
+
+void SinhFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+  throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
+}
+
+const char *SinhFunction::getRepr() const
+{
+  return REPR;
+}
+
+bool SinhFunction::isACall() const
+{
+  return true;
+}
+
+TanhFunction::~TanhFunction()
+{
+}
+
+void TanhFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+  Value *val=stack.back();
+  val->tanh();
+}
+
+void TanhFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+  throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
+}
+
+const char *TanhFunction::getRepr() const
+{
+  return REPR;
+}
+
+bool TanhFunction::isACall() const
+{
+  return true;
+}
+
 SqrtFunction::~SqrtFunction()
 {
 }
index f49c7594303c42938b811afe329a78610ecfe7f7..b63382683c4b7894984ee70d27f8cfb216644fea 100644 (file)
@@ -131,6 +131,78 @@ namespace INTERP_KERNEL
     static const char REPR[];
   };
 
+  class INTERPKERNEL_EXPORT ACosFunction : public UnaryFunction
+  {
+  public:
+    ~ACosFunction();
+    void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+    void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+    const char *getRepr() const;
+    bool isACall() const;
+  public:
+    static const char REPR[];
+  };
+
+  class INTERPKERNEL_EXPORT ASinFunction : public UnaryFunction
+  {
+  public:
+    ~ASinFunction();
+    void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+    void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+    const char *getRepr() const;
+    bool isACall() const;
+  public:
+    static const char REPR[];
+  };
+
+  class INTERPKERNEL_EXPORT ATanFunction : public UnaryFunction
+  {
+  public:
+    ~ATanFunction();
+    void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+    void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+    const char *getRepr() const;
+    bool isACall() const;
+  public:
+    static const char REPR[];
+  };
+
+  class INTERPKERNEL_EXPORT CoshFunction : public UnaryFunction
+  {
+  public:
+    ~CoshFunction();
+    void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+    void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+    const char *getRepr() const;
+    bool isACall() const;
+  public:
+    static const char REPR[];
+  };
+
+  class INTERPKERNEL_EXPORT SinhFunction : public UnaryFunction
+  {
+  public:
+    ~SinhFunction();
+    void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+    void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+    const char *getRepr() const;
+    bool isACall() const;
+  public:
+    static const char REPR[];
+  };
+
+  class INTERPKERNEL_EXPORT TanhFunction : public UnaryFunction
+  {
+  public:
+    ~TanhFunction();
+    void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+    void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+    const char *getRepr() const;
+    bool isACall() const;
+  public:
+    static const char REPR[];
+  };
+
   class INTERPKERNEL_EXPORT SqrtFunction : public UnaryFunction
   {
   public:
index 6564cfd252f78c6ae4207949cd156471016f3413..3a24ef6da5154512a1d3f2e1b514914429e7cd84 100644 (file)
@@ -80,6 +80,36 @@ void ValueDouble::tan() throw(INTERP_KERNEL::Exception)
   _data=std::tan(_data);
 }
 
+void ValueDouble::acos() throw(INTERP_KERNEL::Exception)
+{
+  _data=std::acos(_data);
+}
+
+void ValueDouble::asin() throw(INTERP_KERNEL::Exception)
+{
+  _data=std::asin(_data);
+}
+
+void ValueDouble::atan() throw(INTERP_KERNEL::Exception)
+{
+  _data=std::atan(_data);
+}
+
+void ValueDouble::cosh() throw(INTERP_KERNEL::Exception)
+{
+  _data=std::cosh(_data);
+}
+
+void ValueDouble::sinh() throw(INTERP_KERNEL::Exception)
+{
+  _data=std::sinh(_data);
+}
+
+void ValueDouble::tanh() throw(INTERP_KERNEL::Exception)
+{
+  _data=std::tanh(_data);
+}
+
 void ValueDouble::abs() throw(INTERP_KERNEL::Exception)
 {
   if(_data<0.)
@@ -229,6 +259,36 @@ void ValueUnit::tan() throw(INTERP_KERNEL::Exception)
   unsupportedOp(TanFunction::REPR);
 }
 
+void ValueUnit::acos() throw(INTERP_KERNEL::Exception)
+{
+  unsupportedOp(ACosFunction::REPR);
+}
+
+void ValueUnit::asin() throw(INTERP_KERNEL::Exception)
+{
+  unsupportedOp(ASinFunction::REPR);
+}
+
+void ValueUnit::atan() throw(INTERP_KERNEL::Exception)
+{
+  unsupportedOp(ATanFunction::REPR);
+}
+
+void ValueUnit::cosh() throw(INTERP_KERNEL::Exception)
+{
+  unsupportedOp(CoshFunction::REPR);
+}
+
+void ValueUnit::sinh() throw(INTERP_KERNEL::Exception)
+{
+  unsupportedOp(SinhFunction::REPR);
+}
+
+void ValueUnit::tanh() throw(INTERP_KERNEL::Exception)
+{
+  unsupportedOp(TanhFunction::REPR);
+}
+
 void ValueUnit::abs() throw(INTERP_KERNEL::Exception)
 {
   unsupportedOp(AbsFunction::REPR);
@@ -395,6 +455,48 @@ void ValueDoubleExpr::tan() throw(INTERP_KERNEL::Exception)
   std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun<double,double>(std::tan));
 }
 
+void ValueDoubleExpr::acos() throw(INTERP_KERNEL::Exception)
+{
+  double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::less<double>(),-1.));
+  if(it!=_dest_data+_sz_dest_data)
+    throw INTERP_KERNEL::Exception("Trying to apply acos on < 1. value !");
+  it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::greater<double>(),1.));
+  if(it!=_dest_data+_sz_dest_data)
+    throw INTERP_KERNEL::Exception("Trying to apply acos on > 1. value !");
+  std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun<double,double>(std::acos));
+}
+
+void ValueDoubleExpr::asin() throw(INTERP_KERNEL::Exception)
+{
+   double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::less<double>(),-1.));
+   if(it!=_dest_data+_sz_dest_data)
+    throw INTERP_KERNEL::Exception("Trying to apply asin on < 1. value !");
+  it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::greater<double>(),1.));
+  if(it!=_dest_data+_sz_dest_data)
+    throw INTERP_KERNEL::Exception("Trying to apply asin on > 1. value !");
+  std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun<double,double>(std::asin));
+}
+
+void ValueDoubleExpr::atan() throw(INTERP_KERNEL::Exception)
+{
+  std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun<double,double>(std::atan));
+}
+
+void ValueDoubleExpr::cosh() throw(INTERP_KERNEL::Exception)
+{
+  std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun<double,double>(std::cosh));
+}
+
+void ValueDoubleExpr::sinh() throw(INTERP_KERNEL::Exception)
+{
+  std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun<double,double>(std::sinh));
+}
+
+void ValueDoubleExpr::tanh() throw(INTERP_KERNEL::Exception)
+{
+  std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun<double,double>(std::tanh));
+}
+
 void ValueDoubleExpr::abs() throw(INTERP_KERNEL::Exception)
 {
   std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun<double,double>(fabs));
index 71d5bf0f07727efab5a87609bd740d11d3e1de03..36c484b04bd6841b456236eb25b20d60b1b56b2b 100644 (file)
@@ -41,6 +41,12 @@ namespace INTERP_KERNEL
     virtual void cos() throw(INTERP_KERNEL::Exception) = 0;
     virtual void sin() throw(INTERP_KERNEL::Exception) = 0;
     virtual void tan() throw(INTERP_KERNEL::Exception) = 0;
+    virtual void acos() throw(INTERP_KERNEL::Exception) = 0;
+    virtual void asin() throw(INTERP_KERNEL::Exception) = 0;
+    virtual void atan() throw(INTERP_KERNEL::Exception) = 0;
+    virtual void cosh() throw(INTERP_KERNEL::Exception) = 0;
+    virtual void sinh() throw(INTERP_KERNEL::Exception) = 0;
+    virtual void tanh() throw(INTERP_KERNEL::Exception) = 0;
     virtual void abs() throw(INTERP_KERNEL::Exception) = 0;
     virtual void exp() throw(INTERP_KERNEL::Exception) = 0;
     virtual void ln() throw(INTERP_KERNEL::Exception) = 0;
@@ -74,6 +80,12 @@ namespace INTERP_KERNEL
     void cos() throw(INTERP_KERNEL::Exception);
     void sin() throw(INTERP_KERNEL::Exception);
     void tan() throw(INTERP_KERNEL::Exception);
+    void acos() throw(INTERP_KERNEL::Exception);
+    void asin() throw(INTERP_KERNEL::Exception);
+    void atan() throw(INTERP_KERNEL::Exception);
+    void cosh() throw(INTERP_KERNEL::Exception);
+    void sinh() throw(INTERP_KERNEL::Exception);
+    void tanh() throw(INTERP_KERNEL::Exception);
     void abs() throw(INTERP_KERNEL::Exception);
     void exp() throw(INTERP_KERNEL::Exception);
     void ln() throw(INTERP_KERNEL::Exception);
@@ -112,6 +124,12 @@ namespace INTERP_KERNEL
     void cos() throw(INTERP_KERNEL::Exception);
     void sin() throw(INTERP_KERNEL::Exception);
     void tan() throw(INTERP_KERNEL::Exception);
+    void acos() throw(INTERP_KERNEL::Exception);
+    void asin() throw(INTERP_KERNEL::Exception);
+    void atan() throw(INTERP_KERNEL::Exception);
+    void cosh() throw(INTERP_KERNEL::Exception);
+    void sinh() throw(INTERP_KERNEL::Exception);
+    void tanh() throw(INTERP_KERNEL::Exception);
     void abs() throw(INTERP_KERNEL::Exception);
     void exp() throw(INTERP_KERNEL::Exception);
     void ln() throw(INTERP_KERNEL::Exception);
@@ -152,6 +170,12 @@ namespace INTERP_KERNEL
     void cos() throw(INTERP_KERNEL::Exception);
     void sin() throw(INTERP_KERNEL::Exception);
     void tan() throw(INTERP_KERNEL::Exception);
+    void acos() throw(INTERP_KERNEL::Exception);
+    void asin() throw(INTERP_KERNEL::Exception);
+    void atan() throw(INTERP_KERNEL::Exception);
+    void cosh() throw(INTERP_KERNEL::Exception);
+    void sinh() throw(INTERP_KERNEL::Exception);
+    void tanh() throw(INTERP_KERNEL::Exception);
     void abs() throw(INTERP_KERNEL::Exception);
     void exp() throw(INTERP_KERNEL::Exception);
     void ln() throw(INTERP_KERNEL::Exception);