00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_MAGNITUDE_INCLUDE
00013 #define MTL_MAGNITUDE_INCLUDE
00014
00015 #include <complex>
00016
00017 namespace mtl {
00018
00019
00020
00021
00022
00023
00024 #ifdef __GXX_CONCEPTS__
00025
00026
00027
00028
00029 auto concept Magnitude<typename T>
00030 {
00031 typename type = T;
00032 };
00033
00034 template <typename T>
00035 concept_map Magnitude<std::complex<T> >
00036 {
00037 typedef T type;
00038 }
00039
00040
00041
00042 auto concept RealMagnitude<typename T>
00043 : Magnitude<T>
00044 {
00045 requires std::EqualityComparable<type>;
00046 requires std::LessThanComparable<type>;
00047
00048 #ifndef CONCEPTS_WITHOUT_OVERLOADED_REQUIREMENTS
00049 requires Field<type>;
00050 #endif
00051
00052 type sqrt(type);
00053
00054 type abs(T);
00055 }
00056
00057 #else // now without concepts
00058
00060
00064 template <typename T>
00065 struct Magnitude
00066 {
00068 typedef T type;
00069 };
00070
00072 template <typename T>
00073 struct Magnitude<std::complex<T> >
00074 {
00076 typedef T type;
00077 };
00078
00079 template <typename T> struct RealMagnitude
00080 : public Magnitude<T>
00081 {};
00082
00083 #endif // __GXX_CONCEPTS__
00084
00085 }
00086
00087 #endif // MTL_MAGNITUDE_INCLUDE