00001
00002
00003
00004
00005 #ifndef synaps_arithm_inv_H
00006 #define synaps_arithm_inv_H
00007
00008 #include <synaps/init.h>
00009 #include <synaps/arithm/traits.h>
00010 #include <synaps/arithm/pow.h>
00011
00012
00013 __BEGIN_NAMESPACE_SYNAPS
00014
00016 template<class C>
00017 typename rationalof<C>::T inv(const C& a)
00018 {
00019 return typename rationalof<C>::T (C(1),a);
00020 }
00021
00023 template<class C>
00024 typename rationalof<C>::T powgen( const C& a, int i )
00025 {
00026 typedef typename rationalof<C>::T rat_t;
00027 return (i>0? rat_t(pow(a,i)): (i==0? rat_t(1): rat_t(rat_t(1)/pow(a,-i))));
00028 }
00029
00030 __END_NAMESPACE_SYNAPS
00031 #endif // synaps_arithm_inv_H
00032