ViennaCL - The Vienna Computing Library  1.5.2
circulant_matrix_operations.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_CIRCULANT_MATRIX_OPERATIONS_HPP_
2 #define VIENNACL_LINALG_CIRCULANT_MATRIX_OPERATIONS_HPP_
3 
4 /* =========================================================================
5  Copyright (c) 2010-2014, Institute for Microelectronics,
6  Institute for Analysis and Scientific Computing,
7  TU Wien.
8  Portions of this software are copyright by UChicago Argonne, LLC.
9 
10  -----------------
11  ViennaCL - The Vienna Computing Library
12  -----------------
13 
14  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15 
16  (A list of authors and contributors can be found in the PDF manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
25 #include "viennacl/forwards.h"
26 #include "viennacl/ocl/backend.hpp"
27 #include "viennacl/scalar.hpp"
28 #include "viennacl/vector.hpp"
29 #include "viennacl/tools/tools.hpp"
30 #include "viennacl/fft.hpp"
31 //#include "viennacl/linalg/kernels/coordinate_matrix_kernels.h"
32 
33 namespace viennacl
34 {
35  namespace linalg
36  {
37 
38  // A * x
39 
48  template<class SCALARTYPE, unsigned int ALIGNMENT>
52  {
53  assert(mat.size1() == result.size());
54  assert(mat.size2() == vec.size());
55  //result.clear();
56 
57  //std::cout << "prod(circulant_matrix" << ALIGNMENT << ", vector) called with internal_nnz=" << mat.internal_nnz() << std::endl;
58 
59  viennacl::vector<SCALARTYPE> circ(mat.elements().size() * 2);
60  viennacl::detail::fft::real_to_complex(mat.elements(), circ, mat.elements().size());
61 
62  viennacl::vector<SCALARTYPE> tmp(vec.size() * 2);
63  viennacl::vector<SCALARTYPE> tmp2(vec.size() * 2);
64 
65  viennacl::detail::fft::real_to_complex(vec, tmp, vec.size());
66  viennacl::linalg::convolve(circ, tmp, tmp2);
67  viennacl::detail::fft::complex_to_real(tmp2, result, vec.size());
68 
69  }
70 
71  } //namespace linalg
72 
73 
74 } //namespace viennacl
75 
76 
77 #endif
Various little tools used here and there in ViennaCL.
This file provides the forward declarations for the main types used within ViennaCL.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
viennacl::vector< SCALARTYPE, ALIGNMENT > & elements()
Returns an internal viennacl::vector, which represents a circulant matrix elements.
Definition: circulant_matrix.hpp:86
size_type size() const
Returns the length of the vector (cf. std::vector)
Definition: vector.hpp:837
Implementations of the OpenCL backend, where all contexts are stored in.
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
vcl_size_t size2() const
Returns the number of columns of the matrix.
Definition: circulant_matrix.hpp:97
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
All routines related to the Fast Fourier Transform. Experimental.
vcl_size_t size1() const
Returns the number of rows of the matrix.
Definition: circulant_matrix.hpp:92
A Circulant matrix class.
Definition: circulant_matrix.hpp:41
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
Implementation of the ViennaCL scalar class.