Web Analytics Made Easy - Statcounter
Skip to content

Class SBDQuantityType#

template <typename Unit, typename Value>

ClassList > SBDQuantityType

This template class defines physical quantity types. More...

  • #include <SBDQuantityType.hpp>

Public Types#

Type Name
typedef SBDQuantityType< Unit, Value > Type
The quantity type.
typedef Unit UnitType
The unit type of the quantity.
typedef Value ValueType
The value type of the quantity.

Public Static Attributes#

Type Name
const SBDQuantityType< Unit, Value > one
The one value.
const SBDQuantityType< Unit, Value > zero
The zero value.

Public Functions#

Type Name
constexpr SBDQuantityType () noexcept
Constructs a physical quantity with default value.
constexpr SBDQuantityType (Value v) noexcept
Constructs a physical quantity with value v .
constexpr SBDQuantityType (const SBDQuantityType< Unit, Value > & q)
Constructs a physical quantity from quantity q .
constexpr Value const & getValue () noexcept const
Returns the value.
void getValue (double * array) const
Stores the value as a double in array [0].
void getValue (float * array) const
Stores the value as a float in array [0].
operator SBDQuantityType< UnitB, Value > () const
Converts this physical quantity to unit UnitB .
constexpr bool operator!= (const SBDQuantityType< UnitB, Value > & q) const
Returns true if this physical quantity is different from physical quantity q .
constexpr bool operator!= (double d) const
Returns true if this physical quantity is different from double d (for dimensionless physical quantities only)
constexpr SBDQuantityType< Unit, Value > operator* (double d) noexcept const
Returns the product of this physical quantity with double d .
SBDQuantityType< typename SBDQuantityUnitMultiplication< Unit, UnitB >::UnitType, Value > operator* (const SBDQuantityType< UnitB, Value > & q) const
Returns the product of this physical quantity with physical quantity q .
constexpr SBDQuantityType< Unit, Value > & operator*= (double d) noexcept
Multiplies this physical quantity with double d .
constexpr SBDQuantityType< Unit, Value > & operator*= (const SBDQuantityType< UnitB, Value > & q)
Multiplies this physical quantity with physical quantity q (for dimensionless physical quantities only)
constexpr SBDQuantityType< Unit, Value > operator+ (const SBDQuantityType< Unit, Value > & q) const
Returns the sum of this physical quantity with physical quantity q .
constexpr SBDQuantityType< Unit, Value > operator+ (double d) noexcept const
Returns the sum of this physical quantity with double d (for dimensionless physical quantities only)
constexpr SBDQuantityType< Unit, Value > & operator+= (const SBDQuantityType< Unit, Value > & q)
Adds physical quantity q to this physical quantity.
constexpr SBDQuantityType< Unit, Value > & operator+= (double d) noexcept
Add double d to this physical quantity (for dimensionless physical quantities only)
constexpr SBDQuantityType< Unit, Value > operator- () noexcept const
Returns the opposite of the physical quantity.
constexpr SBDQuantityType< Unit, Value > operator- (const SBDQuantityType< Unit, Value > & q) const
Returns the difference between this physical quantity and physical quantity q .
constexpr SBDQuantityType< Unit, Value > operator- (double d) noexcept const
Returns the difference between this physical quantity and double d (for dimensionless physical quantities only)
constexpr SBDQuantityType< Unit, Value > & operator-= (const SBDQuantityType< Unit, Value > & q)
Subtracts physical quantity q from this physical quantity.
constexpr SBDQuantityType< Unit, Value > & operator-= (double d) noexcept
Subtracts double d from this physical quantity (for dimensionless physical quantities only)
constexpr SBDQuantityType< Unit, Value > operator/ (double d) noexcept const
Returns the division of this physical quantity by double d .
SBDQuantityType< typename SBDQuantityUnitDivision< Unit, UnitB >::UnitType, Value > operator/ (const SBDQuantityType< UnitB, Value > & q) const
Returns the division of this physical quantity by physical quantity q .
constexpr SBDQuantityType< Unit, Value > & operator/= (double d) noexcept
Divides this physical quantity by double d .
constexpr SBDQuantityType< Unit, Value > & operator/= (const SBDQuantityType< UnitB, Value > & q)
Divides this physical quantity by physical quantity q (for dimensionless physical quantities only)
constexpr bool operator< (const SBDQuantityType< UnitB, Value > & q) const
Returns true if this physical quantity is smaller than physical quantity q .
constexpr bool operator< (double d) const
Returns true if this physical quantity is smaller than double d (for dimensionless physical quantities only)
constexpr bool operator<= (const SBDQuantityType< UnitB, Value > & q) const
Returns true if this physical quantity is smaller than or equal to physical quantity q .
constexpr bool operator<= (double d) const
Returns true if this physical quantity is smaller than or equal to double d (for dimensionless physical quantities only)
SBDQuantityType< Unit, Value > & operator= (const SBDQuantityType< Unit, Value > & q)
Copy the physical quantity q .
SBDQuantityType< Unit, Value > & operator= (double d) noexcept
Assign the double d to the physical quantity (for dimensionless physical quantities only)
constexpr bool operator== (const SBDQuantityType< UnitB, Value > & q) const
Returns true if this physical quantity is equal to physical quantity q .
constexpr bool operator== (double d) const
Returns true if this physical quantity is equal to double d (for dimensionless physical quantities only)
constexpr bool operator> (const SBDQuantityType< UnitB, Value > & q) const
Returns true if this physical quantity is larger than physical quantity q .
constexpr bool operator> (double d) const
Returns true if this physical quantity is larger than double d (for dimensionless physical quantities only)
constexpr bool operator>= (const SBDQuantityType< UnitB, Value > & q) const
Returns true if this physical quantity is larger than or equal to physical quantity q .
constexpr bool operator>= (double d) const
Returns true if this physical quantity is larger than or equal to double d (for dimensionless physical quantities only)
void print (bool fullName=false) const
Prints the physical quantity (with a full unit name when fullName is true)
void serialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER) const
Serializes the quantity using the provided serializer .
void setValue (const Value & v)
Sets the value to v .
void setZero () noexcept
Sets the value to zero.
std::string toStdString (bool fullName=false) const
Converts the physical quantity to a string (with a full unit name when fullName is true)
void unserialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER)
Unserializes the quantity using the provided serializer .

