ViennaCL - The Vienna Computing Library  1.2.0
hankel_matrix_operations.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_HANKEL_MATRIX_OPERATIONS_HPP_
2 #define VIENNACL_LINALG_HANKEL_MATRIX_OPERATIONS_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 "viennacl/forwards.h"
25 #include "viennacl/ocl/device.hpp"
26 #include "viennacl/ocl/handle.hpp"
27 #include "viennacl/ocl/kernel.hpp"
28 #include "viennacl/scalar.hpp"
29 #include "viennacl/vector.hpp"
30 #include "viennacl/tools/tools.hpp"
31 #include "viennacl/fft.hpp"
33 //#include "viennacl/linalg/kernels/coordinate_matrix_kernels.h"
34 
35 namespace viennacl
36 {
37  namespace linalg
38  {
39 
40 
41  // A * x
49  template<class SCALARTYPE, unsigned int ALIGNMENT, unsigned int VECTOR_ALIGNMENT>
50  vector_expression<const hankel_matrix<SCALARTYPE, ALIGNMENT>,
51  const vector<SCALARTYPE, VECTOR_ALIGNMENT>,
54  {
57  op_prod >(mat, vec);
58  }
59 
60  // A * x
69  template<class SCALARTYPE, unsigned int ALIGNMENT, unsigned int VECTOR_ALIGNMENT>
74  size_t NUM_THREADS)
75  {
78  viennacl::op_prod >(mat, vec);
79  }
80 
89  template<class SCALARTYPE, unsigned int ALIGNMENT, unsigned int VECTOR_ALIGNMENT>
93  {
94  assert(mat.size1() == result.size());
95  assert(mat.size2() == vec.size());
96 
97  prod_impl(mat.elements(), vec, result);
98  viennacl::detail::fft::reverse(result);
99  }
100 
101  } //namespace linalg
102 
103 
104 
109  template <typename SCALARTYPE, unsigned int ALIGNMENT>
110  template <unsigned int MAT_ALIGNMENT>
114  viennacl::op_prod> & proxy)
115  {
116  // check for the special case x = A * x
117  if (proxy.rhs().handle() == this->handle())
118  {
119  viennacl::vector<SCALARTYPE, ALIGNMENT> result(proxy.rhs().size());
120  viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
121  *this = result;
122  return *this;
123  }
124  else
125  {
126  viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), *this);
127  return *this;
128  }
129  return *this;
130  }
131 
132  //v += A * x
137  template <typename SCALARTYPE, unsigned int ALIGNMENT>
138  template <unsigned int MAT_ALIGNMENT>
142  op_prod> & proxy)
143  {
144  vector<SCALARTYPE, ALIGNMENT> result(proxy.lhs().size1());
145  viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
146  *this += result;
147  return *this;
148  }
149 
154  template <typename SCALARTYPE, unsigned int ALIGNMENT>
155  template <unsigned int MAT_ALIGNMENT>
159  op_prod> & proxy)
160  {
161  vector<SCALARTYPE, ALIGNMENT> result(proxy.get_lhs().size1());
162  viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
163  *this -= result;
164  return *this;
165  }
166 
167 
168  //free functions:
173  template <typename SCALARTYPE, unsigned int ALIGNMENT>
174  template <unsigned int MAT_ALIGNMENT>
178  op_prod> & proxy)
179  {
180  assert(proxy.get_lhs().size1() == size());
182  viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
183  result += *this;
184  return result;
185  }
186 
191  template <typename SCALARTYPE, unsigned int ALIGNMENT>
192  template <unsigned int MAT_ALIGNMENT>
196  op_prod> & proxy)
197  {
198  assert(proxy.get_lhs().size1() == size());
200  viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
201  result = *this - result;
202  return result;
203  }
204 
205 } //namespace viennacl
206 
207 
208 #endif