units
Use physical dimensions at compile-time or run-time.
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
vnix::units::statdim_base< D > Struct Template Reference

Base-type for a dimensioned value whose dimension is specified statically at compile-time by way of a template parameter. More...

#include <statdim-base.hpp>

Inheritance diagram for vnix::units::statdim_base< D >:
[legend]

Public Types

using recip_basedim = statdim_base< recip_dim.encode()>
 Base-dimension-type corresponding to reciprocal of dimensioned quantity. More...
 

Public Member Functions

constexpr statdim_base (dim dd)
 Check for compatibility on contruction from dim. More...
 
constexpr statdim_base ()
 Allow default construction. More...
 

Static Public Member Functions

static constexpr dim d ()
 Exponent for each unit in dimensioned quantity. More...
 
static constexpr void number ()
 Throw if dimension be non-null. More...
 
static constexpr void comparison (statdim_base)
 Test for comparison of dimensioned values. More...
 
static constexpr void comparison (dyndim_base const &db)
 Test for comparison of dimensioned values. More...
 
static constexpr auto sum (statdim_base)
 Dimension for sum of dimensioned values. More...
 
static constexpr dyndim_base sum (dyndim_base const &db)
 Dimension for sum of dimensioned values. More...
 
static constexpr auto diff (statdim_base)
 Dimension for difference of dimensioned values. More...
 
static constexpr dyndim_base diff (dyndim_base const &db)
 Dimension for difference of dimensioned values. More...
 
template<dim::word OD>
static constexpr auto prod (statdim_base< OD >)
 Dimension for product of dimensioned values. More...
 
static constexpr dyndim_base prod (dyndim_base const &db)
 Dimension for product of dimensioned values. More...
 
template<dim::word OD>
static constexpr auto quot (statdim_base< OD >)
 Dimension for quotient of dimensioned values. More...
 
static constexpr dyndim_base quot (dyndim_base const &db)
 Dimension for quotient of dimensioned values. More...
 
static constexpr recip_basedim recip ()
 Dimension for reciprocal of dimensioned value. More...
 
template<int64_t PN, int64_t PD = 1>
static constexpr auto pow ()
 Dimension for rational power of dimensioned value. More...
 
static constexpr dyndim_base pow (dim::rat p)
 Dimension for rational power of dimensioned value. More...
 
static constexpr auto sqrt ()
 Dimension for square-root of dimensioned value. More...
 

Static Public Attributes

static constexpr auto recip_dim = nul_dim - d()
 Dimensions corresponding to reciprocal of dimensioned quantity. More...
 

Detailed Description

template<dim::word D>
struct vnix::units::statdim_base< D >

Base-type for a dimensioned value whose dimension is specified statically at compile-time by way of a template parameter.

The dimension is specified as a set of exponents, one for each of the five base dimensions (time, length, mass, charge, and temperature).

For statdim_base, the dimension is always known statically at compile-time. For dyndim_base, the dimension is known statically at compile-time only if the dimension be specified to the constructor as a constant expression.

Template Parameters
DEncoding of dimensional exponents as a dim::word.

Definition at line 29 of file statdim-base.hpp.

Member Typedef Documentation

template<dim::word D>
using vnix::units::statdim_base< D >::recip_basedim = statdim_base<recip_dim.encode()>

Base-dimension-type corresponding to reciprocal of dimensioned quantity.

Definition at line 96 of file statdim-base.hpp.

Constructor & Destructor Documentation

template<dim::word D>
constexpr vnix::units::statdim_base< D >::statdim_base ( dim  dd)
inline

Check for compatibility on contruction from dim.

Parameters
ddCandidate dimension.

Definition at line 32 of file statdim-base.hpp.

32  {
33  if (d() != dd) {
34  throw "attempt to construct from incompatible dimension";
35  }
36  }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.

Here is the caller graph for this function:

template<dim::word D>
constexpr vnix::units::statdim_base< D >::statdim_base ( )
inline

Allow default construction.

Definition at line 38 of file statdim-base.hpp.

Member Function Documentation