Public Static Functions#

Type Name
void diagonalize (const SBDQuantityType< Unit, Value >(&) matrix, SBDQuantityType< Unit, Value >(&) eigenValues, SBDQuantityType< UnitB, Value >(&) eigenVectors)
SBDQuantityType< Unit, Value > fromLinearInterpolation (const SBDQuantityType< Unit, Value > & q0, const SBDQuantityType< Unit, Value > & q1, double alpha)
Returns a linear interpolation between two physical quantities q0 andq1 for a parameteralpha in the closed unit interval [0, 1].

Detailed Description#

Template parameters:

  • Unit The unit type of the physical quantity
  • Value The value type of the physical quantity

This template class is used to define physical quantity types, i.e. types that represent values associated to units. Precisely, a physical quantity has a both a value of type Value (e.g. double), and a unit type.

SBQuantity::force f = SBQuantity::nanonewton(17.0); // f = 17 nanonewton
SBQuantity::length l = SBQuantity::picometer(8.0);  // l = 8 picometer
SBQuantity::energy w = f * l;                       // w = 136 zeptojoule

Most of the time, developers of SAMSON Extensions do not have to use this template, but may directly use some predefined types, e.g. SBQuantity::nanonewton, SBQuantity::angstrom, etc.

Please refer to the description of SAMSON's unit system for more information.

Short name: SBQuantityType

See also: SAMSON's unit system

Public Types Documentation#

typedef Type#

The quantity type.

typedef SBDQuantityType<Unit,Value> Type;


typedef UnitType#

The unit type of the quantity.

typedef Unit UnitType;


typedef ValueType#

The value type of the quantity.

typedef Value ValueType;


Public Static Attributes Documentation#

variable one#

The one value.

SBDQuantityType< Unit, Value > const one;


variable zero#

The zero value.

SBDQuantityType< Unit, Value > const zero;


Public Functions Documentation#

function SBDQuantityType [1/3]#

Constructs a physical quantity with default value.

inline constexpr SBDQuantityType::SBDQuantityType () noexcept


function SBDQuantityType [2/3]#

Constructs a physical quantity with value v .

inline explicit constexpr SBDQuantityType::SBDQuantityType (
    Value v
) noexcept


function SBDQuantityType [3/3]#

Constructs a physical quantity from quantity q .

inline constexpr SBDQuantityType::SBDQuantityType (
    const SBDQuantityType < Unit, Value > & q
) 


