Arcane  v3.15.3.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Real2x2.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* Real2x2.h (C) 2000-2024 */
9/* */
10/* Matrice 2x2 de 'Real'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_REAL2X2_H
13#define ARCANE_UTILS_REAL2X2_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Real2.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
31{
32 public:
33
34 Real2POD x;
35 Real2POD y;
36};
37
38/*---------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------*/
52class ARCANE_UTILS_EXPORT Real2x2
53{
54 public:
55
57 constexpr ARCCORE_HOST_DEVICE Real2x2()
58 : x(Real2::null())
59 , y(Real2::null())
60 {}
62 constexpr ARCCORE_HOST_DEVICE Real2x2(Real2 ax, Real2 ay)
63 : x(ax)
64 , y(ay)
65 {}
70 ARCANE_DEPRECATED_116 Real2x2(Real ax, Real ay, Real bx, Real by)
71 : x(ax, bx)
72 , y(ay, by)
73 {}
75 Real2x2(const Real2x2& f) = default;
77 constexpr ARCCORE_HOST_DEVICE explicit Real2x2(const Real2x2POD& f)
78 : x(f.x)
79 , y(f.y)
80 {}
82 constexpr ARCCORE_HOST_DEVICE explicit Real2x2(Real v)
83 {
84 x = y = v;
85 }
87 Real2x2& operator=(const Real2x2& f) = default;
88
90 constexpr ARCCORE_HOST_DEVICE Real2x2& operator=(Real v)
91 {
92 x = y = v;
93 return (*this);
94 }
95
96 public:
97
100
101 public:
102
104 constexpr ARCCORE_HOST_DEVICE static Real2x2 null() { return Real2x2(); }
105
107 constexpr ARCCORE_HOST_DEVICE static Real2x2 fromColumns(Real ax, Real ay, Real bx, Real by)
108 {
109 return Real2x2(Real2(ax, bx), Real2(ay, by));
110 }
111
113 constexpr ARCCORE_HOST_DEVICE static Real2x2 fromLines(Real ax, Real bx, Real ay, Real by)
114 {
115 return Real2x2(Real2(ax, bx), Real2(ay, by));
116 }
117
118 public:
119
121 constexpr ARCCORE_HOST_DEVICE Real2x2 copy() const { return (*this); }
123 constexpr ARCCORE_HOST_DEVICE Real2x2& reset()
124 {
125 *this = null();
126 return (*this);
127 }
129 constexpr ARCCORE_HOST_DEVICE Real2x2& assign(Real2 ax, Real2 ay)
130 {
131 x = ax;
132 y = ay;
133 return (*this);
134 }
136 constexpr ARCCORE_HOST_DEVICE Real2x2& assign(Real2x2 f)
137 {
138 x = f.x;
139 y = f.y;
140 return (*this);
141 }
142
147 std::istream& assign(std::istream& i);
149 std::ostream& print(std::ostream& o) const;
151 std::ostream& printXy(std::ostream& o) const;
152
154 constexpr ARCCORE_HOST_DEVICE Real2x2& add(Real2x2 b)
155 {
156 x += b.x;
157 y += b.y;
158 return (*this);
159 }
161 constexpr ARCCORE_HOST_DEVICE Real2x2& sub(Real2x2 b)
162 {
163 x -= b.x;
164 y -= b.y;
165 return (*this);
166 }
168 //Real2x2& mul(Real2x2 b) { x*=b.x; y*=b.y; return (*this); }
170 constexpr ARCCORE_HOST_DEVICE Real2x2& div(Real2x2 b)
171 {
172 x /= b.x;
173 y /= b.y;
174 return (*this);
175 }
177 constexpr ARCCORE_HOST_DEVICE Real2x2& addSame(Real2 b)
178 {
179 x += b;
180 y += b;
181 return (*this);
182 }
184 constexpr ARCCORE_HOST_DEVICE Real2x2& subSame(Real2 b)
185 {
186 x -= b;
187 y -= b;
188 return (*this);
189 }
191 constexpr ARCCORE_HOST_DEVICE Real2x2& mulSame(Real2 b)
192 {
193 x *= b;
194 y *= b;
195 return (*this);
196 }
198 constexpr ARCCORE_HOST_DEVICE Real2x2& divSame(Real2 b)
199 {
200 x /= b;
201 y /= b;
202 return (*this);
203 }
205 constexpr ARCCORE_HOST_DEVICE Real2x2& operator+=(Real2x2 b) { return add(b); }
207 constexpr ARCCORE_HOST_DEVICE Real2x2& operator-=(Real2x2 b) { return sub(b); }
209 //Real2x2& operator*=(Real2x2 b) { return mul(b); }
211 constexpr ARCCORE_HOST_DEVICE void operator*=(Real b)
212 {
213 x *= b;
214 y *= b;
215 }
217 //Real2x2& operator/= (Real2x2 b) { return div(b); }
219 constexpr ARCCORE_HOST_DEVICE void operator/=(Real b)
220 {
221 x /= b;
222 y /= b;
223 }
225 constexpr ARCCORE_HOST_DEVICE Real2x2 operator+(Real2x2 b) const { return Real2x2(x + b.x, y + b.y); }
227 constexpr ARCCORE_HOST_DEVICE Real2x2 operator-(Real2x2 b) const { return Real2x2(x - b.x, y - b.y); }
229 constexpr ARCCORE_HOST_DEVICE Real2x2 operator-() const { return Real2x2(-x, -y); }
230
237 constexpr ARCCORE_HOST_DEVICE bool operator==(Real2x2 b) const
238 {
239 return (x == b.x) && (y == b.y);
240 }
247 constexpr ARCCORE_HOST_DEVICE bool operator!=(Real2x2 b) const
248 {
249 return !operator==(b);
250 }
251
256 ARCCORE_HOST_DEVICE Real2 operator[](Integer i) const
257 {
258 ARCCORE_CHECK_AT(i, 2);
259 return (&x)[i];
260 }
261
266 ARCCORE_HOST_DEVICE Real2 operator()(Integer i) const
267 {
268 ARCCORE_CHECK_AT(i, 2);
269 return (&x)[i];
270 }
271
277 ARCCORE_HOST_DEVICE Real operator()(Integer i, Integer j) const
278 {
279 ARCCORE_CHECK_AT(i, 2);
280 ARCCORE_CHECK_AT(j, 2);
281 return (&x)[i][j];
282 }
283
288 ARCCORE_HOST_DEVICE Real2& operator[](Integer i)
289 {
290 ARCCORE_CHECK_AT(i, 2);
291 return (&x)[i];
292 }
293
298 ARCCORE_HOST_DEVICE Real2& operator()(Integer i)
299 {
300 ARCCORE_CHECK_AT(i, 2);
301 return (&x)[i];
302 }
303
309 ARCCORE_HOST_DEVICE Real& operator()(Integer i, Integer j)
310 {
311 ARCCORE_CHECK_AT(i, 2);
312 ARCCORE_CHECK_AT(j, 2);
313 return (&x)[i][j];
314 }
315
316 public:
317
319 friend std::ostream& operator<<(std::ostream& o, Real2x2 t)
320 {
321 return t.printXy(o);
322 }
323
325 friend std::istream& operator>>(std::istream& i, Real2x2& t)
326 {
327 return t.assign(i);
328 }
329
331 friend constexpr ARCCORE_HOST_DEVICE Real2x2 operator*(Real sca, Real2x2 vec)
332 {
333 return Real2x2(vec.x * sca, vec.y * sca);
334 }
335
337 friend constexpr ARCCORE_HOST_DEVICE Real2x2 operator*(Real2x2 vec, Real sca)
338 {
339 return Real2x2(vec.x * sca, vec.y * sca);
340 }
341
343 friend constexpr ARCCORE_HOST_DEVICE Real2x2 operator/(Real2x2 vec, Real sca)
344 {
345 return Real2x2(vec.x / sca, vec.y / sca);
346 }
347
354 friend constexpr ARCCORE_HOST_DEVICE bool operator<(Real2x2 v1, Real2x2 v2)
355 {
356 if (v1.x == v2.x) {
357 return v1.y < v2.y;
358 }
359 return (v1.x < v2.x);
360 }
361
362 public:
363
375 // TODO: rendre obsolète mi-2025: ARCANE_DEPRECATED_REASON("Y2024: Use math::isNearlyZero(const Real2x2&) instead")
376 inline constexpr ARCCORE_HOST_DEVICE bool isNearlyZero() const;
377
378 private:
379
385 constexpr ARCCORE_HOST_DEVICE static bool _eq(Real a, Real b)
386 {
387 return TypeEqualT<Real>::isEqual(a, b);
388 }
389};
390
391/*---------------------------------------------------------------------------*/
392/*---------------------------------------------------------------------------*/
393
394namespace math
395{
407 constexpr ARCCORE_HOST_DEVICE bool isNearlyZero(const Real2x2& v)
408 {
409 return math::isNearlyZero(v.x) && math::isNearlyZero(v.y);
410 }
411}
412
413/*---------------------------------------------------------------------------*/
414/*---------------------------------------------------------------------------*/
415
416inline constexpr ARCCORE_HOST_DEVICE bool Real2x2::
417isNearlyZero() const
418{
419 return math::isNearlyZero(*this);
420}
421
422/*---------------------------------------------------------------------------*/
423/*---------------------------------------------------------------------------*/
424
425} // End namespace Arcane
426
427/*---------------------------------------------------------------------------*/
428/*---------------------------------------------------------------------------*/
429
430#endif
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:149
Classe gérant un vecteur de réel de dimension 2.
Definition Real2.h:121
Classe gérant une matrice de réel de dimension 2x2.
Definition Real2x2.h:53
constexpr ARCCORE_HOST_DEVICE Real2x2 & operator=(Real v)
Affecte à l'instance le couple (v,v,v).
Definition Real2x2.h:90
constexpr ARCCORE_HOST_DEVICE Real2x2 & mulSame(Real2 b)
Multiplie chaque composante du couple par b.
Definition Real2x2.h:191
constexpr static ARCCORE_HOST_DEVICE Real2x2 null()
Construit la matrice nulle.
Definition Real2x2.h:104
ARCCORE_HOST_DEVICE Real2 operator()(Integer i) const
Accès en lecture seule à la i-ème (entre 0 et 1 inclus) ligne de l'instance.
Definition Real2x2.h:266
constexpr ARCCORE_HOST_DEVICE Real2x2 copy() const
Retourne une copie du couple.
Definition Real2x2.h:121
constexpr ARCCORE_HOST_DEVICE Real2x2 & div(Real2x2 b)
Multiple chaque composante du couple par la composant correspondant de b.
Definition Real2x2.h:170
Real2 x
Première composante.
Definition Real2x2.h:98
constexpr static ARCCORE_HOST_DEVICE Real2x2 fromLines(Real ax, Real bx, Real ay, Real by)
Construit le couple ((ax,bx),(ay,by)).
Definition Real2x2.h:113
ARCANE_DEPRECATED_116 Real2x2(Real ax, Real ay, Real bx, Real by)
Construit le couple ((ax,bx),(ay,by)).
Definition Real2x2.h:70
Real2 y
Deuxième composante.
Definition Real2x2.h:99
constexpr ARCCORE_HOST_DEVICE bool operator!=(Real2x2 b) const
Compare deux couples. Pour la notion d'égalité, voir operator==()
Definition Real2x2.h:247
friend constexpr ARCCORE_HOST_DEVICE Real2x2 operator*(Real2x2 vec, Real sca)
Multiplication par un scalaire.
Definition Real2x2.h:337
constexpr ARCCORE_HOST_DEVICE Real2x2 & add(Real2x2 b)
Ajoute b au couple.
Definition Real2x2.h:154
ARCCORE_HOST_DEVICE Real & operator()(Integer i, Integer j)
Accès à la i-ème ligne et j-ème colonne.
Definition Real2x2.h:309
constexpr ARCCORE_HOST_DEVICE bool isNearlyZero() const
Compare la matrice avec la matrice nulle.
Definition Real2x2.h:417
friend constexpr ARCCORE_HOST_DEVICE bool operator<(Real2x2 v1, Real2x2 v2)
Opérateur de comparaison.
Definition Real2x2.h:354
constexpr ARCCORE_HOST_DEVICE Real2x2 & assign(Real2 ax, Real2 ay)
Affecte à l'instance le couple (ax,ay,az)
Definition Real2x2.h:129
constexpr ARCCORE_HOST_DEVICE Real2x2(Real v)
Construit l'instance avec le triplet (v,v,v).
Definition Real2x2.h:82
constexpr ARCCORE_HOST_DEVICE Real2x2(const Real2x2POD &f)
Construit un couple identique à f.
Definition Real2x2.h:77
constexpr ARCCORE_HOST_DEVICE void operator/=(Real b)
Divise chaque composante du couple par la composant correspondant de b.
Definition Real2x2.h:219
friend std::istream & operator>>(std::istream &i, Real2x2 &t)
Lit le couple t à partir du flot o.
Definition Real2x2.h:325
ARCCORE_HOST_DEVICE Real operator()(Integer i, Integer j) const
Accès en lecture seule à la i-ème ligne et j-ème colonne.
Definition Real2x2.h:277
constexpr ARCCORE_HOST_DEVICE Real2x2 & addSame(Real2 b)
Ajoute b à chaque composante du couple.
Definition Real2x2.h:177
Real2x2(const Real2x2 &f)=default
Construit un couple identique à f.
constexpr static ARCCORE_HOST_DEVICE bool _eq(Real a, Real b)
Compare les valeurs de a et b avec le comparateur TypeEqualT.
Definition Real2x2.h:385
constexpr ARCCORE_HOST_DEVICE Real2x2 & sub(Real2x2 b)
Soustrait b au couple.
Definition Real2x2.h:161
constexpr ARCCORE_HOST_DEVICE Real2x2 & reset()
Réinitialise le couple avec les constructeurs par défaut.
Definition Real2x2.h:123
constexpr ARCCORE_HOST_DEVICE Real2x2 operator-() const
Créé un tenseur opposé au tenseur actuel.
Definition Real2x2.h:229
Real2x2 & operator=(const Real2x2 &f)=default
Opérateur de recopie.
constexpr ARCCORE_HOST_DEVICE Real2x2 & operator+=(Real2x2 b)
Ajoute b au couple.
Definition Real2x2.h:205
constexpr ARCCORE_HOST_DEVICE Real2x2 & assign(Real2x2 f)
Copie le couple f.
Definition Real2x2.h:136
constexpr static ARCCORE_HOST_DEVICE Real2x2 fromColumns(Real ax, Real ay, Real bx, Real by)
Construit le couple ((ax,bx),(ay,by)).
Definition Real2x2.h:107
constexpr ARCCORE_HOST_DEVICE void operator*=(Real b)
Multiple chaque composante du couple par la composant correspondant de b.
Definition Real2x2.h:211
friend constexpr ARCCORE_HOST_DEVICE Real2x2 operator*(Real sca, Real2x2 vec)
Multiplication par un scalaire.
Definition Real2x2.h:331
constexpr ARCCORE_HOST_DEVICE Real2x2(Real2 ax, Real2 ay)
Construit le couple (ax,ay)
Definition Real2x2.h:62
ARCCORE_HOST_DEVICE Real2 & operator()(Integer i)
Accès à la i-ème ligne (entre 0 et 1 inclus) de l'instance.
Definition Real2x2.h:298
constexpr ARCCORE_HOST_DEVICE Real2x2 & divSame(Real2 b)
Divise chaque composante du couple par b.
Definition Real2x2.h:198
constexpr ARCCORE_HOST_DEVICE Real2x2()
Construit la matrice nulle.
Definition Real2x2.h:57
constexpr ARCCORE_HOST_DEVICE Real2x2 operator+(Real2x2 b) const
Créé un couple qui vaut ce couple ajouté à b.
Definition Real2x2.h:225
ARCCORE_HOST_DEVICE Real2 operator[](Integer i) const
Accès en lecture seule à la i-ème (entre 0 et 1 inclus) ligne de l'instance.
Definition Real2x2.h:256
friend constexpr ARCCORE_HOST_DEVICE Real2x2 operator/(Real2x2 vec, Real sca)
Division par un scalaire.
Definition Real2x2.h:343
friend std::ostream & operator<<(std::ostream &o, Real2x2 t)
Ecrit le couple t sur le flot o.
Definition Real2x2.h:319
constexpr ARCCORE_HOST_DEVICE Real2x2 & subSame(Real2 b)
Soustrait b à chaque composante du couple.
Definition Real2x2.h:184
constexpr ARCCORE_HOST_DEVICE Real2x2 operator-(Real2x2 b) const
Créé un couple qui vaut b soustrait de ce couple.
Definition Real2x2.h:227
constexpr ARCCORE_HOST_DEVICE Real2x2 & operator-=(Real2x2 b)
Soustrait b au couple.
Definition Real2x2.h:207
ARCCORE_HOST_DEVICE Real2 & operator[](Integer i)
Accès à la i-ème ligne (entre 0 et 1 inclus) de l'instance.
Definition Real2x2.h:288
constexpr ARCCORE_HOST_DEVICE bool operator==(Real2x2 b) const
Compare composant pas composante l'instance courante à b.
Definition Real2x2.h:237
Opérations de comparaisons pour un type numérique T.
Definition Numeric.h:45
Espace de nom pour l'utilisation des accélérateurs.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Structure POD pour un Real2x2.
Definition Real2x2.h:31