1 #ifndef VIENNACL_LINALG_NORM_2_HPP_
2 #define VIENNACL_LINALG_NORM_2_HPP_
39 #ifdef VIENNACL_HAVE_MTL4
43 #if defined(_MSC_VER) && _MSC_VER < 1500 //Visual Studio 2005 needs special treatment
44 template <
typename ScalarType>
45 ScalarType
norm_2(mtl::dense_vector<ScalarType>
const & v)
48 return mtl::two_norm(v);
52 template<
typename VectorT >
53 typename VectorT::value_type
59 return mtl::two_norm(v);
65 #ifdef VIENNACL_HAVE_EIGEN
69 #if defined(_MSC_VER) && _MSC_VER < 1500 //Visual Studio 2005 needs special treatment
70 float norm_2(Eigen::VectorXf
const & v)
76 double norm_2(Eigen::VectorXd
const & v)
83 template<
typename VectorT >
84 typename VectorT::RealScalar
96 #ifdef VIENNACL_HAVE_UBLAS
100 #if defined(_MSC_VER) && _MSC_VER < 1500 //Visual Studio 2005 needs special treatment
101 template<
typename ScalarType >
103 norm_2(boost::numeric::ublas::vector<ScalarType>
const & v)
109 template<
typename VectorT >
110 typename VectorT::value_type
125 template<
typename VectorT>
126 typename VectorT::value_type
132 typename VectorT::value_type result = 0;
133 for (
typename VectorT::size_type i=0; i<v1.size(); ++i)
134 result += v1[i] * v1[i];
142 template<
typename ScalarType,
unsigned int alignment >
145 viennacl::op_norm_2 >
153 viennacl::op_norm_2 >(v, v);