1 #ifndef VIENNACL_HANKEL_MATRIX_HPP
2 #define VIENNACL_HANKEL_MATRIX_HPP
41 template<
class SCALARTYPE,
unsigned int ALIGNMENT>
62 assert(rows == cols &&
bool(
"Hankel matrix must be square!"));
74 elements_.resize(sz, preserve);
81 handle_type
const &
handle()
const {
return elements_.handle(); }
116 assert(row_index <
size1() && col_index <
size2() &&
bool(
"Invalid access"));
118 return elements_(
size1() - row_index - 1, col_index);
129 elements_ += that.elements();
137 toeplitz_matrix<SCALARTYPE, ALIGNMENT> elements_;
146 template <
typename SCALARTYPE,
unsigned int ALIGNMENT>
149 assert((gpu_mat.size1() * 2 - 1) == cpu_vec.size() && bool(
"Size mismatch"));
151 copy(cpu_vec, gpu_mat.elements());
160 template <
typename SCALARTYPE,
unsigned int ALIGNMENT>
163 assert((gpu_mat.size1() * 2 - 1) == cpu_vec.size() && bool(
"Size mismatch"));
165 copy(gpu_mat.elements(), cpu_vec);
174 template <
typename SCALARTYPE,
unsigned int ALIGNMENT,
typename MATRIXTYPE>
181 std::vector<SCALARTYPE> tmp(size * 2 - 1);
186 com_dst(i, j) = tmp[i + j];
195 template <
typename SCALARTYPE,
unsigned int ALIGNMENT,
typename MATRIXTYPE>
198 assert( (han_dst.size1() == 0 ||
viennacl::traits::size1(com_src) == han_dst.size1()) &&
bool(
"Size mismatch") );
199 assert( (han_dst.size2() == 0 ||
viennacl::traits::size2(com_src) == han_dst.size2()) &&
bool(
"Size mismatch") );
204 std::vector<SCALARTYPE> tmp(2*size - 1);
207 tmp[i] = com_src(0, i);
210 tmp[size + i - 1] = com_src(size - 1, i);
224 template<
class SCALARTYPE,
unsigned int ALIGNMENT>
225 std::ostream & operator<<(std::ostream & s, hankel_matrix<SCALARTYPE, ALIGNMENT>& gpu_matrix)
228 std::vector<SCALARTYPE> tmp(2*size - 1);
229 copy(gpu_matrix, tmp);
230 s <<
"[" << size <<
"," << size <<
"](";
237 if(j < (size - 1)) s <<
",";
256 template <
typename T,
unsigned int A>
257 struct op_executor<vector_base<T>, op_assign, vector_expression<const hankel_matrix<T, A>, const vector_base<T>, op_prod> >
259 static void apply(vector_base<T> & lhs, vector_expression<
const hankel_matrix<T, A>,
const vector_base<T>, op_prod>
const & rhs)
273 template <
typename T,
unsigned int A>
274 struct op_executor<vector_base<T>, op_inplace_add, vector_expression<const hankel_matrix<T, A>, const vector_base<T>, op_prod> >
276 static void apply(vector_base<T> & lhs, vector_expression<
const hankel_matrix<T, A>,
const vector_base<T>, op_prod>
const & rhs)
284 template <
typename T,
unsigned int A>
285 struct op_executor<vector_base<T>, op_inplace_sub, vector_expression<const hankel_matrix<T, A>, const vector_base<T>, op_prod> >
287 static void apply(vector_base<T> & lhs, vector_expression<
const hankel_matrix<T, A>,
const vector_base<T>, op_prod>
const & rhs)
297 template <
typename T,
unsigned int A,
typename LHS,
typename RHS,
typename OP>
298 struct op_executor<vector_base<T>, op_assign, vector_expression<const hankel_matrix<T, A>, const vector_expression<const LHS, const RHS, OP>, op_prod> >
300 static void apply(vector_base<T> & lhs, vector_expression<
const hankel_matrix<T, A>,
const vector_expression<const LHS, const RHS, OP>, op_prod>
const & rhs)
308 template <
typename T,
unsigned int A,
typename LHS,
typename RHS,
typename OP>
309 struct op_executor<vector_base<T>, op_inplace_add, vector_expression<const hankel_matrix<T, A>, vector_expression<const LHS, const RHS, OP>, op_prod> >
311 static void apply(vector_base<T> & lhs, vector_expression<
const hankel_matrix<T, A>, vector_expression<const LHS, const RHS, OP>, op_prod>
const & rhs)
321 template <
typename T,
unsigned int A,
typename LHS,
typename RHS,
typename OP>
322 struct op_executor<vector_base<T>, op_inplace_sub, vector_expression<const hankel_matrix<T, A>, const vector_expression<const LHS, const RHS, OP>, op_prod> >
324 static void apply(vector_base<T> & lhs, vector_expression<
const hankel_matrix<T, A>,
const vector_expression<const LHS, const RHS, OP>, op_prod>
const & rhs)
340 #endif // VIENNACL_HANKEL_MATRIX_HPP
Implementations of operations using hankel_matrix. Experimental.
entry_proxy< SCALARTYPE > operator()(unsigned int row_index, unsigned int col_index)
Read-write access to a element of the matrix.
Definition: hankel_matrix.hpp:114
std::size_t vcl_size_t
Definition: forwards.h:58
scalar< typename viennacl::tools::CHECK_SCALAR_TEMPLATE_ARGUMENT< SCALARTYPE >::ResultType > value_type
Definition: hankel_matrix.hpp:46
A Hankel matrix class.
Definition: forwards.h:327
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
Definition: forwards.h:172
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:216
toeplitz_matrix< SCALARTYPE, ALIGNMENT > & elements()
Returns an internal viennacl::toeplitz_matrix, which represents a Hankel matrix elements.
Definition: hankel_matrix.hpp:87
This file provides the forward declarations for the main types used within ViennaCL.
vcl_size_t size2() const
Returns the number of columns of the matrix.
Definition: hankel_matrix.hpp:98
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
Definition: size.hpp:245
hankel_matrix< SCALARTYPE, ALIGNMENT > & operator+=(hankel_matrix< SCALARTYPE, ALIGNMENT > &that)
+= operation for Hankel matrices
Definition: hankel_matrix.hpp:127
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:144
A proxy class for a single element of a vector or matrix. This proxy should not be noticed by end-use...
Definition: forwards.h:178
hankel_matrix()
The default constructor. Does not allocate any memory.
Definition: hankel_matrix.hpp:52
A Toeplitz matrix class.
Definition: forwards.h:330
void copy(std::vector< SCALARTYPE > &cpu_vec, circulant_matrix< SCALARTYPE, ALIGNMENT > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
Definition: circulant_matrix.hpp:150
Implementations of the OpenCL backend, where all contexts are stored in.
handle_type const & handle() const
Returns the OpenCL handle.
Definition: hankel_matrix.hpp:81
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
viennacl::backend::mem_handle handle_type
Definition: hankel_matrix.hpp:45
vcl_size_t internal_size() const
Returns the internal size of matrix representtion. Usually required for launching OpenCL kernels only...
Definition: hankel_matrix.hpp:105
hankel_matrix(vcl_size_t rows, vcl_size_t cols)
Creates the matrix with the given size.
Definition: hankel_matrix.hpp:60
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
vcl_size_t size1() const
Returns the number of rows of the matrix.
Definition: hankel_matrix.hpp:93
All routines related to the Fast Fourier Transform. Experimental.
toeplitz_matrix< SCALARTYPE, ALIGNMENT > const & elements() const
Definition: hankel_matrix.hpp:88
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
Definition: mem_handle.hpp:62
void prod_impl(const matrix_base< NumericT, F > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Definition: matrix_operations.hpp:350
viennacl::backend::mem_handle & handle(T &obj)
Returns the generic memory handle of an object. Non-const version.
Definition: handle.hpp:41
void resize(vcl_size_t sz, bool preserve=true)
Resizes the matrix. Existing entries can be preserved.
Definition: hankel_matrix.hpp:72
Implementation of the toeplitz_matrix class for efficient manipulation of Toeplitz matrices...