1 #ifndef VIENNACL_LINALG_NORM_2_HPP_
2 #define VIENNACL_LINALG_NORM_2_HPP_
40 #ifdef VIENNACL_WITH_MTL4
44 template<
typename VectorT >
46 typename VectorT::value_type>::type
49 return mtl::two_norm(v);
54 #ifdef VIENNACL_WITH_EIGEN
58 template<
typename VectorT >
60 typename VectorT::RealScalar>::type
68 #ifdef VIENNACL_WITH_UBLAS
72 template<
typename VectorT >
74 typename VectorT::value_type>::type
85 template<
typename T,
typename A >
86 T
norm_2(std::vector<T, A>
const & v1)
89 for (
typename std::vector<T, A>::size_type i=0; i<v1.size(); ++i)
90 result += v1[i] * v1[i];
92 return std::sqrt(result);
98 template<
typename ScalarType>
102 norm_2(viennacl::vector_base<ScalarType>
const & v)
106 const viennacl::vector_base<ScalarType>,
111 template <
typename LHS,
typename RHS,
typename OP>
115 norm_2(viennacl::vector_expression<const LHS, const RHS, OP>
const &
vector)
118 const viennacl::vector_expression<const LHS, const RHS, OP>,
Simple enable-if variant that uses the SFINAE pattern.
Definition: enable_if.hpp:29
Dispatch facility for distinguishing between ublas, STL and ViennaCL types.
T norm_2(std::vector< T, A > const &v1)
Definition: norm_2.hpp:86
This file provides the forward declarations for the main types used within ViennaCL.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
An expression template class that represents a binary operation that yields a vector.
Definition: forwards.h:181
A proxy for scalar expressions (e.g. from inner vector products)
Definition: forwards.h:175
viennacl::scalar_expression< const viennacl::vector_expression< const LHS, const RHS, OP >, const viennacl::vector_expression< const LHS, const RHS, OP >, viennacl::op_norm_2 > norm_2(viennacl::vector_expression< const LHS, const RHS, OP > const &vector)
Definition: norm_2.hpp:115
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
A tag class representing the 2-norm of a vector.
Definition: forwards.h:156
Simple enable-if variant that uses the SFINAE pattern.