Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Namespaces | Classes | Functions | Variables
numbers Namespace Reference

Namespaces

namespace  internal
 

Classes

struct  NumberTraits
 
struct  NumberTraits< std::complex< number > >
 

Functions

bool is_finite (const double x)
 
bool is_finite (const std::complex< double > &x)
 
bool is_finite (const std::complex< float > &x)
 
bool is_finite (const std::complex< long double > &x)
 
template<typename Number1 , typename Number2 >
constexpr bool values_are_equal (const Number1 &value_1, const Number2 &value_2)
 
template<typename Number1 , typename Number2 >
bool values_are_not_equal (const Number1 &value_1, const Number2 &value_2)
 
template<typename Number >
constexpr bool value_is_zero (const Number &value)
 
template<typename Number1 , typename Number2 >
bool value_is_less_than (const Number1 &value_1, const Number2 &value_2)
 
template<typename Number1 , typename Number2 >
bool value_is_less_than_or_equal_to (const Number1 &value_1, const Number2 &value_2)
 
template<typename Number1 , typename Number2 >
bool value_is_greater_than (const Number1 &value_1, const Number2 &value_2)
 
template<typename Number1 , typename Number2 >
bool value_is_greater_than_or_equal_to (const Number1 &value_1, const Number2 &value_2)
 
bool is_nan (const double x)
 
bool values_are_equal (const adouble &value_1, const adouble &value_2)
 
template<typename Number >
bool values_are_equal (const adouble &value_1, const Number &value_2)
 
template<typename Number >
bool values_are_equal (const Number &value_1, const adouble &value_2)
 
bool value_is_less_than (const adouble &value_1, const adouble &value_2)
 
template<typename Number >
bool value_is_less_than (const adouble &value_1, const Number &value_2)
 
template<typename Number >
bool value_is_less_than (const Number &value_1, const adouble &value_2)
 
template<class T >
signaling_nan ()
 

Variables

static constexpr double E = 2.7182818284590452354
 
static constexpr double LOG2E = 1.4426950408889634074
 
static constexpr double LOG10E = 0.43429448190325182765
 
static constexpr double LN2 = 0.69314718055994530942
 
static constexpr double LN10 = 2.30258509299404568402
 
static constexpr double PI = 3.14159265358979323846
 
static constexpr double PI_2 = 1.57079632679489661923
 
static constexpr double PI_4 = 0.78539816339744830962
 
static constexpr double SQRT2 = 1.41421356237309504880
 
static constexpr double SQRT1_2 = 0.70710678118654752440
 
static const unsigned int invalid_unsigned_int
 
const types::global_dof_index invalid_size_type
 
const types::fe_index invalid_fe_index = static_cast<types::fe_index>(-1)
 
const types::global_dof_index invalid_dof_index
 
const types::coarse_cell_id invalid_coarse_cell_id
 
const types::material_id invalid_material_id
 
const types::boundary_id invalid_boundary_id
 
const types::boundary_id internal_face_boundary_id
 
const types::manifold_id flat_manifold_id
 
const types::subdomain_id invalid_subdomain_id
 
const types::subdomain_id artificial_subdomain_id
 

Detailed Description

Namespace for the declaration of universal constants. Since the availability in math.h is not always guaranteed, we put them here. Since this file is included by base/config.h, they are available to the whole library.

The constants defined here are a subset of the M_XXX constants sometimes declared in the system include file math.h, but without the prefix M_.

In addition to that, we declare invalid_unsigned_int to be the largest unsigned integer representable; this value is widely used in the library as a marker for an invalid index, an invalid size of an array, and similar purposes.

Function Documentation

◆ is_finite() [1/4]

bool numbers::is_finite ( const double  x)
inline

Return true if the given value is a finite floating point number, i.e. is neither plus or minus infinity nor NaN (not a number).

Note that the argument type of this function is double. In other words, if you give a very large number of type long double, this function may return false even if the number is finite with respect to type long double.

Definition at line 538 of file numbers.h.

◆ is_finite() [2/4]

bool numbers::is_finite ( const std::complex< double > &  x)
inline

Return true if real and imaginary parts of the given complex number are finite.

Definition at line 546 of file numbers.h.

◆ is_finite() [3/4]

bool numbers::is_finite ( const std::complex< float > &  x)
inline

Return true if real and imaginary parts of the given complex number are finite.

Definition at line 556 of file numbers.h.

◆ is_finite() [4/4]

bool numbers::is_finite ( const std::complex< long double > &  x)
inline

Return true if real and imaginary parts of the given complex number are finite.

Again may not work correctly if real or imaginary parts are very large numbers that are infinite in terms of double, but finite with respect to long double.