function getValue [1/3]#

Returns the value.

inline constexpr Value const & SBDQuantityType::getValue () noexcept const


function getValue [2/3]#

Stores the value as a double in array [0].

inline void SBDQuantityType::getValue (
    double * array
) const


function getValue [3/3]#

Stores the value as a float in array [0].

inline void SBDQuantityType::getValue (
    float * array
) const


function operator SBDQuantityType< UnitB, Value >#

Converts this physical quantity to unit UnitB .

template<typename UnitB>
inline SBDQuantityType::operator SBDQuantityType< UnitB, Value > () const


function operator!=#

Returns true if this physical quantity is different from physical quantity q .

template<typename UnitB>
inline constexpr bool SBDQuantityType::operator!= (
    const SBDQuantityType < UnitB, Value > & q
) const


function operator!=#

Returns true if this physical quantity is different from double d (for dimensionless physical quantities only)

inline constexpr bool SBDQuantityType::operator!= (
    double d
) const


function operator*#

Returns the product of this physical quantity with double d .

inline constexpr SBDQuantityType < Unit, Value > SBDQuantityType::operator* (
    double d
) noexcept const


function operator*#

Returns the product of this physical quantity with physical quantity q .

template<typename UnitB>
inline SBDQuantityType < typename SBDQuantityUnitMultiplication< Unit, UnitB > ::UnitType , Value > SBDQuantityType::operator* (
    const SBDQuantityType < UnitB, Value > & q
) const


function operator*=#

Multiplies this physical quantity with double d .

inline constexpr SBDQuantityType < Unit, Value > & SBDQuantityType::operator*= (
    double d
) noexcept


function operator*=#

Multiplies this physical quantity with physical quantity q (for dimensionless physical quantities only)

template<typename UnitB>
inline constexpr SBDQuantityType < Unit, Value > & SBDQuantityType::operator*= (
    const SBDQuantityType < UnitB, Value > & q
) 


function operator+#

Returns the sum of this physical quantity with physical quantity q .

inline constexpr SBDQuantityType < Unit, Value > SBDQuantityType::operator+ (
    const SBDQuantityType < Unit, Value > & q
) const


function operator+#

Returns the sum of this physical quantity with double d (for dimensionless physical quantities only)

inline constexpr SBDQuantityType < Unit, Value > SBDQuantityType::operator+ (
    double d
) noexcept const


function operator+=#

Adds physical quantity q to this physical quantity.

inline constexpr SBDQuantityType < Unit, Value > & SBDQuantityType::operator+= (
    const SBDQuantityType < Unit, Value > & q
) 


function operator+=#

Add double d to this physical quantity (for dimensionless physical quantities only)

inline constexpr SBDQuantityType < Unit, Value > & SBDQuantityType::operator+= (
    double d
) noexcept


function operator-#

Returns the opposite of the physical quantity.

inline constexpr SBDQuantityType < Unit, Value > SBDQuantityType::operator- () noexcept const


function operator-#

Returns the difference between this physical quantity and physical quantity q .

inline constexpr SBDQuantityType < Unit, Value > SBDQuantityType::operator- (
    const SBDQuantityType < Unit, Value > & q
) const


function operator-#

Returns the difference between this physical quantity and double d (for dimensionless physical quantities only)

inline constexpr SBDQuantityType < Unit, Value > SBDQuantityType::operator- (
    double d
) noexcept const


function operator-=#

Subtracts physical quantity q from this physical quantity.

inline constexpr SBDQuantityType < Unit, Value > & SBDQuantityType::operator-= (
    const SBDQuantityType < Unit, Value > & q
) 


function operator-=#

Subtracts double d from this physical quantity (for dimensionless physical quantities only)

inline constexpr SBDQuantityType < Unit, Value > & SBDQuantityType::operator-= (
    double d
) noexcept


function operator/#

Returns the division of this physical quantity by double d .

inline constexpr SBDQuantityType < Unit, Value > SBDQuantityType::operator/ (
    double d
) noexcept const


function operator/#

Returns the division of this physical quantity by physical quantity q .

template<typename UnitB>
inline SBDQuantityType < typename SBDQuantityUnitDivision< Unit, UnitB > ::UnitType , Value > SBDQuantityType::operator/ (
    const SBDQuantityType < UnitB, Value > & q
) const


function operator/=#

