ViennaCL - The Vienna Computing Library
1.5.1
|
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type like float or double. More...
#include <scalar.hpp>
Public Types | |
typedef viennacl::backend::mem_handle | handle_type |
typedef vcl_size_t | size_type |
typedef SCALARTYPE | value_type |
Returns the underlying host scalar type. | |
Public Member Functions | |
scalar () | |
Creates the scalar object, but does not yet allocate memory. Thus, scalar<> can also be a global variable (if really necessary). | |
scalar (SCALARTYPE val, viennacl::context ctx=viennacl::context()) | |
Allocates the memory for the scalar and sets it to the supplied value. | |
template<typename T1 , typename T2 , typename OP > | |
scalar (scalar_expression< T1, T2, OP > const &proxy) | |
Allocates memory for the scalar and sets it to the result of supplied expression. | |
scalar (const scalar &other) | |
Copy constructor. Allocates new memory for the scalar and copies the value of the supplied scalar. | |
operator SCALARTYPE () const | |
Reads the value of the scalar from the GPU and returns the float or double value. | |
self_type & | operator= (entry_proxy< SCALARTYPE > const &other) |
Assigns a vector entry. | |
self_type & | operator= (scalar< SCALARTYPE > const &other) |
Assigns the value from another scalar. | |
self_type & | operator= (float cpu_other) |
self_type & | operator= (double cpu_other) |
self_type & | operator= (long cpu_other) |
self_type & | operator= (unsigned long cpu_other) |
self_type & | operator= (int cpu_other) |
self_type & | operator= (unsigned int cpu_other) |
template<typename T1 , typename T2 > | |
self_type & | operator= (scalar_expression< T1, T2, op_inner_prod > const &proxy) |
Sets the scalar to the result of supplied inner product expression. | |
template<typename T1 , typename T2 > | |
self_type & | operator= (scalar_expression< T1, T2, op_norm_1 > const &proxy) |
Sets the scalar to the result of supplied norm_1 expression. | |
template<typename T1 , typename T2 > | |
self_type & | operator= (scalar_expression< T1, T2, op_norm_2 > const &proxy) |
Sets the scalar to the result of supplied norm_2 expression. | |
template<typename T1 , typename T2 > | |
self_type & | operator= (scalar_expression< T1, T2, op_norm_inf > const &proxy) |
Sets the scalar to the result of supplied norm_inf expression. | |
template<typename T1 , typename T2 > | |
self_type & | operator= (scalar_expression< T1, T2, op_norm_frobenius > const &proxy) |
Sets the scalar to the result of supplied norm_frobenius expression. | |
template<typename T1 , typename T2 > | |
self_type & | operator= (scalar_expression< T1, T2, op_flip_sign > const &proxy) |
Sets the scalar to the inverse with respect to addition of the supplied sub-expression. | |
self_type & | operator+= (scalar< SCALARTYPE > const &other) |
Inplace addition of a ViennaCL scalar. | |
self_type & | operator+= (SCALARTYPE other) |
Inplace addition of a host scalar (float or double) | |
self_type & | operator-= (scalar< SCALARTYPE > const &other) |
Inplace subtraction of a ViennaCL scalar. | |
self_type & | operator-= (SCALARTYPE other) |
Inplace subtraction of a host scalar (float or double) | |
self_type & | operator*= (scalar< SCALARTYPE > const &other) |
Inplace multiplication with a ViennaCL scalar. | |
self_type & | operator*= (SCALARTYPE other) |
Inplace multiplication with a host scalar (float or double) | |
self_type & | operator/= (scalar< SCALARTYPE > const &other) |
Inplace division with a ViennaCL scalar. | |
self_type & | operator/= (SCALARTYPE other) |
Inplace division with a host scalar (float or double) | |
self_type | operator+ (scalar< SCALARTYPE > const &other) |
Addition of two ViennaCL scalars. | |
template<typename T1 , typename T2 , typename OP > | |
self_type | operator+ (scalar_expression< T1, T2, OP > const &proxy) const |
Addition of a ViennaCL scalar with a scalar expression. | |
self_type | operator+ (SCALARTYPE other) |
Addition of a ViennaCL scalar with a host scalar (float, double) | |
scalar_expression< const self_type, const self_type, op_flip_sign > | operator- () const |
Sign flip of the scalar. Does not evaluate immediately, but instead returns an expression template object. | |
self_type | operator- (scalar< SCALARTYPE > const &other) const |
Subtraction of two ViennaCL scalars. | |
template<typename T1 , typename T2 , typename OP > | |
self_type | operator- (scalar_expression< T1, T2, OP > const &proxy) const |
Subtraction of a ViennaCL scalar from a scalar expression. | |
scalar< SCALARTYPE > | operator- (SCALARTYPE other) const |
Subtraction of a host scalar (float, double) from a ViennaCL scalar. | |
self_type | operator* (scalar< SCALARTYPE > const &other) const |
Multiplication of two ViennaCL scalars. | |
template<typename T1 , typename T2 , typename OP > | |
self_type | operator* (scalar_expression< T1, T2, OP > const &proxy) const |
Multiplication of a ViennaCL scalar with a scalar expression. | |
self_type | operator* (SCALARTYPE other) const |
Multiplication of a host scalar (float, double) with a ViennaCL scalar. | |
self_type | operator/ (scalar< SCALARTYPE > const &other) const |
Division of two ViennaCL scalars. | |
template<typename T1 , typename T2 , typename OP > | |
self_type | operator/ (scalar_expression< T1, T2, OP > const &proxy) const |
Division of a ViennaCL scalar by a scalar expression. | |
self_type | operator/ (SCALARTYPE other) const |
Division of a ViennaCL scalar by a host scalar (float, double) | |
handle_type & | handle () |
Returns the memory handle, non-const version. | |
const handle_type & | handle () const |
Returns the memory handle, const version. |
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type like float or double.
Since every read and write operation requires a CPU->GPU or GPU->CPU transfer, this type should be used with care. The advantage of this type is that the GPU command queue can be filled without blocking read operations.
SCALARTYPE | Either float or double. Checked at compile time. |
typedef vcl_size_t size_type |
typedef SCALARTYPE value_type |
Returns the underlying host scalar type.
scalar | ( | ) | [inline] |
Creates the scalar object, but does not yet allocate memory. Thus, scalar<> can also be a global variable (if really necessary).
scalar | ( | SCALARTYPE | val, |
viennacl::context | ctx = viennacl::context() |
||
) | [inline] |
Allocates the memory for the scalar and sets it to the supplied value.
scalar | ( | scalar_expression< T1, T2, OP > const & | proxy | ) | [inline] |
Allocates memory for the scalar and sets it to the result of supplied expression.
Copy constructor. Allocates new memory for the scalar and copies the value of the supplied scalar.
handle_type& handle | ( | ) | [inline] |
Returns the memory handle, non-const version.
const handle_type& handle | ( | ) | const [inline] |
Returns the memory handle, const version.
operator SCALARTYPE | ( | ) | const [inline] |
Reads the value of the scalar from the GPU and returns the float or double value.
Multiplication of two ViennaCL scalars.
self_type operator* | ( | scalar_expression< T1, T2, OP > const & | proxy | ) | const [inline] |
Multiplication of a ViennaCL scalar with a scalar expression.
self_type operator* | ( | SCALARTYPE | other | ) | const [inline] |
Multiplication of a host scalar (float, double) with a ViennaCL scalar.
Inplace multiplication with a ViennaCL scalar.
self_type& operator*= | ( | SCALARTYPE | other | ) | [inline] |
Inplace multiplication with a host scalar (float or double)
Addition of two ViennaCL scalars.
self_type operator+ | ( | scalar_expression< T1, T2, OP > const & | proxy | ) | const [inline] |
Addition of a ViennaCL scalar with a scalar expression.
self_type operator+ | ( | SCALARTYPE | other | ) | [inline] |
Addition of a ViennaCL scalar with a host scalar (float, double)
Inplace addition of a ViennaCL scalar.
self_type& operator+= | ( | SCALARTYPE | other | ) | [inline] |
Inplace addition of a host scalar (float or double)
scalar_expression<const self_type, const self_type, op_flip_sign> operator- | ( | ) | const [inline] |
Sign flip of the scalar. Does not evaluate immediately, but instead returns an expression template object.
Subtraction of two ViennaCL scalars.
self_type operator- | ( | scalar_expression< T1, T2, OP > const & | proxy | ) | const [inline] |
Subtraction of a ViennaCL scalar from a scalar expression.
scalar<SCALARTYPE> operator- | ( | SCALARTYPE | other | ) | const [inline] |
Subtraction of a host scalar (float, double) from a ViennaCL scalar.
Inplace subtraction of a ViennaCL scalar.
self_type& operator-= | ( | SCALARTYPE | other | ) | [inline] |
Inplace subtraction of a host scalar (float or double)
Division of two ViennaCL scalars.
self_type operator/ | ( | scalar_expression< T1, T2, OP > const & | proxy | ) | const [inline] |
Division of a ViennaCL scalar by a scalar expression.
self_type operator/ | ( | SCALARTYPE | other | ) | const [inline] |
Division of a ViennaCL scalar by a host scalar (float, double)
Inplace division with a ViennaCL scalar.
self_type& operator/= | ( | SCALARTYPE | other | ) | [inline] |
Inplace division with a host scalar (float or double)
self_type& operator= | ( | entry_proxy< SCALARTYPE > const & | other | ) | [inline] |
Assigns a vector entry.
Assigns the value from another scalar.
self_type& operator= | ( | float | cpu_other | ) | [inline] |
self_type& operator= | ( | double | cpu_other | ) | [inline] |
self_type& operator= | ( | long | cpu_other | ) | [inline] |
self_type& operator= | ( | unsigned long | cpu_other | ) | [inline] |
self_type& operator= | ( | int | cpu_other | ) | [inline] |
self_type& operator= | ( | unsigned int | cpu_other | ) | [inline] |
self_type& operator= | ( | scalar_expression< T1, T2, op_inner_prod > const & | proxy | ) | [inline] |
Sets the scalar to the result of supplied inner product expression.
self_type& operator= | ( | scalar_expression< T1, T2, op_norm_1 > const & | proxy | ) | [inline] |
Sets the scalar to the result of supplied norm_1 expression.
self_type& operator= | ( | scalar_expression< T1, T2, op_norm_2 > const & | proxy | ) | [inline] |
Sets the scalar to the result of supplied norm_2 expression.
self_type& operator= | ( | scalar_expression< T1, T2, op_norm_inf > const & | proxy | ) | [inline] |
Sets the scalar to the result of supplied norm_inf expression.
self_type& operator= | ( | scalar_expression< T1, T2, op_norm_frobenius > const & | proxy | ) | [inline] |
Sets the scalar to the result of supplied norm_frobenius expression.
self_type& operator= | ( | scalar_expression< T1, T2, op_flip_sign > const & | proxy | ) | [inline] |
Sets the scalar to the inverse with respect to addition of the supplied sub-expression.