00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_ONE_NORM_INCLUDE
00013 #define MTL_ONE_NORM_INCLUDE
00014
00015 #include <boost/numeric/mtl/concept/collection.hpp>
00016 #include <boost/numeric/mtl/utility/enable_if.hpp>
00017 #include <boost/numeric/mtl/utility/is_row_major.hpp>
00018 #include <boost/numeric/mtl/utility/tag.hpp>
00019 #include <boost/numeric/mtl/utility/category.hpp>
00020 #include <boost/numeric/mtl/utility/property_map.hpp>
00021 #include <boost/numeric/mtl/operation/max_of_sums.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 Vector>
00031 typename traits::enable_if_vector<Vector, typename RealMagnitude<typename Collection<Vector>::value_type>::type>::type
00032 inline one_norm(const Vector& vector)
00033 {
00034 typedef typename RealMagnitude<typename Collection<Vector>::value_type>::type result_type;
00035 return reduction<Unroll, one_norm_functor, result_type>::apply(vector);
00036 }
00037
00046 template <typename Vector>
00047 typename traits::enable_if_vector<Vector, typename RealMagnitude<typename Collection<Vector>::value_type>::type>::type
00048 inline one_norm(const Vector& vector)
00049 {
00050 return one_norm<8>(vector);
00051 }
00052 }
00053
00054 namespace matrix {
00055
00056
00057 template <unsigned long Unroll, typename Matrix>
00058 typename mtl::traits::enable_if_matrix<Matrix, typename RealMagnitude<typename Collection<Matrix>::value_type>::type>::type
00059 inline one_norm(const Matrix& matrix)
00060 {
00061 using mtl::impl::max_of_sums;
00062 typename mtl::traits::col<Matrix>::type col(matrix);
00063 return max_of_sums(matrix, !mtl::traits::is_row_major<typename OrientedCollection<Matrix>::orientation>(),
00064 col, num_cols(matrix));
00065 }
00066
00073 template <typename Matrix>
00074 typename mtl::traits::enable_if_matrix<Matrix, typename RealMagnitude<typename Collection<Matrix>::value_type>::type>::type
00075 inline one_norm(const Matrix& matrix)
00076 {
00077 return one_norm<8>(matrix);
00078 }
00079 }
00080
00081 using vector::one_norm;
00082 using matrix::one_norm;
00083
00084 }
00085
00086 #endif // MTL_ONE_NORM_INCLUDE