// This may look like C code, but it is really -*- C++ -*- // Usuall mathematical functions and operations on arrays // R. Ansari, C.Magneville 03/2000 #ifndef MathArray_SEEN #define MathArray_SEEN #include "machdefs.h" #include "tarray.h" #include namespace SOPHYA { // Class for simple mathematical operation on arrays // Instanciated only for real and double (r_4, r_8) type arrays // Reza 03/2000 template class MathArray { public: // Applying a function // Replaces the input array content with the result f(x) virtual TArray& ApplyFunctionInPlace(TArray & a, Arr_DoubleFunctionOfX f); virtual TArray& ApplyFunctionInPlace(TArray & a, Arr_FloatFunctionOfX f); // Creates a new array and fills it with f(x) virtual TArray ApplyFunction(TArray const & a, Arr_DoubleFunctionOfX f); virtual TArray ApplyFunction(TArray const & a, Arr_FloatFunctionOfX f); }; //////////////////////////////////////////////// // Calcul de fonctions usuelles template inline TArray sin(const TArray& a) { MathArray ma; return( ma.ApplyFunction(a, sin) ); } template inline TArray cos(const TArray& a) { MathArray ma; return( ma.ApplyFunction(a, cos) ); } template inline TArray tan(const TArray& a) { MathArray ma; return( ma.ApplyFunction(a, tan) ); } } // Fin du namespace #endif