1 #ifndef VIENNACL_VANDERMONDE_MATRIX_HPP
2 #define VIENNACL_VANDERMONDE_MATRIX_HPP
40 template<
class SCALARTYPE,
unsigned int ALIGNMENT>
50 viennacl::linalg::kernels::fft<SCALARTYPE, 1>::init();
61 assert(rows == cols &&
"Vandermonde matrix must be square in this release!");
62 viennacl::linalg::kernels::fft<SCALARTYPE, 1>::init();
71 void resize(std::size_t sz,
bool preserve =
true) {
72 elements_.resize(sz, preserve);
91 std::size_t
size1()
const {
return elements_.size(); }
96 std::size_t
size2()
const {
return elements_.size(); }
113 return elements_[row_index];
123 SCALARTYPE
operator()(std::size_t row_index, std::size_t col_index)
const
125 assert(row_index <
size1() && col_index <
size2() &&
"Invalid access");
127 return pow(elements_[row_index], static_cast<int>(col_index));
143 template <
typename SCALARTYPE,
unsigned int ALIGNMENT>
146 assert(cpu_vec.size() == gpu_mat.
size1() &&
"Size mismatch");
156 template <
typename SCALARTYPE,
unsigned int ALIGNMENT>
159 assert(cpu_vec.size() == gpu_mat.
size1() &&
"Size mismatch");
169 template <
typename SCALARTYPE,
unsigned int ALIGNMENT,
typename MATRIXTYPE>
173 assert(size == com_dst.size1() &&
"Size mismatch");
174 assert(size == com_dst.size2() &&
"Size mismatch");
175 std::vector<SCALARTYPE> tmp(size);
176 copy(vander_src, tmp);
178 for(std::size_t i = 0; i <
size; i++) {
179 for(std::size_t j = 0; j <
size; j++) {
180 com_dst(i, j) = pow(tmp[i], static_cast<int>(j));
191 template <
typename SCALARTYPE,
unsigned int ALIGNMENT,
typename MATRIXTYPE>
195 assert(size == com_src.size1() &&
"Size mismatch");
196 assert(size == com_src.size2() &&
"Size mismatch");
197 std::vector<SCALARTYPE> tmp(size);
199 for(std::size_t i = 0; i <
size; i++)
200 tmp[i] = com_src(i, 1);
202 copy(tmp, vander_dst);
219 template<
class SCALARTYPE,
unsigned int ALIGNMENT>
220 std::ostream & operator<<(std::ostream& s, vandermonde_matrix<SCALARTYPE, ALIGNMENT>& gpu_matrix)
222 std::size_t
size = gpu_matrix.size1();
223 std::vector<SCALARTYPE> tmp(size);
224 copy(gpu_matrix, tmp);
225 s <<
"[" << size <<
"," << size <<
"](\n";
227 for(std::size_t i = 0; i <
size; i++) {
229 for(std::size_t j = 0; j <
size; j++) {
231 if(j < (size - 1)) s <<
",";
241 #endif // _VIENNACL_VANDERMONDE_MATRIX_HPP