Definition at line 566 of file numbers.h.

◆ values_are_equal() [1/4]

template<typename Number1 , typename Number2 >
constexpr bool numbers::values_are_equal ( const Number1 &  value_1,
const Number2 &  value_2 
)
constexpr

Return whether two numbers are equal to one another.

For intricate data types (e.g. some automatically differentiable numbers), this function returns the result of the comparison of scalar values stored by the input arguments.

Note
This function expects that value_2 is castable to the type of value_1.

Definition at line 923 of file numbers.h.

◆ values_are_not_equal()

template<typename Number1 , typename Number2 >
bool numbers::values_are_not_equal ( const Number1 &  value_1,
const Number2 &  value_2 
)
inline

Return whether two numbers are not equal to one another.

For intricate data types (e.g. some automatically differentiable numbers), this function returns the result of the comparison of scalar values stored by the input arguments.

Note
This function expects that value_2 is castable to the type of value_1.

Definition at line 931 of file numbers.h.

◆ value_is_zero()

template<typename Number >
constexpr bool numbers::value_is_zero ( const Number &  value)
constexpr

Return whether or not a value is equal to zero.

For intricate data types (e.g. some automatically differentiable numbers), this function returns the result of the comparison of scalar values stored by the input arguments.

Definition at line 939 of file numbers.h.

◆ value_is_less_than() [1/4]

template<typename Number1 , typename Number2 >
bool numbers::value_is_less_than ( const Number1 &  value_1,
const Number2 &  value_2 
)
inline

Return whether value_1 is less than that of value_2.

For intricate data types (e.g. some automatically differentiable numbers), this function returns the result of the comparison of scalar values stored by the input arguments.

Note
This function expects that value_2 is castable to the type of value_1.

Definition at line 947 of file numbers.h.

◆ value_is_less_than_or_equal_to()

template<typename Number1 , typename Number2 >
bool numbers::value_is_less_than_or_equal_to ( const Number1 &  value_1,
const Number2 &  value_2 
)
inline

Return whether value_1 is less than or equal to that of value_2.

For intricate data types (e.g. some automatically differentiable numbers), this function returns the result of the comparison of scalar values stored by the input arguments.

Note
This function expects that value_2 is castable to the type of value_1.

Definition at line 955 of file numbers.h.

◆ value_is_greater_than()

template<typename Number1 , typename Number2 >
bool numbers::value_is_greater_than ( const Number1 &  value_1,
const Number2 &  value_2 
)

Return whether value_1 is greater than that of value_2.

For intricate data types (e.g. some automatically differentiable numbers), this function returns the result of the comparison of scalar values stored by the input arguments.

Note
This function expects that value_2 is castable to the type of value_1.

Definition at line 964 of file numbers.h.

◆ value_is_greater_than_or_equal_to()

template<typename Number1 , typename Number2 >
bool numbers::value_is_greater_than_or_equal_to ( const Number1 &  value_1,
const Number2 &  value_2 
)
inline

Return whether value_1 is greater than or equal to that of value_2.

For intricate data types (e.g. some automatically differentiable numbers), this function returns the result of the comparison of scalar values stored by the input arguments.

Note
This function expects that value_2 is castable to the type of value_1.

Definition at line 972 of file numbers.h.

◆ is_nan()

bool numbers::is_nan ( const double  x)
inline

Definition at line 530 of file numbers.h.

◆ values_are_equal() [2/4]

bool numbers::values_are_equal ( const adouble &  value_1,
const adouble &  value_2 
)

Return whether two numbers are equal to one another. For intricate data types (e.g. some automatically differentiable numbers), this function returns only whether the scalar values stored by the input values are equal.

Note
When ADOL-C is compiled with the "advanced branching" feature, then this specialization is only intended for use in assertions and other code paths that do not affect the end result of a computation.

Definition at line 63 of file adolc_number_types.cc.

◆ values_are_equal() [3/4]

template<typename Number >
bool numbers::values_are_equal ( const adouble &  value_1,
const Number &  value_2 
)

Return whether two numbers are equal to one another. For intricate data types (e.g. some automatically differentiable numbers), this function returns only whether the scalar values stored by the input values are equal.

Note
When ADOL-C is compiled with the "advanced branching" feature, then this specialization is only intended for use in assertions and other code paths that do not affect the end result of a computation.

Definition at line 835 of file numbers.h.

◆ values_are_equal() [4/4]

template<typename Number >
bool numbers::values_are_equal ( const Number &  value_1,
const adouble &  value_2 
)

Return whether two numbers are equal to one another. For intricate data types (e.g. some automatically differentiable numbers), this function returns only whether the scalar values stored by the input values are equal.