template<dim::word D>
static constexpr void vnix::units::statdim_base< D >::comparison ( statdim_base< D >  )
inlinestatic

Test for comparison of dimensioned values.

Definition at line 49 of file statdim-base.hpp.

49 {}
template<dim::word D>
constexpr void vnix::units::statdim_base< D >::comparison ( dyndim_base const &  db)
static

Test for comparison of dimensioned values.

Definition at line 138 of file statdim-base.hpp.

138  {
139  if (d() != db.d()) { throw "incompatible dimensions for comparison"; }
140 }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.

Here is the call graph for this function:

template<dim::word D>
static constexpr dim vnix::units::statdim_base< D >::d ( )
inlinestatic

Exponent for each unit in dimensioned quantity.

Definition at line 41 of file statdim-base.hpp.

41 { return dim(D); }
basic_dim< dim_base_off > dim
Define dim as specification of basic_dim by way of YAML- and ERB-generated type dim_base_off.
Definition: dim.hpp:260

Here is the caller graph for this function:

template<dim::word D>
static constexpr auto vnix::units::statdim_base< D >::diff ( statdim_base< D >  )
inlinestatic

Dimension for difference of dimensioned values.

Definition at line 61 of file statdim-base.hpp.

61 { return statdim_base(); }
constexpr statdim_base()
Allow default construction.

Here is the caller graph for this function:

template<dim::word D>
constexpr dyndim_base vnix::units::statdim_base< D >::diff ( dyndim_base const &  db)
static

Dimension for difference of dimensioned values.

Definition at line 153 of file statdim-base.hpp.

153  {
154  if (d() != db.d()) { throw "incompatible dimensions for subtraction"; }
155  return d();
156 }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.

Here is the call graph for this function:

Here is the caller graph for this function:

template<dim::word D>
static constexpr void vnix::units::statdim_base< D >::number ( )
inlinestatic

Throw if dimension be non-null.

Definition at line 44 of file statdim-base.hpp.

44  {
45  if (d() != nul_dim) { throw "dimensioned quantity is not a number"; }
46  }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.
static constexpr dim nul_dim
Null dimension.
Definition: dim.hpp:263
template<dim::word D>
template<int64_t PN, int64_t PD = 1>
static constexpr auto vnix::units::statdim_base< D >::pow ( )
inlinestatic

Dimension for rational power of dimensioned value.

Template Parameters
PNNumerator of power.
PDDenominator of power.
Returns
Dimension of result.

Definition at line 106 of file statdim-base.hpp.

106  {
107  dim::word constexpr rd = (d() * dim::rat(PN, PD)).encode();
108  return statdim_base<rd>();
109  }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.
rational< 4, 2 > rat
Type of rational for dimensioned values.
Definition: dim.hpp:26
typename int_types< NUM_BITS >::US word
Type of unsigned word in which dimensions are encoded.
Definition: dim.hpp:35
Base-type for a dimensioned value whose dimension is specified statically at compile-time by way of a...
template<dim::word D>
constexpr dyndim_base vnix::units::statdim_base< D >::pow ( dim::rat  p)
static

Dimension for rational power of dimensioned value.

Parameters
pRational power.
Returns
Dimension of result.

Definition at line 174 of file statdim-base.hpp.

174  {
175  return d() * p;
176 }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.

Here is the call graph for this function:

Here is the caller graph for this function:

template<dim::word D>
template<dim::word OD>
static constexpr auto vnix::units::statdim_base< D >::prod ( statdim_base< OD >  )
inlinestatic

Dimension for product of dimensioned values.

Template Parameters
ODEncoding of factor's dimension in dim::word.
Returns
Dimension of product.

Definition at line 69 of file statdim-base.hpp.

69  {
70  dim::word constexpr rd = (d() + dim(OD)).encode();
71  return statdim_base<rd>();
72  }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.
typename int_types< NUM_BITS >::US word
Type of unsigned word in which dimensions are encoded.
Definition: dim.hpp:35
basic_dim< dim_base_off > dim
Define dim as specification of basic_dim by way of YAML- and ERB-generated type dim_base_off.
Definition: dim.hpp:260
Base-type for a dimensioned value whose dimension is specified statically at compile-time by way of a...
template<dim::word D>
constexpr dyndim_base vnix::units::statdim_base< D >::prod ( dyndim_base const &  db)
static

