00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_TWO_NORM_INCLUDE
00013 #define MTL_TWO_NORM_INCLUDE
00014
00015 #include <iostream>
00016 #include <cmath>
00017
00018 #include <boost/numeric/mtl/concept/collection.hpp>
00019 #include <boost/numeric/mtl/concept/magnitude.hpp>
00020 #include <boost/numeric/mtl/utility/tag.hpp>
00021 #include <boost/numeric/mtl/utility/category.hpp>
00022 #include <boost/numeric/mtl/vector/reduction.hpp>
00023 #include <boost/numeric/mtl/vector/reduction_functors.hpp>
00024
00025
00026 namespace mtl {
00027
00028 namespace vector {
00029
00030 template <unsigned long Unroll, typename Value>
00031 typename RealMagnitude<typename Collection<Value>::value_type>::type
00032 inline two_norm(const Value& value)
00033 {
00034 using std::sqrt;
00035 typedef typename RealMagnitude<typename Collection<Value>::value_type>::type result_type;
00036 return sqrt(reduction<Unroll, two_norm_functor, result_type>::apply(value));
00037 }
00038
00039
00048 template <typename Value>
00049 typename RealMagnitude<typename Collection<Value>::value_type>::type
00050 inline two_norm(const Value& value)
00051 {
00052 return two_norm<8>(value);
00053 }
00054 }
00055
00056
00057
00058 using vector::two_norm;
00059
00060 }
00061
00062 #endif // MTL_TWO_NORM_INCLUDE