00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_FUN_MATH_COS_HH
00027 # define MLN_FUN_MATH_COS_HH
00028
00029 # include <mln/fun/unary.hh>
00030 # include <mln/value/builtin/floatings.hh>
00031 # include <mln/value/builtin/integers.hh>
00032 # include <mln/math/acos.hh>
00033 # include <mln/math/cos.hh>
00034
00035 namespace mln
00036 {
00037
00038
00039 namespace fun
00040 {
00041 struct cos : unary<cos> {};
00042 }
00043
00044 namespace trait
00045 {
00046
00047 namespace next
00048 {
00049
00050 template <typename T>
00051 struct set_unary_<mln::fun::cos, mln::value::Floating, T>
00052 {
00053 typedef set_unary_ ret;
00054 typedef T result;
00055 typedef T argument;
00056 typedef T& lvalue;
00057
00058 static result read(const argument& x)
00059 {
00060 return math::cos(x);
00061 }
00062
00063 static void write(lvalue l, const result& x)
00064 {
00065 l = math::acos(x);
00066 }
00067 };
00068
00069 template <typename T>
00070 struct set_unary_<mln::fun::cos, mln::value::Integer, T>
00071 {
00072 typedef set_unary_ ret;
00073 typedef double result;
00074 typedef T argument;
00075
00076 static result read(const argument& x)
00077 {
00078 return math::cos((result)x);
00079 }
00080
00081 };
00082
00083 }
00084
00085 }
00086
00087 }
00088
00089 #endif