00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_INFINITY_NORM_INCLUDE
00013 #define MTL_INFINITY_NORM_INCLUDE
00014
00015 #include <boost/numeric/mtl/concept/collection.hpp>
00016 #include <boost/numeric/mtl/concept/magnitude.hpp>
00017 #include <boost/numeric/mtl/utility/enable_if.hpp>
00018 #include <boost/numeric/mtl/utility/is_row_major.hpp>
00019 #include <boost/numeric/mtl/utility/category.hpp>
00020 #include <boost/numeric/mtl/utility/tag.hpp>
00021 #include <boost/numeric/mtl/utility/property_map.hpp>
00022 #include <boost/numeric/mtl/operation/max_of_sums.hpp>
00023 #include <boost/numeric/mtl/vector/reduction.hpp>
00024 #include <boost/numeric/mtl/vector/reduction_functors.hpp>
00025
00026
00027 namespace mtl {
00028
00029 namespace vector {
00030
00031 template <unsigned long Unroll, typename Vector>
00032 typename traits::enable_if_vector<Vector, typename RealMagnitude<typename Collection<Vector>::value_type>::type>::type
00033 inline infinity_norm(const Vector& vector)
00034 {
00035 typedef typename RealMagnitude<typename Collection<Vector>::value_type>::type result_type;
00036 return vector::reduction<Unroll, vector::infinity_norm_functor, result_type>::apply(vector);
00037 }
00038
00048 template <typename Vector>
00049 typename mtl::traits::enable_if_vector<Vector, typename RealMagnitude<typename Collection<Vector>::value_type>::type>::type
00050 inline infinity_norm(const Vector& vector)
00051 {
00052 return infinity_norm<8>(vector);
00053 }
00054 }
00055
00056 namespace matrix {
00057
00058
00059 template <unsigned long Unroll, typename Matrix>
00060 typename mtl::traits::enable_if_matrix<Matrix, typename RealMagnitude<typename Collection<Matrix>::value_type>::type>::type
00061 inline infinity_norm(const Matrix& matrix)
00062 {
00063 using mtl::impl::max_of_sums;
00064 typename mtl::traits::row<Matrix>::type row(matrix);
00065 return max_of_sums(matrix, mtl::traits::is_row_major<typename OrientedCollection<Matrix>::orientation>(),
00066 row, num_rows(matrix));
00067 }
00068
00075 template <typename Matrix>
00076 typename mtl::traits::enable_if_matrix<Matrix, typename RealMagnitude<typename Collection<Matrix>::value_type>::type>::type
00077 inline infinity_norm(const Matrix& matrix)
00078 {
00079 return infinity_norm<8>(matrix);
00080 }
00081 }
00082
00083 using vector::infinity_norm;
00084 using matrix::infinity_norm;
00085
00086 }
00087
00088 #endif // MTL_INFINITY_NORM_INCLUDE