Dimension for product of dimensioned values.

Parameters
dbFactor's dimension.
Returns
Dimension of product.

Definition at line 161 of file statdim-base.hpp.

161  {
162  return d() + db.d();
163 }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.

Here is the call graph for this function:

Here is the caller graph for this function:

template<dim::word D>
template<dim::word OD>
static constexpr auto vnix::units::statdim_base< D >::quot ( statdim_base< OD >  )
inlinestatic

Dimension for quotient of dimensioned values.

Template Parameters
DEncoding of divisor's dimension in dim::word.
Returns
Dimension of quotient.

Definition at line 82 of file statdim-base.hpp.

82  {
83  dim::word constexpr rd = (d() - dim(OD)).encode();
84  return statdim_base<rd>();
85  }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.
typename int_types< NUM_BITS >::US word
Type of unsigned word in which dimensions are encoded.
Definition: dim.hpp:35
basic_dim< dim_base_off > dim
Define dim as specification of basic_dim by way of YAML- and ERB-generated type dim_base_off.
Definition: dim.hpp:260
Base-type for a dimensioned value whose dimension is specified statically at compile-time by way of a...
template<dim::word D>
constexpr dyndim_base vnix::units::statdim_base< D >::quot ( dyndim_base const &  db)
static

Dimension for quotient of dimensioned values.

Parameters
dbDivisor's dimension.
Returns
Dimension of quotient.

Definition at line 168 of file statdim-base.hpp.

168  {
169  return d() - db.d();
170 }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.

Here is the call graph for this function:

Here is the caller graph for this function:

template<dim::word D>
static constexpr recip_basedim vnix::units::statdim_base< D >::recip ( )
inlinestatic

Dimension for reciprocal of dimensioned value.

Returns
Dimension of reciprocal.

Definition at line 100 of file statdim-base.hpp.

100 { return recip_basedim(); }
statdim_base< recip_dim.encode()> recip_basedim
Base-dimension-type corresponding to reciprocal of dimensioned quantity.

Here is the caller graph for this function:

template<dim::word D>
static constexpr auto vnix::units::statdim_base< D >::sqrt ( )
inlinestatic

Dimension for square-root of dimensioned value.

Returns
Dimension of square-root.

Definition at line 118 of file statdim-base.hpp.

118  {
119  dim::word constexpr rd = (d() / dim::rat(2)).encode();
120  return statdim_base<rd>();
121  }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.
rational< 4, 2 > rat
Type of rational for dimensioned values.
Definition: dim.hpp:26
typename int_types< NUM_BITS >::US word
Type of unsigned word in which dimensions are encoded.
Definition: dim.hpp:35
Base-type for a dimensioned value whose dimension is specified statically at compile-time by way of a...

Here is the caller graph for this function:

template<dim::word D>
static constexpr auto vnix::units::statdim_base< D >::sum ( statdim_base< D >  )
inlinestatic

Dimension for sum of dimensioned values.

Definition at line 55 of file statdim-base.hpp.

55 { return statdim_base(); }
constexpr statdim_base()
Allow default construction.

Here is the caller graph for this function:

template<dim::word D>
constexpr dyndim_base vnix::units::statdim_base< D >::sum ( dyndim_base const &  db)
static

Dimension for sum of dimensioned values.

Definition at line 145 of file statdim-base.hpp.

145  {
146  if (d() != db.d()) { throw "incompatible dimensions for addition"; }
147  return d();
148 }
static constexpr dim d()
Exponent for each unit in dimensioned quantity.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

template<dim::word D>
constexpr auto vnix::units::statdim_base< D >::recip_dim = nul_dim - d()
static

Dimensions corresponding to reciprocal of dimensioned quantity.

Definition at line 93 of file statdim-base.hpp.


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