Divides this physical quantity by double d .

inline constexpr SBDQuantityType < Unit, Value > & SBDQuantityType::operator/= (
    double d
) noexcept


function operator/=#

Divides this physical quantity by physical quantity q (for dimensionless physical quantities only)

template<typename UnitB>
inline constexpr SBDQuantityType < Unit, Value > & SBDQuantityType::operator/= (
    const SBDQuantityType < UnitB, Value > & q
) 


function operator<#

Returns true if this physical quantity is smaller than physical quantity q .

template<typename UnitB>
inline constexpr bool SBDQuantityType::operator< (
    const SBDQuantityType < UnitB, Value > & q
) const


function operator<#

Returns true if this physical quantity is smaller than double d (for dimensionless physical quantities only)

inline constexpr bool SBDQuantityType::operator< (
    double d
) const


function operator<=#

Returns true if this physical quantity is smaller than or equal to physical quantity q .

template<typename UnitB>
inline constexpr bool SBDQuantityType::operator<= (
    const SBDQuantityType < UnitB, Value > & q
) const


function operator<=#

Returns true if this physical quantity is smaller than or equal to double d (for dimensionless physical quantities only)

inline constexpr bool SBDQuantityType::operator<= (
    double d
) const


function operator=#

Copy the physical quantity q .

inline SBDQuantityType < Unit, Value > & SBDQuantityType::operator= (
    const SBDQuantityType < Unit, Value > & q
) 


function operator=#

Assign the double d to the physical quantity (for dimensionless physical quantities only)

inline SBDQuantityType < Unit, Value > & SBDQuantityType::operator= (
    double d
) noexcept


function operator==#

Returns true if this physical quantity is equal to physical quantity q .

template<typename UnitB>
inline constexpr bool SBDQuantityType::operator== (
    const SBDQuantityType < UnitB, Value > & q
) const


function operator==#

Returns true if this physical quantity is equal to double d (for dimensionless physical quantities only)

inline constexpr bool SBDQuantityType::operator== (
    double d
) const


function operator>#

Returns true if this physical quantity is larger than physical quantity q .

template<typename UnitB>
inline constexpr bool SBDQuantityType::operator> (
    const SBDQuantityType < UnitB, Value > & q
) const


function operator>#

Returns true if this physical quantity is larger than double d (for dimensionless physical quantities only)

inline constexpr bool SBDQuantityType::operator> (
    double d
) const


function operator>=#

Returns true if this physical quantity is larger than or equal to physical quantity q .

template<typename UnitB>
inline constexpr bool SBDQuantityType::operator>= (
    const SBDQuantityType < UnitB, Value > & q
) const


function operator>=#

Returns true if this physical quantity is larger than or equal to double d (for dimensionless physical quantities only)

inline constexpr bool SBDQuantityType::operator>= (
    double d
) const


function print#

Prints the physical quantity (with a full unit name when fullName is true)

inline void SBDQuantityType::print (
    bool fullName=false
) const


function serialize#

Serializes the quantity using the provided serializer .

inline void SBDQuantityType::serialize (
    SBCSerializer * serializer,
    const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER
) const


function setValue#

Sets the value to v .

inline void SBDQuantityType::setValue (
    const Value & v
) 


function setZero#

Sets the value to zero.

inline void SBDQuantityType::setZero () noexcept


function toStdString#

Converts the physical quantity to a string (with a full unit name when fullName is true)

inline std::string SBDQuantityType::toStdString (
    bool fullName=false
) const


function unserialize#

Unserializes the quantity using the provided serializer .

inline void SBDQuantityType::unserialize (
    SBCSerializer * serializer,
    const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER
) 


Public Static Functions Documentation#

function diagonalize#

template<typename UnitB, int n>
static inline void SBDQuantityType::diagonalize (
    const SBDQuantityType < Unit, Value >(&) matrix,
    SBDQuantityType < Unit, Value >(&) eigenValues,
    SBDQuantityType < UnitB, Value >(&) eigenVectors
) 

function fromLinearInterpolation#

Returns a linear interpolation between two physical quantities q0 andq1 for a parameteralpha in the closed unit interval [0, 1].

static inline SBDQuantityType < Unit, Value > SBDQuantityType::fromLinearInterpolation (
    const SBDQuantityType < Unit, Value > & q0,
    const SBDQuantityType < Unit, Value > & q1,
    double alpha
)