Note
When ADOL-C is compiled with the "advanced branching" feature, then this specialization is only intended for use in assertions and other code paths that do not affect the end result of a computation.

Definition at line 855 of file numbers.h.

◆ value_is_less_than() [2/4]

bool numbers::value_is_less_than ( const adouble &  value_1,
const adouble &  value_2 
)

Return whether value_1 is less than that of value_2.

For intricate data types (e.g. some automatically differentiable numbers), this function returns the result of the comparison of scalar values stored by the input arguments.

Note
When ADOL-C is compiled with the "advanced branching" feature, then this specialization is only intended for use in assertions and other code paths that do not affect the end result of a computation.

Definition at line 72 of file adolc_number_types.cc.

◆ value_is_less_than() [3/4]

template<typename Number >
bool numbers::value_is_less_than ( const adouble &  value_1,
const Number &  value_2 
)

Return whether value_1 is less than that of value_2.

For intricate data types (e.g. some automatically differentiable numbers), this function returns the result of the comparison of scalar values stored by the input arguments.

Note
When ADOL-C is compiled with the "advanced branching" feature, then this specialization is only intended for use in assertions and other code paths that do not affect the end result of a computation.

Definition at line 890 of file numbers.h.

◆ value_is_less_than() [4/4]

template<typename Number >
bool numbers::value_is_less_than ( const Number &  value_1,
const adouble &  value_2 
)

Return whether value_1 is less than that of value_2.

For intricate data types (e.g. some automatically differentiable numbers), this function returns the result of the comparison of scalar values stored by the input arguments.

Note
When ADOL-C is compiled with the "advanced branching" feature, then this specialization is only intended for use in assertions and other code paths that do not affect the end result of a computation.

Definition at line 911 of file numbers.h.

◆ signaling_nan()

template<class T >
T numbers::signaling_nan ( )

Provide an object of type T filled with a signaling NaN that will cause an exception when used in a computation. The content of these objects is a "signaling NaN" ("NaN" stands for "not a number", and "signaling" implies that at least on platforms where this is supported, any arithmetic operation using them terminates the program). The purpose of such objects is to use them as markers for invalid objects and arrays that are required to be initialized to valid values at some point, and to trigger an error when this later initialization does not happen before the first use. An example is code such as this:

double x = numbers::signaling_nan<double>();
if (some condition)
{
...much code computing a,b,c...
x = f(a,b,c);
}
else
{
...more code...
// bug: we forgot to assign a value to 'x'.
}
return std::sin(x);
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)

The bug is that the else branch forgot to write a value into the x variable. If your platform supports signaling NaNs, then this mistake will become apparent in the last line above because the program is going to be terminated by a floating point exception: The processor realizes that the code is attempting to do an operation on the signaling NaN still stored in x and aborts the program, thereby facilitating an easy way to find what the problem is. This would not have been an easy bug to find if one had just initialized x to zero in the first line (or just left it uninitialized altogether): In that case, the call to std::sin in the last line would have simply computed the sine of "something" if some condition == false, but this invalid results may not have been obvious to the calling site and would have required a substantial amount of debugging to uncover because downstream computations would simply have been wrong, without any indication of why they are wrong.

Template Parameters
TThe type of the returned invalid object. This type can either be a scalar, or of type Tensor, SymmetricTensor, or DerivativeForm. Other types may be supported if there is a corresponding specialization of the internal::SignalingNaN::NaNInitializer class for this type.
Note
Because the type T is not used as a function argument, the compiler cannot deduce it from the type of arguments. Consequently, you have to provide it explicitly. For example, the line
Tensor<1,dim> tensor = Utilities::signaling_nan<Tensor<1,dim> >();
initializes a tensor with invalid values.

Definition at line 271 of file signaling_nan.h.

Variable Documentation

◆ E

constexpr double numbers::E = 2.7182818284590452354
staticconstexpr

e

Definition at line 234 of file numbers.h.

◆ LOG2E

constexpr double numbers::LOG2E = 1.4426950408889634074
staticconstexpr

log_2 e

Definition at line 239 of file numbers.h.

◆ LOG10E

constexpr double numbers::LOG10E = 0.43429448190325182765
staticconstexpr

log_10 e

Definition at line 244 of file numbers.h.

◆ LN2

constexpr double numbers::LN2 = 0.69314718055994530942
staticconstexpr

log_e 2

Definition at line 249 of file numbers.h.

◆ LN10

constexpr double numbers::LN10 = 2.30258509299404568402
staticconstexpr

log_e 10

Definition at line 254 of file numbers.h.

