/usr/include/deal.II/base/numbers.h is in libdeal.ii-dev 8.1.0-6ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | // ---------------------------------------------------------------------
// $Id: numbers.h 30036 2013-07-18 16:55:32Z maier $
//
// Copyright (C) 2006 - 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef __deal2__numbers_h
#define __deal2__numbers_h
#include <deal.II/base/config.h>
#include <deal.II/base/types.h>
#include <complex>
DEAL_II_NAMESPACE_OPEN
/**
* Namespace for the declaration of universal constants. Since the
* availability in <tt>math.h</tt> is not always guaranteed, we put
* them here. Since this file is included by <tt>base/config.h</tt>,
* they are available to the whole library.
*
* The constants defined here are a subset of the <tt>M_XXX</tt> constants
* sometimes declared in the system include file <tt>math.h</tt>, but without
* the prefix <tt>M_</tt>.
*
* In addition to that, we declare <tt>invalid_unsigned_int</tt> 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.
*/
namespace numbers
{
/**
* e
*/
static const double E = 2.7182818284590452354;
/**
* log_2 e
*/
static const double LOG2E = 1.4426950408889634074;
/**
* log_10 e
*/
static const double LOG10E = 0.43429448190325182765;
/**
* log_e 2
*/
static const double LN2 = 0.69314718055994530942;
/**
* log_e 10
*/
static const double LN10 = 2.30258509299404568402;
/**
* pi
*/
static const double PI = 3.14159265358979323846;
/**
* pi/2
*/
static const double PI_2 = 1.57079632679489661923;
/**
* pi/4
*/
static const double PI_4 = 0.78539816339744830962;
/**
* sqrt(2)
*/
static const double SQRT2 = 1.41421356237309504880;
/**
* 1/sqrt(2)
*/
static const double SQRT1_2 = 0.70710678118654752440;
/**
* Return @p 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
* <code>double</code>. In other
* words, if you give a very
* large number of type
* <code>long double</code>, this
* function may return
* <code>false</code> even if the
* number is finite with respect
* to type <code>long
* double</code>.
*/
bool is_finite (const double x);
/**
* Return @p true if real and
* imaginary parts of the given
* complex number are finite.
*/
bool is_finite (const std::complex<double> &x);
/**
* Return @p true if real and
* imaginary parts of the given
* complex number are finite.
*/
bool is_finite (const std::complex<float> &x);
/**
* Return @p 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 <code>double</code>, but
* finite with respect to
* <code>long double</code>.
*/
bool is_finite (const std::complex<long double> &x);
/**
* A structure that, together with
* its partial specializations
* NumberTraits<std::complex<number> >,
* provides traits and member
* functions that make it possible
* to write templates that work on
* both real number types and
* complex number types. This
* template is mostly used to
* implement linear algebra classes
* such as vectors and matrices
* that work for both real and
* complex numbers.
*
* @author Wolfgang Bangerth, 2007
*/
template <typename number>
struct NumberTraits
{
/**
* A flag that specifies whether the
* template type given to this class is
* complex or real. Since the general
* template is selected for non-complex
* types, the answer is
* <code>false</code>.
*/
static const bool is_complex = false;
/**
* For this data type, typedef the
* corresponding real type. Since the
* general template is selected for all
* data types that are not
* specializations of std::complex<T>,
* the underlying type must be
* real-values, so the real_type is
* equal to the underlying type.
*/
typedef number real_type;
/**
* Return the complex-conjugate of the
* given number. Since the general
* template is selected if number is
* not a complex data type, this
* function simply returns the given
* number.
*/
static
const number &conjugate (const number &x);
/**
* Return the square of the absolute
* value of the given number. Since the
* general template is chosen for types
* not equal to std::complex, this
* function simply returns the square
* of the given number.
*/
static
real_type abs_square (const number &x);
/**
* Return the absolute value of a
* number.
*/
static
real_type abs (const number &x);
};
/**
* Specialization of the general
* NumberTraits class that provides the
* relevant information if the underlying
* data type is std::complex<T>.
*
* @author Wolfgang Bangerth, 2007
*/
template <typename number>
struct NumberTraits<std::complex<number> >
{
/**
* A flag that specifies whether the
* template type given to this class is
* complex or real. Since this
* specialization of the general
* template is selected for complex
* types, the answer is
* <code>true</code>.
*/
static const bool is_complex = true;
/**
* For this data type, typedef the
* corresponding real type. Since this
* specialization of the template is
* selected for number types
* std::complex<T>, the real type is
* equal to the type used to store the
* two components of the complex
* number.
*/
typedef number real_type;
/**
* Return the complex-conjugate of the
* given number.
*/
static
std::complex<number> conjugate (const std::complex<number> &x);
/**
* Return the square of the absolute
* value of the given number. Since
* this specialization of the general
* template is chosen for types equal
* to std::complex, this function
* returns the product of a number and
* its complex conjugate.
*/
static
real_type abs_square (const std::complex<number> &x);
/**
* Return the absolute value of a
* complex number.
*/
static
real_type abs (const std::complex<number> &x);
};
}
//TODO[WB]: eventually remove this namespace alias
/*
* Namespace alias with the old name for the numbers namespace. The namespace
* was originally called numbers, but has since been renamed to
* dealii::numbers when everything was moved into namespace dealii.
*
* @deprecated
*/
namespace deal_II_numbers = numbers;
// --------------- inline and template functions ---------------- //
namespace numbers
{
template <typename number>
const number &
NumberTraits<number>::conjugate (const number &x)
{
return x;
}
template <typename number>
typename NumberTraits<number>::real_type
NumberTraits<number>::abs_square (const number &x)
{
return x * x;
}
template <typename number>
typename NumberTraits<number>::real_type
NumberTraits<number>::abs (const number &x)
{
return std::fabs(x);
}
template <typename number>
std::complex<number>
NumberTraits<std::complex<number> >::conjugate (const std::complex<number> &x)
{
return std::conj(x);
}
template <typename number>
typename NumberTraits<std::complex<number> >::real_type
NumberTraits<std::complex<number> >::abs (const std::complex<number> &x)
{
return std::abs(x);
}
template <typename number>
typename NumberTraits<std::complex<number> >::real_type
NumberTraits<std::complex<number> >::abs_square (const std::complex<number> &x)
{
return std::norm (x);
}
}
DEAL_II_NAMESPACE_CLOSE
#endif
|