From: ageay Date: Wed, 28 Nov 2012 15:52:21 +0000 (+0000) Subject: Addition of asin,acos,atan,sinh,cosh and tanh X-Git-Tag: V6_6_0~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6eeba600c0a0e6b1b16109d8c8c2403885cee1c0;p=tools%2Fmedcoupling.git Addition of asin,acos,atan,sinh,cosh and tanh --- diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx index c8e4d5b8d..6e4f13e7b 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx @@ -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& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val=stack.back(); + val->acos(); +} + +void ACosFunction::operateX86(std::vector& 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& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val=stack.back(); + val->asin(); +} + +void ASinFunction::operateX86(std::vector& 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& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val=stack.back(); + val->atan(); +} + +void ATanFunction::operateX86(std::vector& 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& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val=stack.back(); + val->cosh(); +} + +void CoshFunction::operateX86(std::vector& 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& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val=stack.back(); + val->sinh(); +} + +void SinhFunction::operateX86(std::vector& 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& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val=stack.back(); + val->tanh(); +} + +void TanhFunction::operateX86(std::vector& 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() { } diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx index f49c75943..b63382683 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx @@ -131,6 +131,78 @@ namespace INTERP_KERNEL static const char REPR[]; }; + class INTERPKERNEL_EXPORT ACosFunction : public UnaryFunction + { + public: + ~ACosFunction(); + void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& 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& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& 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& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& 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& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& 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& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& 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& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& 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: diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx index 6564cfd25..3a24ef6da 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx @@ -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(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(),-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(),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(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(),-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(),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(std::asin)); +} + +void ValueDoubleExpr::atan() throw(INTERP_KERNEL::Exception) +{ + std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::atan)); +} + +void ValueDoubleExpr::cosh() throw(INTERP_KERNEL::Exception) +{ + std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::cosh)); +} + +void ValueDoubleExpr::sinh() throw(INTERP_KERNEL::Exception) +{ + std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::sinh)); +} + +void ValueDoubleExpr::tanh() throw(INTERP_KERNEL::Exception) +{ + std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::tanh)); +} + void ValueDoubleExpr::abs() throw(INTERP_KERNEL::Exception) { std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(fabs)); diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx index 71d5bf0f0..36c484b04 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx @@ -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);