ViennaCL - The Vienna Computing Library  1.2.0
norm_inf.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_NORM_INF_HPP_
2 #define VIENNACL_LINALG_NORM_INF_HPP_
3 
4 /* =========================================================================
5  Copyright (c) 2010-2011, Institute for Microelectronics,
6  Institute for Analysis and Scientific Computing,
7  TU Wien.
8 
9  -----------------
10  ViennaCL - The Vienna Computing Library
11  -----------------
12 
13  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
14 
15  (A list of authors and contributors can be found in the PDF manual)
16 
17  License: MIT (X11), see file LICENSE in the base directory
18 ============================================================================= */
19 
24 #include <math.h> //for sqrt()
25 #include "viennacl/forwards.h"
26 #include "viennacl/tools/tools.hpp"
28 #include "viennacl/meta/tag_of.hpp"
29 
30 namespace viennacl
31 {
32  //
33  // generic norm_inf function
34  // uses tag dispatch to identify which algorithm
35  // should be called
36  //
37  namespace linalg
38  {
39 
40  #ifdef VIENNACL_HAVE_UBLAS
41  // ----------------------------------------------------
42  // UBLAS
43  //
44  template< typename VectorT >
45  typename VectorT::value_type
46  norm_inf(VectorT const& v1,
48  >::type* dummy = 0)
49  {
50  // std::cout << "ublas .. " << std::endl;
52  }
53  #endif
54 
55 
56  // ----------------------------------------------------
57  // STL
58  //
59  template< typename VectorT>
60  typename VectorT::value_type
61  norm_inf(VectorT const& v1,
63  >::type* dummy = 0)
64  {
65  //std::cout << "stl .. " << std::endl;
66  typename VectorT::value_type result = 0;
67  for (typename VectorT::size_type i=0; i<v1.size(); ++i)
68  {
69  if (fabs(v1[i]) > result)
70  result = fabs(v1[i]);
71  }
72 
73  return result;
74  }
75 
76  // ----------------------------------------------------
77  // VIENNACL
78  //
79  template< typename ScalarType, unsigned int alignment >
82  viennacl::op_norm_inf >
85  >::type* dummy = 0)
86  {
87  //std::cout << "viennacl .. " << std::endl;
90  viennacl::op_norm_inf >(v1, v1);
91  }
92 
93  } // end namespace linalg
94 } // end namespace viennacl
95 #endif
96 
97 
98 
99 
100