1 #ifndef VIENNACL_HANKEL_MATRIX_HPP
2 #define VIENNACL_HANKEL_MATRIX_HPP
40 template<
class SCALARTYPE,
unsigned int ALIGNMENT>
50 viennacl::linalg::kernels::fft<SCALARTYPE, 1>::init();
59 explicit hankel_matrix(std::size_t rows, std::size_t cols) : elements_(rows, cols)
61 assert(rows == cols &&
"Hankel matrix must be square!");
62 viennacl::linalg::kernels::fft<SCALARTYPE, 1>::init();
71 void resize(
size_t sz,
bool preserve =
true)
73 elements_.resize(sz, preserve);
92 std::size_t
size1()
const {
return elements_.size1(); }
97 std::size_t
size2()
const {
return elements_.size2(); }
115 assert(row_index <
size1() && col_index <
size2() &&
"Invalid access");
117 return elements_(
size1() - row_index - 1, col_index);
136 toeplitz_matrix<SCALARTYPE, ALIGNMENT> elements_;
145 template <
typename SCALARTYPE,
unsigned int ALIGNMENT>
148 assert((gpu_mat.
size1() * 2 - 1) == cpu_vec.size() &&
"Size mismatch");
159 template <
typename SCALARTYPE,
unsigned int ALIGNMENT>
162 assert((gpu_mat.
size1() * 2 - 1) == cpu_vec.size() &&
"Size mismatch");
173 template <
typename SCALARTYPE,
unsigned int ALIGNMENT,
typename MATRIXTYPE>
177 assert(size == com_dst.size1() &&
"Size mismatch");
178 assert(size == com_dst.size2() &&
"Size mismatch");
179 std::vector<SCALARTYPE> tmp(size * 2 - 1);
182 for (std::size_t i = 0; i <
size; i++)
183 for (std::size_t j = 0; j <
size; j++)
184 com_dst(i, j) = tmp[i + j];
193 template <
typename SCALARTYPE,
unsigned int ALIGNMENT,
typename MATRIXTYPE>
197 assert(size == com_src.size1() &&
"Size mismatch");
198 assert(size == com_src.size2() &&
"Size mismatch");
200 std::vector<SCALARTYPE> tmp(2*size - 1);
202 for (std::size_t i = 0; i <
size; i++)
203 tmp[i] = com_src(0, i);
205 for (std::size_t i = 1; i <
size; i++)
206 tmp[size + i - 1] = com_src(size - 1, i);
220 template<
class SCALARTYPE,
unsigned int ALIGNMENT>
221 std::ostream & operator<<(std::ostream & s, hankel_matrix<SCALARTYPE, ALIGNMENT>& gpu_matrix)
223 std::size_t
size = gpu_matrix.size1();
224 std::vector<SCALARTYPE> tmp(2*size - 1);
225 copy(gpu_matrix, tmp);
226 s <<
"[" << size <<
"," << size <<
"](";
228 for(std::size_t i = 0; i <
size; i++) {
230 for(std::size_t j = 0; j <
size; j++) {
233 if(j < (size - 1)) s <<
",";
241 #endif // _VIENNACL_HANKEL_MATRIX_HPP