1 #ifndef VIENNACL_FORWARDS_H
2 #define VIENNACL_FORWARDS_H
37 #ifdef VIENNACL_HAVE_UBLAS
38 #define VIENNACL_WITH_UBLAS
41 #ifdef VIENNACL_HAVE_EIGEN
42 #define VIENNACL_WITH_EIGEN
45 #ifdef VIENNACL_HAVE_MTL4
46 #define VIENNACL_WITH_MTL4
85 template <
typename OP>
89 template <
typename OP>
174 template <
typename LHS,
typename RHS,
typename OP>
177 template <
typename SCALARTYPE>
180 template <
typename LHS,
typename RHS,
typename OP>
183 template<
class SCALARTYPE,
unsigned int ALIGNMENT>
186 template<
class SCALARTYPE,
unsigned int ALIGNMENT>
189 template<
typename SCALARTYPE>
192 template <
typename SCALARTYPE>
195 template <
typename SCALARTYPE>
198 template <
typename SCALARTYPE>
201 template <
typename SCALARTYPE>
204 template<
class SCALARTYPE,
typename SizeType = vcl_
size_t,
typename DistanceType = vcl_ptrdiff_t>
207 template<
class SCALARTYPE,
unsigned int ALIGNMENT = 1>
210 template <
typename ScalarT>
214 template <
typename SCALARTYPE,
unsigned int ALIGNMENT,
typename CPU_ITERATOR>
215 void copy(CPU_ITERATOR
const & cpu_begin,
216 CPU_ITERATOR
const & cpu_end,
219 template <
typename SCALARTYPE,
unsigned int ALIGNMENT_SRC,
unsigned int ALIGNMENT_DEST>
224 template <
typename SCALARTYPE,
unsigned int ALIGNMENT_SRC,
unsigned int ALIGNMENT_DEST>
229 template <
typename SCALARTYPE,
unsigned int ALIGNMENT,
typename CPU_ITERATOR>
232 CPU_ITERATOR cpu_begin );
234 template <
typename CPU_ITERATOR,
typename SCALARTYPE,
unsigned int ALIGNMENT>
235 void fast_copy(CPU_ITERATOR
const & cpu_begin,
236 CPU_ITERATOR
const & cpu_end,
258 return i * num_cols + j;
275 return i + j * num_rows;
279 struct row_iteration;
280 struct col_iteration;
282 template <
typename LHS,
typename RHS,
typename OP>
289 template<
class SCALARTYPE,
typename F = row_major,
typename SizeType = vcl_
size_t,
typename DistanceType = vcl_ptrdiff_t>
292 template <
class SCALARTYPE,
typename F = row_major,
unsigned int ALIGNMENT = 1>
295 template<
typename SCALARTYPE>
298 template <
class SCALARTYPE>
301 template <
class SCALARTYPE>
304 template <
class SCALARTYPE>
307 template<
class SCALARTYPE,
unsigned int ALIGNMENT = 1>
310 template<
class SCALARTYPE>
314 template<
class SCALARTYPE,
unsigned int ALIGNMENT = 128>
317 template<
class SCALARTYPE,
unsigned int ALIGNMENT = 1>
320 template<
class SCALARTYPE,
unsigned int ALIGNMENT = 1>
323 template<
class SCALARTYPE,
unsigned int ALIGNMENT = 1>
326 template<
class SCALARTYPE,
unsigned int ALIGNMENT = 1>
329 template<
class SCALARTYPE,
unsigned int ALIGNMENT = 1>
332 template<
class SCALARTYPE,
unsigned int ALIGNMENT = 1>
338 template <
typename SizeType = vcl_
size_t,
typename DistanceType = std::ptrdiff_t>
343 template <
typename SizeType = vcl_
size_t,
typename DistanceType = std::ptrdiff_t>
348 template <
typename VectorType>
351 template <
typename VectorType>
354 template <
typename MatrixType>
357 template <
typename MatrixType>
362 template <
typename T>
369 template <
typename T>
376 template <
typename T>
383 template <
typename T>
398 template <
typename T>
405 template <
typename T>
412 template <
typename T>
419 template <
typename T>
426 template <
typename T>
433 template <
typename T>
441 template <
typename T>
448 template <
typename T>
455 template <
typename T>
462 template <
typename T>
469 template <
typename T>
489 memory_exception(std::string message) : message_(
"ViennaCL: Internal memory error: " + message) {}
491 virtual const char*
what()
const throw() {
return message_.c_str(); }
495 std::string message_;
503 virtual const char*
what()
const throw() {
return message_.c_str(); }
507 std::string message_;
518 template <
typename ROWCOL,
typename MATRIXTYPE>
521 typedef typename MATRIXTYPE::ERROR_SPECIALIZATION_FOR_THIS_MATRIX_TYPE_MISSING
ErrorIndicator;
523 static void apply(
const MATRIXTYPE & ,
unsigned int & ,
unsigned int & ) {}
529 #if !defined(_MSC_VER) || defined(__CUDACC__)
531 template<
class SCALARTYPE,
unsigned int ALIGNMENT>
536 template <
typename T>
540 template <
typename T>
546 template <
typename T>
551 template <
typename LHS,
typename RHS,
typename OP,
typename T>
556 template <
typename T,
typename LHS,
typename RHS,
typename OP>
561 template <
typename LHS1,
typename RHS1,
typename OP1,
562 typename LHS2,
typename RHS2,
typename OP2,
typename T>
569 template <
typename T>
574 template <
typename LHS,
typename RHS,
typename OP,
typename T>
579 template <
typename T,
typename LHS,
typename RHS,
typename OP>
584 template <
typename LHS1,
typename RHS1,
typename OP1,
585 typename LHS2,
typename RHS2,
typename OP2,
typename S3>
593 template <
typename T>
599 template <
typename LHS,
typename RHS,
typename OP,
typename T>
604 template <
typename T>
612 template <
typename LHS,
typename RHS,
typename OP,
typename S2>
617 template <
typename T>
620 template <
typename LHS,
typename RHS,
typename OP,
typename T>
624 template <
typename T>
627 template <
typename LHS,
typename RHS,
typename OP,
typename S2>
633 template <
typename T>
639 template <
typename LHS,
typename RHS,
typename OP,
typename T>
644 template <
typename T>
650 template <
typename LHS,
typename RHS,
typename OP,
typename S2>
654 template <
typename T,
typename F>
657 template <
typename T,
typename F>
661 template <
typename T>
664 template <
typename LHS,
typename RHS,
typename OP>
669 template <
typename NumericT,
typename F>
674 template <
typename NumericT,
typename F>
679 template<
typename SparseMatrixType,
class SCALARTYPE,
unsigned int ALIGNMENT>
705 static const char *
name() {
return "lower"; }
710 static const char *
name() {
return "upper"; }
715 static const char *
name() {
return "unit_lower"; }
720 static const char *
name() {
return "unit_upper"; }
730 template <
typename VectorType>
777 namespace FFT_DATA_ORDER {}
786 namespace autotune {}
792 namespace profiles {}
860 namespace result_of {}
879 namespace result_of {}
virtual const char * what() const
Definition: forwards.h:491
Sparse matrix class using a hybrid format composed of the ELL and CSR format for storing the nonzeros...
Definition: forwards.h:321
Simple enable-if variant that uses the SFINAE pattern.
Definition: enable_if.hpp:29
Represents a vector consisting of zeros only.
Definition: forwards.h:193
A tag class representing multiplication by a scalar.
Definition: forwards.h:74
viennacl::vector_expression< const vector_base< T >, const vector_base< T >, op_element_binary< op_div > > element_div(vector_base< T > const &v1, vector_base< T > const &v2)
A tag class representing the cosh() function.
Definition: forwards.h:107
A STL-type const-iterator for vector elements. Elements can be accessed, but cannot be manipulated...
Definition: forwards.h:187
std::size_t vcl_size_t
Definition: forwards.h:58
Definition: forwards.h:498
basic_slice slice
Definition: forwards.h:344
A tag class representing the tan() function.
Definition: forwards.h:133
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
Definition: forwards.h:172
Definition: forwards.h:478
virtual const char * what() const
Definition: forwards.h:503
Checks for either matrix_base or implicit_matrix_base.
Definition: forwards.h:395
Exception class in case of memory errors.
Definition: forwards.h:485
Helper class for checking whether a matrix is a compressed_matrix (CSR format)
Definition: forwards.h:406
Helper class for checking whether a matrix is a hyb_matrix (hybrid format: ELL plus CSR) ...
Definition: forwards.h:427
Class for representing strided submatrices of a bigger matrix A.
Definition: forwards.h:358
Helper class for checking whether the provided type is one of the sparse matrix types (compressed_mat...
Definition: forwards.h:434
Helper class for checking whether a matrix has a row-major layout.
Definition: forwards.h:399
static vcl_size_t mem_index(vcl_size_t i, vcl_size_t j, vcl_size_t, vcl_size_t num_cols)
Returns the memory offset for entry (i,j) of a dense matrix.
Definition: forwards.h:256
Helper struct for checking whether a type represents a sign flip on a viennacl::scalar<> ...
Definition: forwards.h:377
Represents a vector consisting of 1 at a given index and zeros otherwise.
Definition: forwards.h:196
A tag class representing the extraction of a matrix column to a vector.
Definition: forwards.h:147
A tag class representing a matrix given by a vector placed on a certain (off-)diagonal.
Definition: forwards.h:141
A tag class representing a lower triangular matrix.
Definition: forwards.h:703
void apply(VectorType &) const
Definition: forwards.h:731
A tag class representing subtraction.
Definition: forwards.h:72
A tag class representing assignment.
Definition: forwards.h:63
Helper class for checking whether a matrix is a Toeplitz matrix.
Definition: forwards.h:456
A dense matrix class.
Definition: forwards.h:290
A tag class representing the modulus function for integers.
Definition: forwards.h:93
Expression template class for representing a tree of expressions which ultimately result in a matrix...
Definition: forwards.h:283
A tag class representing the ceil() function.
Definition: forwards.h:103
A Hankel matrix class.
Definition: forwards.h:327
A dense matrix class.
Definition: forwards.h:293
vcl_size_t index_norm_inf(viennacl::vector_expression< LHS, RHS, OP > const &vec)
Computes the supremum norm of a vector with final reduction on the CPU - interface for a vector expre...
Definition: vector_operations.hpp:835
A tag class representing division.
Definition: forwards.h:80
Represents a vector consisting of 1 at a given index and zeros otherwise. To be used as an initialize...
Definition: forwards.h:299
void norm_1_impl(viennacl::vector_expression< LHS, RHS, OP > const &vec, scalar< T > &result)
A proxy for scalar expressions (e.g. from inner vector products)
Definition: forwards.h:175
An expression template class that represents a binary operation that yields a vector.
Definition: forwards.h:181
memory_exception()
Definition: forwards.h:488
A tag class representing the log() function.
Definition: forwards.h:123
row_major_tag orientation_category
Definition: forwards.h:248
A tag class representing inplace addition.
Definition: forwards.h:65
Definition: forwards.h:481
memory_types
Definition: forwards.h:476
A tag class representing the tanh() function.
Definition: forwards.h:135
A tag class representing the fabs() function.
Definition: forwards.h:111
A tag class representing the atan2() function.
Definition: forwards.h:101
Definition: forwards.h:365
A Vandermonde matrix class.
Definition: forwards.h:333
A tag class representing the (off-)diagonal of a matrix.
Definition: forwards.h:138
A tag class representing the atan() function.
Definition: forwards.h:99
A tag class representing the sinh() function.
Definition: forwards.h:129
virtual ~cuda_not_available_exception()
Definition: forwards.h:505
Checks for a type being either vector_base or implicit_vector_base.
Definition: forwards.h:391
Base class for representing matrices where the individual entries are not all stored explicitly...
Definition: forwards.h:296
static const char * name()
Definition: forwards.h:710
Definition: forwards.h:480
Helper struct for checking whether a type is a host scalar type (e.g. float, double) ...
Definition: forwards.h:363
A tag class representing the fmax() function.
Definition: forwards.h:117
Class for representing non-strided subvectors of a bigger vector x.
Definition: forwards.h:349
Helper class for checking whether a matrix is a circulant matrix.
Definition: forwards.h:442
Sparse matrix class using the ELLPACK format for storing the nonzeros.
Definition: ell_matrix.hpp:53
A tag class representing the use of no preconditioner.
Definition: forwards.h:727
A tag class representing the fmod() function.
Definition: forwards.h:121
Definition: forwards.h:379
A tag class representing the exp() function.
Definition: forwards.h:109
A tag class representing an upper triangular matrix.
Definition: forwards.h:708
void norm_frobenius_cpu(matrix_base< T, F > const &vec, T &result)
Computes the Frobenius norm of a vector with final reduction on the CPU.
Definition: matrix_operations.hpp:325
Tuple class holding pointers to multiple vectors. Mainly used as a temporary object returned from vie...
Definition: forwards.h:211
Definition: forwards.h:693
Helper struct for checking whether the provided type represents a scalar (either host, from ViennaCL, or a flip-sign proxy)
Definition: forwards.h:384
A STL-type iterator for vector elements. Elements can be accessed and manipulated. VERY SLOW!!
Definition: forwards.h:184
A sparse square matrix in compressed sparse rows format optimized for the case that only a few rows c...
Definition: compressed_compressed_matrix.hpp:263
Definition: forwards.h:694
static const char * name()
Definition: forwards.h:705
Class for representing strided subvectors of a bigger vector x.
Definition: forwards.h:352
A tag class representing addition.
Definition: forwards.h:70
static vcl_size_t mem_index(vcl_size_t i, vcl_size_t j, vcl_size_t num_rows, vcl_size_t)
Returns the memory offset for entry (i,j) of a dense matrix.
Definition: forwards.h:273
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
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
Definition: forwards.h:305
Common base class for dense vectors, vector ranges, and vector slices.
Definition: forwards.h:205
viennacl::enable_if< viennacl::is_any_sparse_matrix< SparseMatrixType >::value, vector_expression< const SparseMatrixType, const vector< SCALARTYPE, ALIGNMENT >, op_prod > >::type prod_impl(const SparseMatrixType &mat, const vector< SCALARTYPE, ALIGNMENT > &vec)
A tag class representing the sqrt() function.
Definition: forwards.h:131
column_major_tag orientation_category
Definition: forwards.h:265
Tag class for indicating column-major layout of a matrix. Not passed to the matrix directly...
Definition: forwards.h:243
void inner_prod_impl(viennacl::vector_expression< LHS1, RHS1, OP1 > const &vec1, viennacl::vector_expression< LHS2, RHS2, OP2 > const &vec2, scalar< T > &result)
Definition: vector_operations.hpp:404
A tag class representing matrix-matrix products.
Definition: forwards.h:78
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
static const char * name()
Definition: forwards.h:720
Represents a vector consisting of zeros only. To be used as an initializer for viennacl::vector, vector_range, or vector_slize only.
Definition: forwards.h:302
void convolve_i(viennacl::vector< SCALARTYPE, ALIGNMENT > &input1, viennacl::vector< SCALARTYPE, ALIGNMENT > &input2, viennacl::vector< SCALARTYPE, ALIGNMENT > &output)
void norm_inf_impl(viennacl::vector_expression< LHS, RHS, OP > const &vec, scalar< T > &result)
Computes the supremum norm of a vector - interface for a vector expression. Creates a temporary...
Definition: vector_operations.hpp:747
void norm_2_impl(viennacl::vector_expression< LHS, RHS, OP > const &vec, scalar< T > &result)
Computes the l^2-norm of a vector - interface for a vector expression. Creates a temporary.
Definition: vector_operations.hpp:655
Definition: forwards.h:372
A tag class representing the sin() function.
Definition: forwards.h:127
memory_exception(std::string message)
Definition: forwards.h:489
Helper class for checking whether a matrix is a Hankel matrix.
Definition: forwards.h:449
A tag class representing the fmin() function.
Definition: forwards.h:119
A tag class representing inplace subtraction.
Definition: forwards.h:67
cuda_not_available_exception()
Definition: forwards.h:501
Helper class for checking whether the provided type is any of the dense structured matrix types (circ...
Definition: forwards.h:470
A tag class representing the 1-norm of a vector.
Definition: forwards.h:153
A tag class representing matrix-vector products and element-wise multiplications. ...
Definition: forwards.h:76
Helper struct for checking whether a type is a viennacl::scalar<>
Definition: forwards.h:370
static const char * name()
Definition: forwards.h:715
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
Definition: context.hpp:41
Tag class for indicating row-major layout of a matrix. Not passed to the matrix directly, see row_major type.
Definition: forwards.h:241
row_info_types
Definition: forwards.h:691
A tag class representing the floor() function.
Definition: forwards.h:115
A tag class representing the asin() function.
Definition: forwards.h:97
Definition: forwards.h:479
void norm_1_cpu(viennacl::vector_expression< LHS, RHS, OP > const &vec, S2 &result)
Computes the l^1-norm of a vector with final reduction on the CPU - interface for a vector expression...
Definition: vector_operations.hpp:608
A range class that refers to an interval [start, stop), where 'start' is included, and 'stop' is excluded.
Definition: forwards.h:339
virtual ~memory_exception()
Definition: forwards.h:493
A tag class representing a lower triangular matrix with unit diagonal.
Definition: forwards.h:713
std::ptrdiff_t vcl_ptrdiff_t
Definition: forwards.h:59
viennacl::vector_expression< const vector_base< T >, const vector_base< T >, op_element_binary< op_prod > > element_prod(vector_base< T > const &v1, vector_base< T > const &v2)
A Toeplitz matrix class.
Definition: forwards.h:330
A tag class representing transposed matrices.
Definition: forwards.h:165
void inner_prod_cpu(viennacl::vector_expression< LHS1, RHS1, OP1 > const &vec1, viennacl::vector_expression< LHS2, RHS2, OP2 > const &vec2, S3 &result)
Definition: vector_operations.hpp:476
Represents a vector consisting of ones only.
Definition: forwards.h:199
basic_range range
Definition: forwards.h:339
A sparse square matrix in compressed sparse rows format.
Definition: compressed_matrix.hpp:428
A tag class representing the Frobenius-norm of a matrix.
Definition: forwards.h:162
A tag for column-major storage of a dense matrix.
Definition: forwards.h:263
A tag class representing element-wise binary operations (like multiplication) on vectors or matrices...
Definition: forwards.h:86
A Circulant matrix class.
Definition: circulant_matrix.hpp:41
Class for representing non-strided submatrices of a bigger matrix A.
Definition: forwards.h:355
Helper class for checking whether a matrix is a coordinate_matrix (COO format)
Definition: forwards.h:413
void norm_frobenius_impl(matrix_base< T, F > const &vec, scalar< T > &result)
Computes the Frobenius norm of a matrix - dispatcher interface.
Definition: matrix_operations.hpp:311
Definition: forwards.h:386
Common base class for representing vectors where the entries are not all stored explicitly.
Definition: forwards.h:190
A tag class representing sign flips (for scalars only. Vectors and matrices use the standard multipli...
Definition: forwards.h:168
Helper class for checking whether a matrix is a Vandermonde matrix.
Definition: forwards.h:463
A tag class representing the acos() function.
Definition: forwards.h:95
A tag class representing the fdim() function.
Definition: forwards.h:113
A tag class representing inner products of two vectors.
Definition: forwards.h:150
A tag class representing the extraction of a matrix row to a vector.
Definition: forwards.h:144
A tag class representing the power function.
Definition: forwards.h:82
A slice class that refers to an interval [start, stop), where 'start' is included, and 'stop' is excluded.
Definition: forwards.h:344
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
A tag class representing the inf-norm of a vector.
Definition: forwards.h:159
void norm_inf_cpu(viennacl::vector_expression< LHS, RHS, OP > const &vec, S2 &result)
Computes the supremum norm of a vector with final reduction on the CPU - interface for a vector expre...
Definition: vector_operations.hpp:792
A tag class representing the log10() function.
Definition: forwards.h:125
A tag class representing element-wise unary operations (like sin()) on vectors or matrices...
Definition: forwards.h:90
void norm_2_cpu(viennacl::vector_expression< LHS, RHS, OP > const &vec, S2 &result)
Computes the l^2-norm of a vector with final reduction on the CPU - interface for a vector expression...
Definition: vector_operations.hpp:700
A tag class representing the 2-norm of a vector.
Definition: forwards.h:156
void fast_copy(const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_begin, const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_end, CPU_ITERATOR cpu_begin)
STL-like transfer of a GPU vector to the CPU. The cpu type is assumed to reside in a linear piece of ...
Definition: vector.hpp:1284
A tag for row-major storage of a dense matrix.
Definition: forwards.h:246
Helper class for checking whether a matrix is an ell_matrix (ELL format)
Definition: forwards.h:420
A tag class representing the cos() function.
Definition: forwards.h:105
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
Definition: forwards.h:202
Simple enable-if variant that uses the SFINAE pattern.
A tag class representing an upper triangular matrix with unit diagonal.
Definition: forwards.h:718
Definition: forwards.h:695
A sparse square matrix, where entries are stored as triplets (i,j, val), where i and j are the row an...
Definition: coordinate_matrix.hpp:186
Definition: forwards.h:696