TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Double.h
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef DOUBLE_H
17#define DOUBLE_H
18
19#ifndef LATATOOLS
20#include <blas1.h>
21#endif
22#include <Objet_U.h>
23#include <cmath>
24
25# ifndef M_E
26# define M_E 2.7182818284590452354
27# endif
28# ifndef M_LOG2E
29# define M_LOG2E 1.4426950408889634074
30# endif
31# ifndef M_LOG10E
32# define M_LOG10E 0.43429448190325182765
33# endif
34# ifndef M_LN2
35# define M_LN2 0.69314718055994530942
36# endif
37# ifndef M_LN10
38# define M_LN10 2.30258509299404568402
39# endif
40# ifndef M_PI
41# define M_PI 3.14159265358979323846
42# endif
43# ifndef M_PI_2
44# define M_PI_2 1.57079632679489661923
45# endif
46# ifndef M_PI_4
47# define M_PI_4 0.78539816339744830962
48# endif
49# ifndef M_1_PI
50# define M_1_PI 0.31830988618379067154
51# endif
52# ifndef M_2_PI
53# define M_2_PI 0.63661977236758134308
54# endif
55# ifndef M_2_SQRTPI
56# define M_2_SQRTPI 1.12837916709551257390
57# endif
58# ifndef M_SQRT2
59# define M_SQRT2 1.41421356237309504880
60# endif
61# ifndef M_SQRT1_2
62# define M_SQRT1_2 0.70710678118654752440
63# endif
64# ifndef DMAXFLOAT
65# define DMAXFLOAT 1e+38
66# endif
67# ifndef DMINFLOAT
68# define DMINFLOAT 1e-30
69# endif
70
71/*! @brief : fonctions utiles sur les double
72 *
73 */
74#ifdef LATATOOLS
75#define KOKKOS_INLINE_FUNCTION inline
76#endif
77
78KOKKOS_INLINE_FUNCTION double carre(double x) { return x*x; }
79
80inline double* prodvect(const double* a, const double* b, double* resu)
81{
82 resu[0]=a[1]*b[2]-a[2]*b[1];
83 resu[1]=a[2]*b[0]-a[0]*b[2];
84 resu[2]=a[0]*b[1]-a[1]*b[0];
85 return(resu);
86}
87
88inline double determinant(double a[2], double b[2]) { return (a[0]*b[1]-a[1]*b[0]); }
89#if 0
90inline double norme(int n, const double* const a)
91{
92 const integer un=1;
93 const integer m=n ;
94 return F77NAME(DNRM2)(&m, a, &un);
95}
96#endif
97
98KOKKOS_INLINE_FUNCTION
99int est_egal(double x1, double x2, double eps)
100{
101 double somme = std::fabs(x1)+std::fabs(x2);
102 return ( (somme < eps) || (std::fabs(x1-x2) < eps * somme) );
103}
104
105inline int est_egal(double x1, double x2) { return est_egal(x1,x2,Objet_U::precision_geom); }
106
107inline int est_different(double x1, double x2, double eps) { return !est_egal(x1,x2,eps); }
108
109inline int est_different(double x1, double x2) { return !est_egal(x1,x2); }
110
111inline int inf_ou_egal(double x1, double x2, double eps)
112{
113 double somme=std::fabs(x1)+std::fabs(x2);
114 return ( (somme < eps) || (x1 < x2 + eps * somme));
115}
116
117inline int inf_ou_egal(double x1, double x2) { return inf_ou_egal(x1,x2,Objet_U::precision_geom); }
118
119inline int inf_strict(double x1, double x2, double eps)
120{
121 double somme=std::fabs(x1)+std::fabs(x2);
122 return ( (somme > eps) && (x1 < x2 - eps * somme) );
123}
124
125inline int inf_strict(double x1, double x2) { return inf_strict(x1,x2,Objet_U::precision_geom); }
126
127inline int sup_strict(double x1, double x2, double eps) { return !inf_ou_egal(x1,x2,eps); }
128
129inline int sup_strict(double x1, double x2) { return sup_strict(x1,x2,Objet_U::precision_geom); }
130
131inline int sup_ou_egal(double x1, double x2, double eps) { return !inf_strict(x1,x2,eps); }
132
133inline int sup_ou_egal(double x1, double x2) { return sup_ou_egal(x1,x2,Objet_U::precision_geom); }
134
135#endif /* DOUBLE_H */
static double precision_geom
Definition Objet_U.h:86