Advanced Multi-Physics (AMP)
On-Line Documentation
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
AMP::Scalar Class Reference

Scalar is a class used to store a scalar variable that may be different types/precision. More...

#include <Scalar.h>

Public Member Functions

Scalar abs () const
 
template<class TYPE >
Scalar create (const TYPE &x) const
 Construct a Scalar value.
 
template<class TYPE >
TYPE get (double tol=Scalar::getTol< TYPE >()) const
 Construct a scalar value.
 
uint32_t getTypeHash () const
 Return the storage type.
 
bool has_value () const noexcept
 Check if we are storing a value.
 
bool is_complex () const
 Return true if the type is a complex type.
 
bool is_floating_point () const
 Return true if the type is a floating point type.
 
bool is_integral () const
 Return true if the type is a integer point type.
 
Scalar limitsMax () const
 Return the maximum allowed value.
 
Scalar limitsMin () const
 Return the minimum allowed value.
 
template<class TYPE >
 operator TYPE () const
 
bool operator!= (const Scalar &rhs) const
 
bool operator< (const Scalar &rhs) const
 
bool operator<= (const Scalar &rhs) const
 
Scalaroperator= (const Scalar &)=default
 Assignment operator.
 
Scalaroperator= (Scalar &&)=default
 Move operator.
 
bool operator== (const Scalar &rhs) const
 
bool operator> (const Scalar &rhs) const
 
bool operator>= (const Scalar &rhs) const
 
void print (std::ostream &out) const
 Print the value to a stream.
 
 Scalar ()=default
 Empty constructor.
 
 Scalar (const Scalar &)=default
 Copy constructor.
 
template<class TYPE >
 Scalar (const TYPE &x)
 Construct a Scalar value.
 
 Scalar (Scalar &&)=default
 Move constructor.
 
Scalar sqrt () const
 
const auto & type () const
 Return the storage type.
 
Scalar zero () const
 Return a zero.
 

Static Public Member Functions

template<class TYPE >
static constexpr double getTol ()
 Get default tolerance.
 

Private Member Functions

template<class TYPE >
void store (const TYPE &x)
 

Private Attributes

std::any d_data
 
uint32_t d_hash = 0
 
char d_type = 0
 

Detailed Description

Scalar is a class used to store a scalar variable that may be different types/precision.

Definition at line 20 of file Scalar.h.

Constructor & Destructor Documentation

◆ Scalar() [1/4]

AMP::Scalar::Scalar ( )
inlinedefault

Empty constructor.

◆ Scalar() [2/4]

template<class TYPE >
AMP::Scalar::Scalar ( const TYPE &  x)

Construct a Scalar value.

Default constructor allowing implicit conversion to double

Parameters
[in]xInput scalar

◆ Scalar() [3/4]

AMP::Scalar::Scalar ( const Scalar )
default

Copy constructor.

◆ Scalar() [4/4]

AMP::Scalar::Scalar ( Scalar &&  )
default

Move constructor.

Member Function Documentation

◆ abs()

Scalar AMP::Scalar::abs ( ) const

◆ create()

template<class TYPE >
Scalar AMP::Scalar::create ( const TYPE &  x) const

Construct a Scalar value.

Create a new Scalar with the same implied type as *this

Parameters
[in]xInput scalar

◆ get()

template<class TYPE >
TYPE AMP::Scalar::get ( double  tol = Scalar::getTol< TYPE >()) const

Construct a scalar value.

Parameters
[in]tolTolerance to allow for the conversion (absolute error)
Returns
Returns the scalar value

◆ getTol()

template<class TYPE >
static constexpr double AMP::Scalar::getTol ( )
inlinestaticconstexpr

Get default tolerance.

Definition at line 86 of file Scalar.h.

◆ getTypeHash()

uint32_t AMP::Scalar::getTypeHash ( ) const
inline

Return the storage type.

Return the hash value computed by typeID. Equivalent to AMP::getTypeID<TYPE>().hash

Definition at line 79 of file Scalar.h.

References d_hash.

◆ has_value()

bool AMP::Scalar::has_value ( ) const
inlinenoexcept

Check if we are storing a value.

Definition at line 82 of file Scalar.h.

References d_data.

◆ is_complex()

bool AMP::Scalar::is_complex ( ) const
inline

Return true if the type is a complex type.

Definition at line 69 of file Scalar.h.

References d_type.

◆ is_floating_point()

bool AMP::Scalar::is_floating_point ( ) const
inline

Return true if the type is a floating point type.

Definition at line 63 of file Scalar.h.

References d_type.

◆ is_integral()

bool AMP::Scalar::is_integral ( ) const
inline

Return true if the type is a integer point type.

Definition at line 66 of file Scalar.h.

References d_type.

◆ limitsMax()

Scalar AMP::Scalar::limitsMax ( ) const

Return the maximum allowed value.

Return the maximum allowed value defined as the maximum value allowed by both the type used to create the scalar and the internal storage limits

◆ limitsMin()

Scalar AMP::Scalar::limitsMin ( ) const

Return the minimum allowed value.

Return the minimum allowed value defined as the minimum value allowed by both the type used to create the scalar and the internal storage limits

◆ operator TYPE()

template<class TYPE >
AMP::Scalar::operator TYPE ( ) const
inlineexplicit

Definition at line 117 of file Scalar.h.

◆ operator!=()

bool AMP::Scalar::operator!= ( const Scalar rhs) const

◆ operator<()

bool AMP::Scalar::operator< ( const Scalar rhs) const

◆ operator<=()

bool AMP::Scalar::operator<= ( const Scalar rhs) const

◆ operator=() [1/2]

Scalar & AMP::Scalar::operator= ( const Scalar )
default

Assignment operator.

◆ operator=() [2/2]

Scalar & AMP::Scalar::operator= ( Scalar &&  )
default

Move operator.

◆ operator==()

bool AMP::Scalar::operator== ( const Scalar rhs) const

◆ operator>()

bool AMP::Scalar::operator> ( const Scalar rhs) const

◆ operator>=()

bool AMP::Scalar::operator>= ( const Scalar rhs) const

◆ print()

void AMP::Scalar::print ( std::ostream &  out) const

Print the value to a stream.

◆ sqrt()

Scalar AMP::Scalar::sqrt ( ) const

◆ store()

template<class TYPE >
void AMP::Scalar::store ( const TYPE &  x)
inlineprivate

◆ type()

const auto & AMP::Scalar::type ( ) const
inline

Return the storage type.

Definition at line 72 of file Scalar.h.

References d_data.

◆ zero()

Scalar AMP::Scalar::zero ( ) const

Return a zero.

Return a zero as if it were created by the same type used to create *this

Member Data Documentation

◆ d_data

std::any AMP::Scalar::d_data
private

Definition at line 158 of file Scalar.h.

Referenced by has_value(), and type().

◆ d_hash

uint32_t AMP::Scalar::d_hash = 0
private

Definition at line 157 of file Scalar.h.

Referenced by getTypeHash().

◆ d_type

char AMP::Scalar::d_type = 0
private

Definition at line 156 of file Scalar.h.

Referenced by is_complex(), is_floating_point(), and is_integral().


The documentation for this class was generated from the following file:



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:42.
Comments on this page