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 <forwards.h>
Public Types | |
typedef viennacl::backend::mem_handle | handle_type |
typedef vcl_size_t | size_type |
typedef NumericT | value_type |
Returns the underlying host scalar type. More... | |
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). More... | |
scalar (NumericT val, viennacl::context ctx=viennacl::context()) | |
Allocates the memory for the scalar and sets it to the supplied value. More... | |
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. More... | |
scalar (const scalar &other) | |
Copy constructor. Allocates new memory for the scalar and copies the value of the supplied scalar. More... | |
operator NumericT () const | |
Reads the value of the scalar from the GPU and returns the float or double value. More... | |
self_type & | operator= (entry_proxy< NumericT > const &other) |
Assigns a vector entry. More... | |
self_type & | operator= (scalar< NumericT > const &other) |
Assigns the value from another scalar. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
template<typename T1 , typename T2 > | |
self_type & | operator= (scalar_expression< T1, T2, op_max > const &proxy) |
Sets the scalar to the result of supplied norm_inf expression. More... | |
template<typename T1 , typename T2 > | |
self_type & | operator= (scalar_expression< T1, T2, op_min > const &proxy) |
Sets the scalar to the result of supplied norm_inf expression. More... | |
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. More... | |
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. More... | |
self_type & | operator+= (scalar< NumericT > const &other) |
Inplace addition of a ViennaCL scalar. More... | |
self_type & | operator+= (NumericT other) |
Inplace addition of a host scalar (float or double) More... | |
self_type & | operator-= (scalar< NumericT > const &other) |
Inplace subtraction of a ViennaCL scalar. More... | |
self_type & | operator-= (NumericT other) |
Inplace subtraction of a host scalar (float or double) More... | |
self_type & | operator*= (scalar< NumericT > const &other) |
Inplace multiplication with a ViennaCL scalar. More... | |
self_type & | operator*= (NumericT other) |
Inplace multiplication with a host scalar (float or double) More... | |
self_type & | operator/= (scalar< NumericT > const &other) |
Inplace division with a ViennaCL scalar. More... | |
self_type & | operator/= (NumericT other) |
Inplace division with a host scalar (float or double) More... | |
self_type | operator+ (scalar< NumericT > const &other) |
Addition of two ViennaCL scalars. More... | |
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. More... | |
self_type | operator+ (NumericT other) |
Addition of a ViennaCL scalar with a host scalar (float, double) More... | |
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. More... | |
self_type | operator- (scalar< NumericT > const &other) const |
Subtraction of two ViennaCL scalars. More... | |
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. More... | |
scalar< NumericT > | operator- (NumericT other) const |
Subtraction of a host scalar (float, double) from a ViennaCL scalar. More... | |
self_type | operator* (scalar< NumericT > const &other) const |
Multiplication of two ViennaCL scalars. More... | |
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. More... | |
self_type | operator* (NumericT other) const |
Multiplication of a host scalar (float, double) with a ViennaCL scalar. More... | |
self_type | operator/ (scalar< NumericT > const &other) const |
Division of two ViennaCL scalars. More... | |
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. More... | |
self_type | operator/ (NumericT other) const |
Division of a ViennaCL scalar by a host scalar (float, double) More... | |
handle_type & | handle () |
Returns the memory handle, non-const version. More... | |
const handle_type & | handle () const |
Returns the memory handle, const version. More... | |
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.
NumericT | Either float or double. Checked at compile time. |
Definition at line 226 of file forwards.h.
typedef viennacl::backend::mem_handle viennacl::scalar< TYPE >::handle_type |
Definition at line 320 of file scalar.hpp.
typedef vcl_size_t viennacl::scalar< TYPE >::size_type |
Definition at line 321 of file scalar.hpp.
typedef NumericT viennacl::scalar< TYPE >::value_type |
Returns the underlying host scalar type.
Definition at line 324 of file scalar.hpp.
|
inline |
Creates the scalar object, but does not yet allocate memory. Thus, scalar<> can also be a global variable (if really necessary).
Definition at line 327 of file scalar.hpp.
|
inline |
Allocates the memory for the scalar and sets it to the supplied value.
Definition at line 330 of file scalar.hpp.
|
inline |
Allocates memory for the scalar and sets it to the result of supplied expression.
Definition at line 351 of file scalar.hpp.
|
inline |
Copy constructor. Allocates new memory for the scalar and copies the value of the supplied scalar.
Definition at line 360 of file scalar.hpp.
|
inline |
Returns the memory handle, non-const version.
Definition at line 792 of file scalar.hpp.
|
inline |
Returns the memory handle, const version.
Definition at line 795 of file scalar.hpp.
|
inline |
Reads the value of the scalar from the GPU and returns the float or double value.
Definition at line 372 of file scalar.hpp.
|
inline |
Multiplication of two ViennaCL scalars.
Definition at line 715 of file scalar.hpp.
|
inline |
Multiplication of a ViennaCL scalar with a scalar expression.
Definition at line 728 of file scalar.hpp.
|
inline |
Multiplication of a host scalar (float, double) with a ViennaCL scalar.
Definition at line 740 of file scalar.hpp.
|
inline |
Inplace multiplication with a ViennaCL scalar.
Definition at line 580 of file scalar.hpp.
|
inline |
Inplace multiplication with a host scalar (float or double)
Definition at line 589 of file scalar.hpp.
|
inline |
Addition of two ViennaCL scalars.
Definition at line 622 of file scalar.hpp.
|
inline |
Addition of a ViennaCL scalar with a scalar expression.
Definition at line 636 of file scalar.hpp.
|
inline |
Addition of a ViennaCL scalar with a host scalar (float, double)
Definition at line 649 of file scalar.hpp.
|
inline |
Inplace addition of a ViennaCL scalar.
Definition at line 536 of file scalar.hpp.
|
inline |
Inplace addition of a host scalar (float or double)
Definition at line 546 of file scalar.hpp.
|
inline |
Sign flip of the scalar. Does not evaluate immediately, but instead returns an expression template object.
Definition at line 666 of file scalar.hpp.
|
inline |
Subtraction of two ViennaCL scalars.
Definition at line 673 of file scalar.hpp.
|
inline |
Subtraction of a ViennaCL scalar from a scalar expression.
Definition at line 687 of file scalar.hpp.
|
inline |
Subtraction of a host scalar (float, double) from a ViennaCL scalar.
Definition at line 700 of file scalar.hpp.
|
inline |
Inplace subtraction of a ViennaCL scalar.
Definition at line 558 of file scalar.hpp.
|
inline |
Inplace subtraction of a host scalar (float or double)
Definition at line 568 of file scalar.hpp.
|
inline |
Division of two ViennaCL scalars.
Definition at line 754 of file scalar.hpp.
|
inline |
Division of a ViennaCL scalar by a scalar expression.
Definition at line 767 of file scalar.hpp.
|
inline |
Division of a ViennaCL scalar by a host scalar (float, double)
Definition at line 779 of file scalar.hpp.
|
inline |
Inplace division with a ViennaCL scalar.
Definition at line 601 of file scalar.hpp.
|
inline |
Inplace division with a host scalar (float or double)
Definition at line 610 of file scalar.hpp.
|
inline |
Assigns a vector entry.
Definition at line 383 of file scalar.hpp.
|
inline |
Assigns the value from another scalar.
Definition at line 391 of file scalar.hpp.
|
inline |
Definition at line 398 of file scalar.hpp.
|
inline |
Definition at line 408 of file scalar.hpp.
|
inline |
Definition at line 417 of file scalar.hpp.
|
inline |
Definition at line 426 of file scalar.hpp.
|
inline |
Definition at line 435 of file scalar.hpp.
|
inline |
Definition at line 444 of file scalar.hpp.
|
inline |
Sets the scalar to the result of supplied inner product expression.
Definition at line 455 of file scalar.hpp.
|
inline |
Sets the scalar to the result of supplied norm_1 expression.
Definition at line 465 of file scalar.hpp.
|
inline |
Sets the scalar to the result of supplied norm_2 expression.
Definition at line 475 of file scalar.hpp.
|
inline |
Sets the scalar to the result of supplied norm_inf expression.
Definition at line 485 of file scalar.hpp.
|
inline |
Sets the scalar to the result of supplied norm_inf expression.
Definition at line 495 of file scalar.hpp.
|
inline |
Sets the scalar to the result of supplied norm_inf expression.
Definition at line 505 of file scalar.hpp.
|
inline |
Sets the scalar to the result of supplied norm_frobenius expression.
Definition at line 516 of file scalar.hpp.
|
inline |
Sets the scalar to the inverse with respect to addition of the supplied sub-expression.
Definition at line 526 of file scalar.hpp.