◆ PI

constexpr double numbers::PI = 3.14159265358979323846
staticconstexpr

pi

Definition at line 259 of file numbers.h.

◆ PI_2

constexpr double numbers::PI_2 = 1.57079632679489661923
staticconstexpr

pi/2

Definition at line 264 of file numbers.h.

◆ PI_4

constexpr double numbers::PI_4 = 0.78539816339744830962
staticconstexpr

pi/4

Definition at line 269 of file numbers.h.

◆ SQRT2

constexpr double numbers::SQRT2 = 1.41421356237309504880
staticconstexpr

sqrt(2)

Definition at line 274 of file numbers.h.

◆ SQRT1_2

constexpr double numbers::SQRT1_2 = 0.70710678118654752440
staticconstexpr

1/sqrt(2)

Definition at line 279 of file numbers.h.

◆ invalid_unsigned_int

const unsigned int numbers::invalid_unsigned_int
static
Initial value:
=
static_cast<unsigned int>(-1)

Representation of the largest number that can be put into an unsigned integer. This value is widely used throughout the library as a marker for an invalid unsigned integer value, such as an invalid array index, an invalid array size, and the like.

Definition at line 213 of file types.h.

◆ invalid_size_type

const types::global_dof_index numbers::invalid_size_type
Initial value:

Representation of the largest number that can be put into a size_type. This value is used throughout the library as a marker for an invalid size_type value, such as an invalid array index, an invalid array size, and the like. Invalid_size_type is equivalent to invalid_dof_index.

Definition at line 222 of file types.h.

◆ invalid_fe_index

const types::fe_index numbers::invalid_fe_index = static_cast<types::fe_index>(-1)

An invalid value for active and future fe indices.

Definition at line 228 of file types.h.

◆ invalid_dof_index

const types::global_dof_index numbers::invalid_dof_index
Initial value:
=
static_cast<types::global_dof_index>(-1)

An invalid value for indices of degrees of freedom.

Definition at line 233 of file types.h.

◆ invalid_coarse_cell_id

const types::coarse_cell_id numbers::invalid_coarse_cell_id
Initial value:
=
static_cast<types::coarse_cell_id>(-1)

An invalid value for coarse cell ids. See the glossary entry on coarse cell IDs for more information.

Definition at line 242 of file types.h.

◆ invalid_material_id

const types::material_id numbers::invalid_material_id
Initial value:
=
static_cast<types::material_id>(-1)

Invalid material_id which we need in several places as a default value. We assume that all material_ids lie in the range [0, invalid_material_id).

Definition at line 250 of file types.h.

◆ invalid_boundary_id

const types::boundary_id numbers::invalid_boundary_id
Initial value:
=
static_cast<types::boundary_id>(-1)

Invalid boundary_id which we need in several places as a default value. We assume that all valid boundary_ids lie in the range [0, invalid_boundary_id).

See also
Glossary entry on boundary indicators

Definition at line 261 of file types.h.

◆ internal_face_boundary_id

const types::boundary_id numbers::internal_face_boundary_id
Initial value:
=
static_cast<types::boundary_id>(-1)

A boundary indicator number that we reserve for internal faces. We assume that all valid boundary_ids lie in the range [0, internal_face_boundary_id).

This is an indicator that is used internally (by the library) to differentiate between faces that lie at the boundary of the domain and faces that lie in the interior of the domain. You should never try to assign this boundary indicator to anything in user code.

See also
Glossary entry on boundary indicators

Definition at line 277 of file types.h.

◆ flat_manifold_id

const types::manifold_id numbers::flat_manifold_id
Initial value:
=
static_cast<types::manifold_id>(-1)

A manifold_id we reserve for the default flat Cartesian manifold.

See also
Glossary entry on manifold indicators

Definition at line 286 of file types.h.

◆ invalid_subdomain_id

const types::subdomain_id numbers::invalid_subdomain_id
Initial value:
=
static_cast<types::subdomain_id>(-1)

A special id for an invalid subdomain id. This value may not be used as a valid id but is used, for example, for default arguments to indicate a subdomain id that is not to be used.

See the glossary for more information.

Definition at line 298 of file types.h.

◆ artificial_subdomain_id

const types::subdomain_id numbers::artificial_subdomain_id
Initial value:
=
static_cast<types::subdomain_id>(-2)

The subdomain id assigned to a cell whose true subdomain id we don't know, for example because it resides on a different processor on a mesh that is kept distributed on many processors. Such cells are called "artificial".

See the glossary entries on subdomain ids and artificial cells as well as the Parallel computing with multiple processors using distributed memory module for more information.

Definition at line 315 of file types.h.