ViennaCL - The Vienna Computing Library  1.7.0
Free open-source GPU-accelerated linear algebra and solver library.
matrix_proxy.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_MATRIX_PROXY_HPP_
2 #define VIENNACL_MATRIX_PROXY_HPP_
3 
4 /* =========================================================================
5  Copyright (c) 2010-2015, 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 manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
25 #include "viennacl/forwards.h"
26 #include "viennacl/range.hpp"
27 #include "viennacl/slice.hpp"
29 
30 namespace viennacl
31 {
32 
37 template<typename MatrixType>
38 class matrix_range : public matrix_base<typename MatrixType::cpu_value_type>
39 {
40  typedef matrix_base<typename MatrixType::cpu_value_type> base_type;
41  typedef matrix_range<MatrixType> self_type;
42 
43 public:
44  typedef typename MatrixType::value_type value_type;
49  typedef value_type reference;
50  typedef const value_type & const_reference;
51 
52 
53  matrix_range(MatrixType const & A,
54  range const & row_range,
55  range const & col_range) : base_type(const_cast<handle_type &>(A.handle()),
56  row_range.size(), row_range.start() * A.stride1() + A.start1(), A.stride1(), A.internal_size1(),
57  col_range.size(), col_range.start() * A.stride2() + A.start2(), A.stride2(), A.internal_size2(),
58  A.row_major()) {}
59 
60  matrix_range(self_type const & A,
61  range const & row_range,
62  range const & col_range) : base_type(const_cast<handle_type &>(A.handle()),
63  row_range.size(), row_range.start() * A.stride1() + A.start1(), A.stride1(), A.internal_size1(),
64  col_range.size(), col_range.start() * A.stride2() + A.start2(), A.stride2(), A.internal_size2(),
65  A.row_major()) {}
66 
67 
68  matrix_range(self_type const & other) : base_type(const_cast<handle_type &>(other.handle()),
69  other.size1(), other.start1(), other.stride1(), other.internal_size1(),
70  other.size2(), other.start2(), other.stride2(), other.internal_size2(),
71  other.row_major()) {}
72 
73  using base_type::operator=;
74 
75  // the following are needed for Visual Studio:
76  template<typename OtherNumericT, typename F>
78 
79  template<typename OtherNumericT, typename F>
81 
82  template<typename OtherNumericT, typename F>
84 };
85 
86 template<typename MatrixType>
87 class matrix_range<matrix_range<MatrixType> > : public matrix_base<typename MatrixType::cpu_value_type>
88 {
90 public:
92 
93  matrix_range(MatrixType const & A,
94  range const & row_range,
95  range const & col_range) : base_type(const_cast<handle_type &>(A.handle()),
96  row_range.size(), row_range.start() * A.stride1() + A.start1(), A.stride1(), A.internal_size1(),
97  col_range.size(), col_range.start() * A.stride2() + A.start2(), A.stride2(), A.internal_size2(),
98  A.row_major()) {}
99 
101  range const & row_range,
102  range const & col_range) : base_type(const_cast<handle_type &>(A.handle()),
103  row_range.size(), row_range.start() * A.stride1() + A.start1(), A.stride1(), A.internal_size1(),
104  col_range.size(), col_range.start() * A.stride2() + A.start2(), A.stride2(), A.internal_size2(),
105  A.row_major()) {}
106 };
107 
111 
112 //row_major:
113 template<typename CPUMatrixT, typename NumericT>
114 void copy(const CPUMatrixT & cpu_matrix,
115  matrix_range<matrix<NumericT, row_major, 1> > & gpu_matrix_range )
116 {
117  assert( (cpu_matrix.size1() == gpu_matrix_range.size1())
118  && (cpu_matrix.size2() == gpu_matrix_range.size2())
119  && bool("Matrix size mismatch!"));
120 
121  if ( gpu_matrix_range.start2() != 0)
122  {
123  std::vector<NumericT> entries(gpu_matrix_range.size2());
124 
125  //copy each stride separately:
126  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
127  {
128  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
129  entries[j] = cpu_matrix(i,j);
130 
131  vcl_size_t start_offset = (gpu_matrix_range.start1() + i) * gpu_matrix_range.internal_size2() + gpu_matrix_range.start2();
132  vcl_size_t num_entries = gpu_matrix_range.size2();
133  viennacl::backend::memory_write(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
134  //std::cout << "Strided copy worked!" << std::endl;
135  }
136  }
137  else
138  {
139  //full block can be copied:
140  std::vector<NumericT> entries(gpu_matrix_range.size1()*gpu_matrix_range.internal_size2());
141 
142  //copy each stride separately:
143  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
144  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
145  entries[i*gpu_matrix_range.internal_size2() + j] = cpu_matrix(i,j);
146 
147  vcl_size_t start_offset = gpu_matrix_range.start1() * gpu_matrix_range.internal_size2();
148  vcl_size_t num_entries = gpu_matrix_range.size1() * gpu_matrix_range.internal_size2();
149  viennacl::backend::memory_write(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
150  //std::cout << "Block copy worked!" << std::endl;
151  }
152 }
153 
154 //column_major:
155 template<typename CPUMatrixT, typename NumericT>
156 void copy(const CPUMatrixT & cpu_matrix,
157  matrix_range<matrix<NumericT, column_major, 1> > & gpu_matrix_range )
158 {
159  assert( (cpu_matrix.size1() == gpu_matrix_range.size1())
160  && (cpu_matrix.size2() == gpu_matrix_range.size2())
161  && bool("Matrix size mismatch!"));
162 
163  if ( gpu_matrix_range.start1() != 0 || gpu_matrix_range.size1() != gpu_matrix_range.size1())
164  {
165  std::vector<NumericT> entries(gpu_matrix_range.size1());
166 
167  //copy each stride separately:
168  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
169  {
170  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
171  entries[i] = cpu_matrix(i,j);
172 
173  vcl_size_t start_offset = (gpu_matrix_range.start2() + j) * gpu_matrix_range.internal_size1() + gpu_matrix_range.start1();
174  vcl_size_t num_entries = gpu_matrix_range.size1();
175  viennacl::backend::memory_write(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
176  //std::cout << "Strided copy worked!" << std::endl;
177  }
178  }
179  else
180  {
181  //full block can be copied:
182  std::vector<NumericT> entries(gpu_matrix_range.internal_size1()*gpu_matrix_range.size2());
183 
184  //copy each stride separately:
185  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
186  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
187  entries[i + j*gpu_matrix_range.internal_size1()] = cpu_matrix(i,j);
188 
189  vcl_size_t start_offset = gpu_matrix_range.start2() * gpu_matrix_range.internal_size1();
190  vcl_size_t num_entries = gpu_matrix_range.internal_size1() * gpu_matrix_range.size2();
191  viennacl::backend::memory_write(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
192  //std::cout << "Block copy worked!" << std::endl;
193  }
194 
195 }
196 
197 
201 
202 
203 //row_major:
204 template<typename CPUMatrixT, typename NumericT>
205 void copy(matrix_range<matrix<NumericT, row_major, 1> > const & gpu_matrix_range,
206  CPUMatrixT & cpu_matrix)
207 {
208  assert( (cpu_matrix.size1() == gpu_matrix_range.size1())
209  && (cpu_matrix.size2() == gpu_matrix_range.size2())
210  && bool("Matrix size mismatch!"));
211 
212  if ( gpu_matrix_range.start2() != 0)
213  {
214  std::vector<NumericT> entries(gpu_matrix_range.size2());
215 
216  //copy each stride separately:
217  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
218  {
219  vcl_size_t start_offset = (gpu_matrix_range.start1() + i) * gpu_matrix_range.internal_size2() + gpu_matrix_range.start2();
220  vcl_size_t num_entries = gpu_matrix_range.size2();
221  viennacl::backend::memory_read(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
222  //std::cout << "Strided copy worked!" << std::endl;
223 
224  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
225  cpu_matrix(i,j) = entries[j];
226  }
227  }
228  else
229  {
230  //full block can be copied:
231  std::vector<NumericT> entries(gpu_matrix_range.size1()*gpu_matrix_range.internal_size2());
232 
233  vcl_size_t start_offset = gpu_matrix_range.start1() * gpu_matrix_range.internal_size2();
234  viennacl::backend::memory_read(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*entries.size(), &(entries[0]));
235  //std::cout << "Block copy worked!" << std::endl;
236 
237  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
238  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
239  cpu_matrix(i,j) = entries[i*gpu_matrix_range.internal_size2() + j];
240  }
241 
242 }
243 
244 
245 //column_major:
246 template<typename CPUMatrixT, typename NumericT>
247 void copy(matrix_range<matrix<NumericT, column_major, 1> > const & gpu_matrix_range,
248  CPUMatrixT & cpu_matrix)
249 {
250  assert( (cpu_matrix.size1() == gpu_matrix_range.size1())
251  && (cpu_matrix.size2() == gpu_matrix_range.size2())
252  && bool("Matrix size mismatch!"));
253 
254  if ( gpu_matrix_range.start1() != 0)
255  {
256  std::vector<NumericT> entries(gpu_matrix_range.size1());
257 
258  //copy each stride separately:
259  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
260  {
261  vcl_size_t start_offset = (gpu_matrix_range.start2() + j) * gpu_matrix_range.internal_size1() + gpu_matrix_range.start1();
262  vcl_size_t num_entries = gpu_matrix_range.size1();
263  viennacl::backend::memory_read(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
264  //std::cout << "Strided copy worked!" << std::endl;
265 
266  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
267  cpu_matrix(i,j) = entries[i];
268  }
269  }
270  else
271  {
272  //full block can be copied:
273  std::vector<NumericT> entries(gpu_matrix_range.internal_size1()*gpu_matrix_range.size2());
274 
275  //copy each stride separately:
276  vcl_size_t start_offset = gpu_matrix_range.start2() * gpu_matrix_range.internal_size1();
277  vcl_size_t num_entries = gpu_matrix_range.internal_size1() * gpu_matrix_range.size2();
278  viennacl::backend::memory_read(gpu_matrix_range.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
279  //std::cout << "Block copy worked!" << std::endl;
280 
281  for (vcl_size_t i=0; i < gpu_matrix_range.size1(); ++i)
282  for (vcl_size_t j=0; j < gpu_matrix_range.size2(); ++j)
283  cpu_matrix(i,j) = entries[i + j*gpu_matrix_range.internal_size1()];
284  }
285 
286 }
287 
288 
289 //
290 // Convenience function
291 //
292 template<typename MatrixType>
293 matrix_range<MatrixType> project(MatrixType const & A, viennacl::range const & r1, viennacl::range const & r2)
294 {
295  assert(r1.size() <= A.size1() && r2.size() <= A.size2() && bool("Size of range invalid!"));
296 
297  return matrix_range<MatrixType>(A, r1, r2);
298 }
299 
300 
301 template<typename MatrixType>
303 {
304  assert(r1.size() <= A.size1() && r2.size() <= A.size2() && bool("Size of range invalid!"));
305 
306  return matrix_range<MatrixType>(A, r1, r2);
307 }
308 
309 
310 
311 
312 //
313 //
314 //
316 //
317 //
318 //
319 
320 
321 
322 
323 
328 template<typename MatrixType>
329 class matrix_slice : public matrix_base<typename MatrixType::cpu_value_type>
330 {
331  typedef matrix_base<typename MatrixType::cpu_value_type> base_type;
332  typedef matrix_slice<MatrixType> self_type;
333 
334 public:
335 
336  typedef typename MatrixType::value_type value_type;
341  typedef value_type reference;
342  typedef const value_type & const_reference;
343 
344  matrix_slice(MatrixType const & A,
345  slice const & row_slice,
346  slice const & col_slice) : base_type(const_cast<handle_type &>(A.handle()),
347  row_slice.size(), row_slice.start() * A.stride1() + A.start1(), row_slice.stride() * A.stride1(), A.internal_size1(),
348  col_slice.size(), col_slice.start() * A.stride2() + A.start2(), col_slice.stride() * A.stride2(), A.internal_size2(),
349  A.row_major()) {}
350 
351  matrix_slice(self_type const & A,
352  slice const & row_slice,
353  slice const & col_slice) : base_type(const_cast<handle_type &>(A.handle()),
354  row_slice.size(), row_slice.start() * A.stride1() + A.start1(), row_slice.stride() * A.stride1(), A.internal_size1(),
355  col_slice.size(), col_slice.start() * A.stride2() + A.start2(), col_slice.stride() * A.stride2(), A.internal_size2(),
356  A.row_major()) {}
357 
358 
359  matrix_slice(self_type const & other) : base_type(const_cast<handle_type &>(other.handle()),
360  other.size1(), other.start1(), other.stride1(), other.internal_size1(),
361  other.size2(), other.start2(), other.stride2(), other.internal_size2(),
362  other.row_major()) {}
363 
364  using base_type::operator=;
365 
366  // the following are needed for Visual Studio:
367  template<typename OtherNumericT, typename F>
369 
370  template<typename OtherNumericT, typename F>
372 
373  template<typename OtherNumericT, typename F>
375 };
376 
377 template<typename MatrixType>
378 class matrix_slice<matrix_range<MatrixType> > : public matrix_base<typename MatrixType::cpu_value_type>
379 {
381 public:
383 
384  matrix_slice(MatrixType const & A,
385  slice const & row_slice,
386  slice const & col_slice) : base_type(const_cast<handle_type &>(A.handle()),
387  row_slice.size(), row_slice.start() * A.stride1() + A.start1(), row_slice.stride() * A.stride1(), A.internal_size1(),
388  col_slice.size(), col_slice.start() * A.stride2() + A.start2(), col_slice.stride() * A.stride2(), A.internal_size2(),
389  A.row_major()) {}
390 
392  slice const & row_slice,
393  slice const & col_slice) : base_type(const_cast<handle_type &>(A.handle()),
394  row_slice.size(), row_slice.start() * A.stride1() + A.start1(), row_slice.stride() * A.stride1(), A.internal_size1(),
395  col_slice.size(), col_slice.start() * A.stride2() + A.start2(), col_slice.stride() * A.stride2(), A.internal_size2(),
396  A.row_major()) {}
397 };
398 
399 
403 
404 //row_major:
405 template<typename CPUMatrixT, typename NumericT>
406 void copy(const CPUMatrixT & cpu_matrix,
407  matrix_slice<matrix<NumericT, row_major, 1> > & gpu_matrix_slice )
408 {
409  assert( (cpu_matrix.size1() == gpu_matrix_slice.size1())
410  && (cpu_matrix.size2() == gpu_matrix_slice.size2())
411  && bool("Matrix size mismatch!"));
412 
413  if ( (gpu_matrix_slice.size1() > 0) && (gpu_matrix_slice.size1() > 0) )
414  {
415  vcl_size_t num_entries = gpu_matrix_slice.size2() * gpu_matrix_slice.stride2(); //no. of entries per stride
416 
417  std::vector<NumericT> entries(num_entries);
418 
419  //copy each stride separately:
420  for (vcl_size_t i=0; i < gpu_matrix_slice.size1(); ++i)
421  {
422  vcl_size_t start_offset = (gpu_matrix_slice.start1() + i * gpu_matrix_slice.stride1()) * gpu_matrix_slice.internal_size2() + gpu_matrix_slice.start2();
423  viennacl::backend::memory_read(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
424 
425  for (vcl_size_t j=0; j < gpu_matrix_slice.size2(); ++j)
426  entries[j * gpu_matrix_slice.stride2()] = cpu_matrix(i,j);
427 
428  viennacl::backend::memory_write(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
429  }
430  }
431 }
432 
433 //column_major:
434 template<typename CPUMatrixT, typename NumericT>
435 void copy(const CPUMatrixT & cpu_matrix,
436  matrix_slice<matrix<NumericT, column_major, 1> > & gpu_matrix_slice )
437 {
438  assert( (cpu_matrix.size1() == gpu_matrix_slice.size1())
439  && (cpu_matrix.size2() == gpu_matrix_slice.size2())
440  && bool("Matrix size mismatch!"));
441 
442 
443  if ( (gpu_matrix_slice.size1() > 0) && (gpu_matrix_slice.size1() > 0) )
444  {
445  vcl_size_t num_entries = gpu_matrix_slice.size1() * gpu_matrix_slice.stride1(); //no. of entries per stride
446 
447  std::vector<NumericT> entries(num_entries);
448 
449  //copy each column stride separately:
450  for (vcl_size_t j=0; j < gpu_matrix_slice.size2(); ++j)
451  {
452  vcl_size_t start_offset = gpu_matrix_slice.start1() + (gpu_matrix_slice.start2() + j * gpu_matrix_slice.stride2()) * gpu_matrix_slice.internal_size1();
453 
454  viennacl::backend::memory_read(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
455 
456  for (vcl_size_t i=0; i < gpu_matrix_slice.size1(); ++i)
457  entries[i * gpu_matrix_slice.stride1()] = cpu_matrix(i,j);
458 
459  viennacl::backend::memory_write(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
460  }
461  }
462 
463 }
464 
465 
469 
470 
471 //row_major:
472 template<typename CPUMatrixT, typename NumericT>
473 void copy(matrix_slice<matrix<NumericT, row_major, 1> > const & gpu_matrix_slice,
474  CPUMatrixT & cpu_matrix)
475 {
476  assert( (cpu_matrix.size1() == gpu_matrix_slice.size1())
477  && (cpu_matrix.size2() == gpu_matrix_slice.size2())
478  && bool("Matrix size mismatch!"));
479 
480  if ( (gpu_matrix_slice.size1() > 0) && (gpu_matrix_slice.size1() > 0) )
481  {
482  vcl_size_t num_entries = gpu_matrix_slice.size2() * gpu_matrix_slice.stride2(); //no. of entries per stride
483 
484  std::vector<NumericT> entries(num_entries);
485 
486  //copy each stride separately:
487  for (vcl_size_t i=0; i < gpu_matrix_slice.size1(); ++i)
488  {
489  vcl_size_t start_offset = (gpu_matrix_slice.start1() + i * gpu_matrix_slice.stride1()) * gpu_matrix_slice.internal_size2() + gpu_matrix_slice.start2();
490 
491  viennacl::backend::memory_read(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
492 
493  for (vcl_size_t j=0; j < gpu_matrix_slice.size2(); ++j)
494  cpu_matrix(i,j) = entries[j * gpu_matrix_slice.stride2()];
495  }
496  }
497 
498 }
499 
500 
501 //column_major:
502 template<typename CPUMatrixT, typename NumericT>
503 void copy(matrix_slice<matrix<NumericT, column_major, 1> > const & gpu_matrix_slice,
504  CPUMatrixT & cpu_matrix)
505 {
506  assert( (cpu_matrix.size1() == gpu_matrix_slice.size1())
507  && (cpu_matrix.size2() == gpu_matrix_slice.size2())
508  && bool("Matrix size mismatch!"));
509 
510  if ( (gpu_matrix_slice.size1() > 0) && (gpu_matrix_slice.size1() > 0) )
511  {
512  vcl_size_t num_entries = gpu_matrix_slice.size1() * gpu_matrix_slice.stride1(); //no. of entries per stride
513 
514  std::vector<NumericT> entries(num_entries);
515 
516  //copy each column stride separately:
517  for (vcl_size_t j=0; j < gpu_matrix_slice.size2(); ++j)
518  {
519  vcl_size_t start_offset = gpu_matrix_slice.start1() + (gpu_matrix_slice.start2() + j * gpu_matrix_slice.stride2()) * gpu_matrix_slice.internal_size1();
520 
521  viennacl::backend::memory_read(gpu_matrix_slice.handle(), sizeof(NumericT)*start_offset, sizeof(NumericT)*num_entries, &(entries[0]));
522 
523  for (vcl_size_t i=0; i < gpu_matrix_slice.size1(); ++i)
524  cpu_matrix(i,j) = entries[i * gpu_matrix_slice.stride1()];
525  }
526  }
527 
528 }
529 
530 
531 //
532 // Convenience function
533 //
534 template<typename MatrixType>
535 matrix_slice<MatrixType> project(MatrixType const & A, viennacl::slice const & r1, viennacl::slice const & r2)
536 {
537  assert(r1.size() <= A.size1() && r2.size() <= A.size2() && bool("Size of slice invalid!"));
538 
539  return matrix_slice<MatrixType>(A, r1, r2);
540 }
541 
542 template<typename MatrixType>
544 {
545  assert(r1.size() <= A.size1() && r2.size() <= A.size2() && bool("Size of slice invalid!"));
546 
547  return matrix_slice<MatrixType>(A, r1, r2);
548 }
549 
550 template<typename MatrixType>
552 {
553  assert(r1.size() <= A.size1() && r2.size() <= A.size2() && bool("Size of slice invalid!"));
554 
555  return matrix_slice<MatrixType>(A, r1, r2);
556 }
557 
558 // TODO: Allow mix of range/slice
559 
560 }
561 
562 #endif
viennacl::tools::shared_ptr< char > handle_type
Definition: cpu_ram.hpp:40
base_type & operator=(viennacl::matrix_slice< viennacl::matrix< OtherNumericT, F > > const &B)
matrix_slice(MatrixType const &A, slice const &row_slice, slice const &col_slice)
void memory_write(mem_handle &dst_buffer, vcl_size_t dst_offset, vcl_size_t bytes_to_write, const void *ptr, bool async=false)
Writes data from main RAM identified by 'ptr' to the buffer identified by 'dst_buffer'.
Definition: memory.hpp:220
base_type & operator=(viennacl::matrix< OtherNumericT, F > const &B)
matrix_range(matrix_range< MatrixType > const &A, range const &row_range, range const &col_range)
Class for representing strided submatrices of a bigger matrix A.
Definition: forwards.h:443
self_type & operator=(const self_type &other)
Definition: matrix.hpp:262
range::size_type size_type
size_type size() const
Definition: slice.hpp:56
MatrixType::value_type value_type
size_type size() const
Definition: range.hpp:56
matrix_range(MatrixType const &A, range const &row_range, range const &col_range)
MatrixType::handle_type handle_type
size_type stride2() const
Returns the number of columns.
Definition: matrix_def.hpp:234
result_of::size_type< viennacl::vector_base< T > >::type stride(viennacl::vector_base< T > const &s)
Definition: stride.hpp:45
This file provides the forward declarations for the main types used within ViennaCL.
A dense matrix class.
Definition: forwards.h:375
void memory_read(mem_handle const &src_buffer, vcl_size_t src_offset, vcl_size_t bytes_to_read, void *ptr, bool async=false)
Reads data from a buffer back to main RAM.
Definition: memory.hpp:261
range::difference_type difference_type
Forward declaration of dense matrix classes.
viennacl::result_of::cpu_value_type< value_type >::type cpu_value_type
matrix_slice(self_type const &other)
float NumericT
Definition: bisect.cpp:40
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:34
MatrixType::value_type value_type
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:235
range::size_type size_type
matrix_range(self_type const &A, range const &row_range, range const &col_range)
result_of::size_type< T >::type start(T const &obj)
Definition: start.hpp:44
matrix_slice(MatrixType const &A, slice const &row_slice, slice const &col_slice)
range::difference_type difference_type
const value_type & const_reference
size_type stride1() const
Returns the number of rows.
Definition: matrix_def.hpp:232
matrix_range< MatrixType > project(MatrixType const &A, viennacl::range const &r1, viennacl::range const &r2)
matrix_range(self_type const &other)
std::size_t vcl_size_t
Definition: forwards.h:75
size_type size2() const
Returns the number of columns.
Definition: matrix_def.hpp:226
handle_type & handle()
Returns the OpenCL handle, non-const-version.
Definition: matrix_def.hpp:244
base_type & operator=(viennacl::matrix_slice< viennacl::matrix< OtherNumericT, F > > const &B)
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
Definition: result_of.hpp:271
size_type size1() const
Returns the number of rows.
Definition: matrix_def.hpp:224
MatrixType::handle_type handle_type
DistanceT difference_type
Definition: range.hpp:43
base_type & operator=(viennacl::matrix< OtherNumericT, F > const &B)
matrix_slice(self_type const &A, slice const &row_slice, slice const &col_slice)
void copy(std::vector< NumericT > &cpu_vec, circulant_matrix< NumericT, AlignmentV > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
Implementation of a slice object for use with proxy objects.
A range class that refers to an interval [start, stop), where 'start' is included, and 'stop' is excluded.
Definition: forwards.h:424
base_type & operator=(viennacl::matrix_range< viennacl::matrix< OtherNumericT, F > > const &B)
Implementation of a range object for use with proxy objects.
size_type start2() const
Returns the number of columns.
Definition: matrix_def.hpp:230
size_type internal_size2() const
Returns the internal number of columns. Usually required for launching OpenCL kernels only...
Definition: matrix_def.hpp:240
Class for representing non-strided submatrices of a bigger matrix A.
Definition: forwards.h:440
size_type internal_size1() const
Returns the internal number of rows. Usually required for launching OpenCL kernels only...
Definition: matrix_def.hpp:238
viennacl::result_of::cpu_value_type< value_type >::type cpu_value_type
const value_type & const_reference
A slice class that refers to an interval [start, stop), where 'start' is included, and 'stop' is excluded.
Definition: forwards.h:429
A tag for row-major storage of a dense matrix.
Definition: forwards.h:304
matrix_range(MatrixType const &A, range const &row_range, range const &col_range)
size_type start1() const
Returns the number of rows.
Definition: matrix_def.hpp:228
base_type & operator=(viennacl::matrix_range< viennacl::matrix< OtherNumericT, F > > const &B)
matrix_slice(matrix_slice< MatrixType > const &A, slice const &row_slice, slice const &col_slice)