00001 #ifndef VIENNACL_LINALG_HANKEL_MATRIX_OPERATIONS_HPP_
00002 #define VIENNACL_LINALG_HANKEL_MATRIX_OPERATIONS_HPP_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00024 #include "viennacl/forwards.h"
00025 #include "viennacl/ocl/device.hpp"
00026 #include "viennacl/ocl/handle.hpp"
00027 #include "viennacl/ocl/kernel.hpp"
00028 #include "viennacl/scalar.hpp"
00029 #include "viennacl/vector.hpp"
00030 #include "viennacl/tools/tools.hpp"
00031 #include "viennacl/fft.hpp"
00032 #include "viennacl/linalg/toeplitz_matrix_operations.hpp"
00033
00034
00035 namespace viennacl
00036 {
00037 namespace linalg
00038 {
00039
00040
00041
00049 template<class SCALARTYPE, unsigned int ALIGNMENT, unsigned int VECTOR_ALIGNMENT>
00050 vector_expression<const hankel_matrix<SCALARTYPE, ALIGNMENT>,
00051 const vector<SCALARTYPE, VECTOR_ALIGNMENT>,
00052 op_prod > prod_impl(const hankel_matrix<SCALARTYPE, ALIGNMENT> & mat,
00053 const vector<SCALARTYPE, VECTOR_ALIGNMENT> & vec)
00054 {
00055 return vector_expression<const hankel_matrix<SCALARTYPE, ALIGNMENT>,
00056 const vector<SCALARTYPE, VECTOR_ALIGNMENT>,
00057 op_prod >(mat, vec);
00058 }
00059
00060
00069 template<class SCALARTYPE, unsigned int ALIGNMENT, unsigned int VECTOR_ALIGNMENT>
00070 viennacl::vector_expression<const viennacl::hankel_matrix<SCALARTYPE, ALIGNMENT>,
00071 const viennacl::vector<SCALARTYPE, VECTOR_ALIGNMENT>,
00072 viennacl::op_prod > prod_impl(const viennacl::hankel_matrix<SCALARTYPE, ALIGNMENT> & mat,
00073 const viennacl::vector<SCALARTYPE, VECTOR_ALIGNMENT> & vec,
00074 size_t NUM_THREADS)
00075 {
00076 return viennacl::vector_expression<const viennacl::hankel_matrix<SCALARTYPE, ALIGNMENT>,
00077 const viennacl::vector<SCALARTYPE, VECTOR_ALIGNMENT>,
00078 viennacl::op_prod >(mat, vec);
00079 }
00080
00089 template<class SCALARTYPE, unsigned int ALIGNMENT, unsigned int VECTOR_ALIGNMENT>
00090 void prod_impl(const viennacl::hankel_matrix<SCALARTYPE, ALIGNMENT> & mat,
00091 const viennacl::vector<SCALARTYPE, VECTOR_ALIGNMENT> & vec,
00092 viennacl::vector<SCALARTYPE, VECTOR_ALIGNMENT> & result)
00093 {
00094 assert(mat.size1() == result.size());
00095 assert(mat.size2() == vec.size());
00096
00097 prod_impl(mat.elements(), vec, result);
00098 viennacl::detail::fft::reverse(result);
00099 }
00100
00101 }
00102
00103
00104
00109 template <typename SCALARTYPE, unsigned int ALIGNMENT>
00110 template <unsigned int MAT_ALIGNMENT>
00111 viennacl::vector<SCALARTYPE, ALIGNMENT> &
00112 viennacl::vector<SCALARTYPE, ALIGNMENT>::operator=(const viennacl::vector_expression< const hankel_matrix<SCALARTYPE, MAT_ALIGNMENT>,
00113 const viennacl::vector<SCALARTYPE, ALIGNMENT>,
00114 viennacl::op_prod> & proxy)
00115 {
00116
00117 if (proxy.rhs().handle() == this->handle())
00118 {
00119 viennacl::vector<SCALARTYPE, ALIGNMENT> result(proxy.rhs().size());
00120 viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
00121 *this = result;
00122 return *this;
00123 }
00124 else
00125 {
00126 viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), *this);
00127 return *this;
00128 }
00129 return *this;
00130 }
00131
00132
00137 template <typename SCALARTYPE, unsigned int ALIGNMENT>
00138 template <unsigned int MAT_ALIGNMENT>
00139 viennacl::vector<SCALARTYPE, ALIGNMENT> &
00140 viennacl::vector<SCALARTYPE, ALIGNMENT>::operator+=(const vector_expression< const hankel_matrix<SCALARTYPE, MAT_ALIGNMENT>,
00141 const vector<SCALARTYPE, ALIGNMENT>,
00142 op_prod> & proxy)
00143 {
00144 vector<SCALARTYPE, ALIGNMENT> result(proxy.lhs().size1());
00145 viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
00146 *this += result;
00147 return *this;
00148 }
00149
00154 template <typename SCALARTYPE, unsigned int ALIGNMENT>
00155 template <unsigned int MAT_ALIGNMENT>
00156 viennacl::vector<SCALARTYPE, ALIGNMENT> &
00157 viennacl::vector<SCALARTYPE, ALIGNMENT>::operator-=(const vector_expression< const hankel_matrix<SCALARTYPE, MAT_ALIGNMENT>,
00158 const vector<SCALARTYPE, ALIGNMENT>,
00159 op_prod> & proxy)
00160 {
00161 vector<SCALARTYPE, ALIGNMENT> result(proxy.get_lhs().size1());
00162 viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
00163 *this -= result;
00164 return *this;
00165 }
00166
00167
00168
00173 template <typename SCALARTYPE, unsigned int ALIGNMENT>
00174 template <unsigned int MAT_ALIGNMENT>
00175 viennacl::vector<SCALARTYPE, ALIGNMENT>
00176 viennacl::vector<SCALARTYPE, ALIGNMENT>::operator+(const vector_expression< const hankel_matrix<SCALARTYPE, MAT_ALIGNMENT>,
00177 const vector<SCALARTYPE, ALIGNMENT>,
00178 op_prod> & proxy)
00179 {
00180 assert(proxy.get_lhs().size1() == size());
00181 vector<SCALARTYPE, ALIGNMENT> result(size());
00182 viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
00183 result += *this;
00184 return result;
00185 }
00186
00191 template <typename SCALARTYPE, unsigned int ALIGNMENT>
00192 template <unsigned int MAT_ALIGNMENT>
00193 viennacl::vector<SCALARTYPE, ALIGNMENT>
00194 viennacl::vector<SCALARTYPE, ALIGNMENT>::operator-(const vector_expression< const hankel_matrix<SCALARTYPE, MAT_ALIGNMENT>,
00195 const vector<SCALARTYPE, ALIGNMENT>,
00196 op_prod> & proxy)
00197 {
00198 assert(proxy.get_lhs().size1() == size());
00199 vector<SCALARTYPE, ALIGNMENT> result(size());
00200 viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
00201 result = *this - result;
00202 return result;
00203 }
00204
00205 }
00206
00207
00208 #endif