Reference documentation for deal.II version 9.4.1
\(\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
signaling_nan.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2005 - 2020 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_signaling_nan_h
17#define dealii_signaling_nan_h
18
19#include <deal.II/base/config.h>
20
22#include <deal.II/base/point.h>
24#include <deal.II/base/tensor.h>
25
26#include <limits>
27
28
30
31namespace numbers
32{
33 namespace internal
34 {
40 namespace SignalingNaN
41 {
49 template <typename T>
51
52
58 template <>
59 struct NaNInitializer<float>
60 {
61 static float
63 {
64 return std::numeric_limits<float>::signaling_NaN();
65 }
66 };
67
68
74 template <>
75 struct NaNInitializer<double>
76 {
77 static double
79 {
80 return std::numeric_limits<double>::signaling_NaN();
81 }
82 };
83
84
90 template <int dim, typename T>
91 struct NaNInitializer<Tensor<1, dim, T>>
92 {
95 {
96 Tensor<1, dim, T> nan_tensor;
97
98 for (unsigned int i = 0; i < dim; ++i)
99 nan_tensor[i] = NaNInitializer<T>::invalid_element();
100
101 return nan_tensor;
102 }
103 };
104
105
106
112 template <int rank, int dim, typename T>
113 struct NaNInitializer<Tensor<rank, dim, T>>
114 {
117 {
118 Tensor<rank, dim, T> nan_tensor;
119
120 // recursively initialize sub-tensors with invalid elements
121 for (unsigned int i = 0; i < dim; ++i)
122 nan_tensor[i] =
123 NaNInitializer<Tensor<rank - 1, dim, T>>::invalid_element();
124
125 return nan_tensor;
126 }
127 };
128
129
130
136 template <int dim, typename T>
137 struct NaNInitializer<Point<dim, T>>
138 {
139 static Point<dim, T>
141 {
142 Point<dim, T> nan_point;
143
144 for (unsigned int i = 0; i < dim; ++i)
145 nan_point[i] = NaNInitializer<T>::invalid_element();
146
147 return nan_point;
148 }
149 };
150
151
152
158 template <int rank, int dim, typename T>
159 struct NaNInitializer<SymmetricTensor<rank, dim, T>>
160 {
163 {
164 // initialize symmetric tensors via the unrolled list of elements
165 T initializers
167 for (unsigned int i = 0;
168 i < SymmetricTensor<rank, dim, T>::n_independent_components;
169 ++i)
170 initializers[i] = NaNInitializer<T>::invalid_element();
171
172 return SymmetricTensor<rank, dim, T>(initializers);
173 }
174 };
175
176
177
183 template <int order, int dim, int spacedim, typename T>
184 struct NaNInitializer<DerivativeForm<order, dim, spacedim, T>>
185 {
188 {
190
191 // recursively initialize sub-tensors with invalid elements
192 for (unsigned int i = 0; i < spacedim; ++i)
193 form[i] = NaNInitializer<Tensor<order, dim, T>>::invalid_element();
194
195 return form;
196 }
197 };
198 } // namespace SignalingNaN
199 } // namespace internal
200
201
202
257 template <class T>
258 T
260 {
261 // dispatch to the classes in the internal namespace because there
262 // we can do partial specializations, which is not possible for
263 // template functions such as the current one
265 }
266} // namespace numbers
267
268
270
271#endif
Definition: point.h:111
Definition: tensor.h:503
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
T signaling_nan()