libpnicore
|
Scalar template for scalar values. More...
#include <scalar.hpp>
Public Types | |
typedef T | value_type |
native data type of the scalar | |
typedef scalar< T > | array_type |
type of the scalar itself | |
typedef std::array< T, 1 > | storage_type |
storage type | |
typedef scalar_iterator < array_type > | iterator |
iterator | |
typedef scalar_iterator< const array_type > | const_iterator |
const iterator | |
typedef array_view< array_type > | view_type |
view type | |
Public Member Functions | |
scalar () | |
default constructor | |
scalar (const array_type &s) | |
copy constructor | |
scalar (const value_type &r) | |
constructor from a scalar value | |
~scalar () | |
destructor | |
array_type & | operator= (const value_type &v) |
assignment from T value More... | |
array_type & | operator= (const array_type &v) |
assignment from Scalar<T> More... | |
operator T () const | |
conversion operator More... | |
T | operator[] (size_t) const |
get data More... | |
T & | operator[] (size_t) |
get reference to data More... | |
T | at (size_t) const |
get data value More... | |
T & | at (size_t) |
get data reference More... | |
void | insert (size_t, const T &v) |
set data value More... | |
const storage_type & | storage () const |
get reference to the storage object More... | |
template<typename... ITYPES> | |
T & | operator() (ITYPES...) |
get reference to the data More... | |
template<typename... ITYPES> | |
T | operator() (ITYPES...) const |
get value of data More... | |
template<template< typename...> class CTYPE, typename... OTS> | |
T & | operator() (const CTYPE< OTS...> &) |
get reference to data More... | |
template<template< typename...> class CTYPE, typename... OTS> | |
T | operator() (const CTYPE< OTS...> &) const |
get data value More... | |
size_t | size () const |
get size More... | |
size_t | rank () const |
get rank More... | |
template<typename CTYPE > | |
CTYPE | shape () const |
get shape More... | |
iterator | begin () |
get iterator to first element | |
iterator | end () |
get iterator to last+1 element | |
const_iterator | begin () const |
get const iterator to first element | |
const_iterator | end () const |
get const iterator to last+1 element | |
Static Public Attributes | |
static const type_id_t | type_id = type_id_map<T>::type_id |
type ID of the data type held by the scalar | |
Private Attributes | |
std::array< T, 1 > | _data |
static buffer holding the data value | |
This template is used in expression tempaltes. Its purpose is to give scalar values an array like interface.
T | scalar type of the data stored. |
|
inline |
Return the value of the data stored in the instance no matter of the value of the index.
i | index |
|
inline |
Return a reference to the data stored in the scalar no matter what index is passed to the method.
i | index |
|
inline |
Method to set a data value. The index does not matter.
i | index |
v | value |
|
inline |
Allows conversion from an instance of scalar<T> to a variable of type T.
|
inline |
Returns the reference to the data value no matter how many or what indices are passed.
ITYPES | index types |
indices | multidimensional index |
|
inline |
Return the value of the scalar. The number of indices or their type do not matter.
ITYPES | index types |
indices | multidimensional index |
|
inline |
Return a reference to the data. The multidimensional index is passed by a container. The number of indices or their value are ignored.
CTYPE | container template |
OTS | template arguments for the container template |
|
inline |
Return the data value. The multidimensional index is passed by a container. The number of indices or their value are ignored.
CTYPE | container template |
OTS | template arguments of the container template |
|
inline |
Assigns a value of type T to the scalar.
v | value to assign |
|
inline |
This is the most trivial case. An object of type Scalar<T> is assigned to an other object of type Scalar<T>.
v | value of scalar<T> to assign |
|
inline |
Return the single data value independent of what value of i is given.
i | linear index of the value |
|
inline |
Return a reference to the data stored in the scalar. No matter what value of i is passed to this operator - it will always return the same reference.
i | index |
|
inline |
Return the number of dimensions of the scalar. This is always 0.
Returns the shape of the scalar - this is a container with a single value 1.
|
inline |
For a scalar object this method always returns 1. This is due to the fact that one needs to allocate only one block of memory of sizeof(T) bytes to hold the scalar data.
|
inline |
Return a const reference to the static buffer that holds the scalar data.