Go to the documentation of this file.00001 #ifndef VIENNACL_LINALG_NORM_INF_HPP_
00002 #define VIENNACL_LINALG_NORM_INF_HPP_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00024 #include <math.h>
00025 #include "viennacl/forwards.h"
00026 #include "viennacl/tools/tools.hpp"
00027 #include "viennacl/meta/enable_if.hpp"
00028 #include "viennacl/meta/tag_of.hpp"
00029
00030 namespace viennacl
00031 {
00032
00033
00034
00035
00036
00037 namespace linalg
00038 {
00039
00040 #ifdef VIENNACL_HAVE_UBLAS
00041
00042
00043
00044 template< typename VectorT >
00045 typename VectorT::value_type
00046 norm_inf(VectorT const& v1,
00047 typename viennacl::enable_if< viennacl::is_ublas< typename viennacl::traits::tag_of< VectorT >::type >::value
00048 >::type* dummy = 0)
00049 {
00050
00051 return boost::numeric::ublas::norm_inf(v1);
00052 }
00053 #endif
00054
00055
00056
00057
00058
00059 template< typename VectorT>
00060 typename VectorT::value_type
00061 norm_inf(VectorT const& v1,
00062 typename viennacl::enable_if< viennacl::is_stl< typename viennacl::traits::tag_of< VectorT >::type >::value
00063 >::type* dummy = 0)
00064 {
00065
00066 typename VectorT::value_type result = 0;
00067 for (typename VectorT::size_type i=0; i<v1.size(); ++i)
00068 {
00069 if (fabs(v1[i]) > result)
00070 result = fabs(v1[i]);
00071 }
00072
00073 return result;
00074 }
00075
00076
00077
00078
00079 template< typename ScalarType, unsigned int alignment >
00080 viennacl::scalar_expression< const viennacl::vector<ScalarType, alignment>,
00081 const viennacl::vector<ScalarType, alignment>,
00082 viennacl::op_norm_inf >
00083 norm_inf(viennacl::vector<ScalarType, alignment> const & v1,
00084 typename viennacl::enable_if< viennacl::is_viennacl< typename viennacl::traits::tag_of< viennacl::vector<ScalarType, alignment> >::type >::value
00085 >::type* dummy = 0)
00086 {
00087
00088 return viennacl::scalar_expression< const viennacl::vector<ScalarType, alignment>,
00089 const viennacl::vector<ScalarType, alignment>,
00090 viennacl::op_norm_inf >(v1, v1);
00091 }
00092
00093 }
00094 }
00095 #endif
00096
00097
00098
00099
00100