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
signaling_nan.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2005 - 2023 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
85 template <typename T, size_t width>
87 {
90 {
93 }
94 };
95
96
102 template <int dim, typename T>
103 struct NaNInitializer<Tensor<1, dim, T>>
104 {
105 static Tensor<1, dim, T>
107 {
108 Tensor<1, dim, T> nan_tensor;
109
110 for (unsigned int i = 0; i < dim; ++i)
111 nan_tensor[i] = NaNInitializer<T>::invalid_element();
112
113 return nan_tensor;
114 }
115 };
116
117
118
124 template <int rank, int dim, typename T>
125 struct NaNInitializer<Tensor<rank, dim, T>>
126 {
129 {
130 Tensor<rank, dim, T> nan_tensor;
131
132 // recursively initialize sub-tensors with invalid elements
133 for (unsigned int i = 0; i < dim; ++i)
134 nan_tensor[i] =
135 NaNInitializer<Tensor<rank - 1, dim, T>>::invalid_element();
136
137 return nan_tensor;
138 }
139 };
140
141
142
148 template <int dim, typename T>
149 struct NaNInitializer<Point<dim, T>>
150 {
151 static Point<dim, T>
153 {
154 Point<dim, T> nan_point;
155
156 for (unsigned int i = 0; i < dim; ++i)
157 nan_point[i] = NaNInitializer<T>::invalid_element();
158
159 return nan_point;
160 }
161 };
162
163
164
170 template <int rank, int dim, typename T>
171 struct NaNInitializer<SymmetricTensor<rank, dim, T>>
172 {
175 {
176 // initialize symmetric tensors via the unrolled list of elements
177 T initializers
179 for (unsigned int i = 0;
180 i < SymmetricTensor<rank, dim, T>::n_independent_components;
181 ++i)
182 initializers[i] = NaNInitializer<T>::invalid_element();
183
184 return SymmetricTensor<rank, dim, T>(initializers);
185 }
186 };
187
188
189
195 template <int order, int dim, int spacedim, typename T>
196 struct NaNInitializer<DerivativeForm<order, dim, spacedim, T>>
197 {
200 {
202
203 // recursively initialize sub-tensors with invalid elements
204 for (unsigned int i = 0; i < spacedim; ++i)
205 form[i] = NaNInitializer<Tensor<order, dim, T>>::invalid_element();
206
207 return form;
208 }
209 };
210 } // namespace SignalingNaN
211 } // namespace internal
212
213
214
269 template <class T>
270 T
272 {
273 // dispatch to the classes in the internal namespace because there
274 // we can do partial specializations, which is not possible for
275 // template functions such as the current one
277 }
278} // namespace numbers
279
280
282
283#endif
Definition point.h:112
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
T signaling_nan()