/** -*- C++ -*- ** ** KAI C++ Compiler ** ** Copyright (C) 1997-2001 Intel Corp. All rights reserved. **/ /** ** Lib++ : The Modena C++ Standard Library, ** Version 2.4, October 1997 ** ** Copyright (c) 1995-1997 Modena Software Inc. **/ #ifndef __KAI_EXTFUNC #define __KAI_EXTFUNC #include #include namespace __kai { // // Extended functors provided for // class valarray implementation // using namespace std; template struct unary_plus: unary_function { // Added by KAI T operator()(const T& x) const { return +x; } }; template struct unary_not : std::unary_function { T operator()(const T& x) const { return !x; } }; template struct complement : unary_function { T operator()(const T& x) const { return ~x; } }; template struct bitwise_and : binary_function { T operator()(const T& x, const T& y) const { return x & y; } }; template struct bitwise_or : binary_function { T operator()(const T& x, const T& y) const { return x | y; } }; template struct logical_and : binary_function { T operator()(const T& x, const T& y) const { return x && y; } }; template struct logical_or : binary_function { T operator()(const T& x, const T& y) const { return x || y; } }; template struct caret : binary_function { T operator()(const T& x, const T& y) const { return x ^ y; } }; template struct shiftl: binary_function { T operator()(const T& x, const T& y) const { return x << y; } }; template struct shiftr: binary_function { T operator()(const T& x, const T& y) const { return x >> y; } }; template struct absolute: unary_function { T operator()(const T& x) const { return std::abs(x); } }; template struct sine: unary_function { T operator()(const T& x) const { return std::sin(x); } }; template struct cosine: unary_function { T operator()(const T& x) const { return std::cos(x); } }; template struct tangent: unary_function { T operator()(const T& x) const { return std::tan(x); } }; template struct arcsin: unary_function { T operator()(const T& x) const { return std::asin(x); } }; template struct arccos: unary_function { T operator()(const T& x) const { return std::acos(x); } }; template struct arctan: unary_function { T operator()(const T& x) const { return std::atan(x); } }; template struct logarithm: unary_function { T operator()(const T& x) const { return std::log(x); } }; template struct logarithm10: unary_function { T operator()(const T& x) const { return std::log10(x); } }; template struct sqroot: unary_function { T operator()(const T& x) const { return std::sqrt((double)x); } }; template<> struct sqroot : unary_function { float operator()(const float& x) const { return std::sqrt(x); } }; template<> struct sqroot : unary_function { long double operator()(const long double& x) const { return std::sqrt(x); } }; template struct exponential: unary_function { T operator()(const T& x) const { return std::exp(x); } }; template struct arctan2: binary_function { T operator()(const T& x, const T& y) const { return std::atan2(x, y); } }; template struct power: binary_function { T operator()(const T& x, const T& y) const { return std::pow((double)x, (double)y); } }; template<> struct power : binary_function { int operator()(const int& x, const int& y) const { float f = std::pow((float)x, (float)y); int i = f; return i; } }; template<> struct power : binary_function { float operator()(const float& x, const float& y) const { return std::pow(x,y); } }; template<> struct power : binary_function { long double operator()(const long double& x, const long double& y) const { return std::pow(x,y); } }; template struct sineh: unary_function { T operator()(const T& x) const { return std::sinh (x); } }; template struct cosineh: unary_function { T operator()(const T& x) const { return std::cosh (x); } }; template struct tangenth: unary_function { T operator()(const T& x) const { return std::tanh (x); } }; } // namespace std #endif /* __KAI_EXTFUNC */