Expression Templates Library (ETL)
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
etl::scalar< T > Struct Template Reference

Represents a scalar value. More...

#include <scalar.hpp>

Public Types

using value_type = T
 The value type.
 
template<typename V = default_vec>
using vec_type = typename V::template vec_type< T >
 

Public Member Functions

constexpr scalar (T v)
 Builds a new scalar \þaram v The scalar value.
 
template<std::convertible_to< T > C>
constexpr scalar (C c)
 Builds a new scalar from a convertible type \þaram v The scalar value.
 
constexpr T operator[] (size_t d) const noexcept
 Returns the element at the given index. More...
 
constexpr T read_flat (size_t d) const noexcept
 Returns the value at the given index This function never alters the state of the container. More...
 
template<typename V = default_vec>
vec_type< V > load (size_t d) const noexcept
 Load several elements of the matrix at once. More...
 
template<typename V = default_vec>
vec_type< V > loadu (size_t d) const noexcept
 Load several elements of the matrix at once. More...
 
template<size_c... S>
constexpr T operator() (__attribute__((unused)) S... args) const noexcept
 Returns the value at the position (args...) More...
 
template<typename E >
constexpr bool alias (const E &) const noexcept
 Indicate if the expression aliases with the given expression. More...
 
template<typename L >
void assign_to (L &&lhs) const
 Assign to the given left-hand-side expression. More...
 
template<typename L >
void assign_add_to (L &&lhs) const
 Add to the given left-hand-side expression. More...
 
template<typename L >
void assign_sub_to (L &&lhs) const
 Sub from the given left-hand-side expression. More...
 
template<typename L >
void assign_mul_to (L &&lhs) const
 Multiply the given left-hand-side expression. More...
 
template<typename L >
void assign_div_to (L &&lhs) const
 Divide the given left-hand-side expression. More...
 
template<typename L >
void assign_mod_to (L &&lhs) const
 Modulo the given left-hand-side expression. More...
 
template<typename V >
void visit ([[maybe_unused]] V &&visitor) const
 Apply the given visitor to this expression and its descendants. More...
 
template<typename Y >
decltype(auto) gpu_compute_hint ([[maybe_unused]] Y &y) const
 Return a GPU computed version of this expression. More...
 
template<typename Y >
decltype(auto) gpu_compute (Y &y) const
 Return a GPU computed version of this expression. More...
 
void ensure_cpu_up_to_date () const
 Ensures that the GPU memory is allocated and that the GPU memory is up to date (to undefined value).
 
void ensure_gpu_up_to_date () const
 Copy back from the GPU to the expression memory if necessary.
 

Public Attributes

const T value
 The scalar value.
 

Friends

std::ostream & operator<< (std::ostream &os, const scalar &s)
 Prints a scalar value to the given stream. More...
 

Detailed Description

template<typename T>
struct etl::scalar< T >

Represents a scalar value.

Member Typedef Documentation

◆ vec_type

template<typename T >
template<typename V = default_vec>
using etl::scalar< T >::vec_type = typename V::template vec_type<T>

The vectorization type for V

Member Function Documentation

◆ alias()

template<typename T >
template<typename E >
constexpr bool etl::scalar< T >::alias ( const E &  ) const
inlinenoexcept

Indicate if the expression aliases with the given expression.

Returns
true if the expressions alias, false otherwise

◆ assign_add_to()

template<typename T >
template<typename L >
void etl::scalar< T >::assign_add_to ( L &&  lhs) const
inline

Add to the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ assign_div_to()

template<typename T >
template<typename L >
void etl::scalar< T >::assign_div_to ( L &&  lhs) const
inline

Divide the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ assign_mod_to()

template<typename T >
template<typename L >
void etl::scalar< T >::assign_mod_to ( L &&  lhs) const
inline

Modulo the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ assign_mul_to()

template<typename T >
template<typename L >
void etl::scalar< T >::assign_mul_to ( L &&  lhs) const
inline

Multiply the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ assign_sub_to()

template<typename T >
template<typename L >
void etl::scalar< T >::assign_sub_to ( L &&  lhs) const
inline

Sub from the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ assign_to()

template<typename T >
template<typename L >
void etl::scalar< T >::assign_to ( L &&  lhs) const
inline

Assign to the given left-hand-side expression.

Parameters
lhsThe expression to which assign

◆ gpu_compute()

template<typename T >
template<typename Y >
decltype(auto) etl::scalar< T >::gpu_compute ( Y &  y) const
inline

Return a GPU computed version of this expression.

Returns
a GPU-computed ETL expression for this expression

◆ gpu_compute_hint()

template<typename T >
template<typename Y >
decltype(auto) etl::scalar< T >::gpu_compute_hint ( [[maybe_unused] ] Y &  y) const
inline

Return a GPU computed version of this expression.

Returns
a GPU-computed ETL expression for this expression

◆ load()

template<typename T >
template<typename V = default_vec>
vec_type<V> etl::scalar< T >::load ( size_t  d) const
inlinenoexcept

Load several elements of the matrix at once.

Parameters
dThe position at which to start. This will be aligned from the beginning (multiple of the vector size).
Template Parameters
VThe vectorization mode to use
Returns
a vector containing several elements of the matrix

◆ loadu()

template<typename T >
template<typename V = default_vec>
vec_type<V> etl::scalar< T >::loadu ( size_t  d) const
inlinenoexcept

Load several elements of the matrix at once.

Parameters
dThe position at which to start. This will be aligned from the beginning (multiple of the vector size).
Template Parameters
VThe vectorization mode to use
Returns
a vector containing several elements of the matrix

◆ operator()()

template<typename T >
template<size_c... S>
constexpr T etl::scalar< T >::operator() ( __attribute__((unused)) S...  args) const
inlinenoexcept

Returns the value at the position (args...)

Parameters
argsThe indices
Returns
The computed value at the position (args...)

◆ operator[]()

template<typename T >
constexpr T etl::scalar< T >::operator[] ( size_t  d) const
inlinenoexcept

Returns the element at the given index.

Parameters
dThe index
Returns
a reference to the element at the given index.

◆ read_flat()

template<typename T >
constexpr T etl::scalar< T >::read_flat ( size_t  d) const
inlinenoexcept

Returns the value at the given index This function never alters the state of the container.

Parameters
dThe index
Returns
the value at the given index.

◆ visit()

template<typename T >
template<typename V >
void etl::scalar< T >::visit ( [[maybe_unused] ] V &&  visitor) const
inline

Apply the given visitor to this expression and its descendants.

Parameters
visitorThe visitor to apply

Friends And Related Function Documentation

◆ operator<<

template<typename T >
std::ostream& operator<< ( std::ostream &  os,
const scalar< T > &  s 
)
friend

Prints a scalar value to the given stream.

Parameters
osThe output stream
sThe scalar to print
Returns
the output stream

The documentation for this struct was generated from the following files: