Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Real2x2Proxy.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* Real2x2Proxy.h (C) 2000-2008 */
9/* */
10/* Proxy of type 'Real2x2'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_REAL2X2PROXY_H
13#define ARCANE_UTILS_REAL2X2PROXY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Real2x2.h"
18#include "arcane/utils/Real2Proxy.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
32class ARCANE_UTILS_EXPORT Real2x2Proxy
33{
34 public:
35
38 : x(value.x, info)
39 , y(value.y, info)
40 , m_value(value)
41 , m_info(info)
42 {}
43
46 : x(f.x)
47 , y(f.y)
48 , m_value(f.m_value)
49 , m_info(f.m_info)
50 {}
51 const Real2x2Proxy& operator=(const Real2x2Proxy& f)
52 {
53 x = f.x;
54 y = f.y;
55 return (*this);
56 }
57 const Real2x2Proxy& operator=(Real2x2 f)
58 {
59 x = f.x;
60 y = f.y;
61 return (*this);
62 }
63
66 {
67 x = v;
68 y = v;
69 return (*this);
70 }
71
72 public:
73
76
77 private:
78
79 Real2x2& m_value;
80 MemoryAccessInfo m_info;
81
82 public:
83
85 Real2x2 copy() const { return getValue(); }
86
89 {
90 *this = Real2x2::null();
91 return (*this);
92 }
93
96 {
97 x = ax;
98 y = ay;
99 return (*this);
100 }
101
104 {
105 x = f.x;
106 y = f.y;
107 return (*this);
108 }
109 operator const Real2x2&() const
110 {
111 return getValue();
112 }
113 //operator Real2x2&()
114 //{
115 // return getValueMutable();
116 //}
117
129 bool isNearlyZero() const
130 {
131 return x.isNearlyZero() && y.isNearlyZero();
132 }
133
138 istream& assign(istream& i);
139
141 ostream& print(ostream& o) const;
142
144 ostream& printXy(ostream& o) const;
145
148 {
149 x += b.x;
150 y += b.y;
151 return (*this);
152 }
153
156 {
157 x -= b.x;
158 y -= b.y;
159 return (*this);
160 }
161
163 //Real2x2Proxy& mul(Real2x2Proxy b) { x*=b.x; y*=b.y; return (*this); }
164
167 {
168 x /= b.x;
169 y /= b.y;
170 return (*this);
171 }
172
175 {
176 x += b;
177 y += b;
178 return (*this);
179 }
180
183 {
184 x -= b;
185 y -= b;
186 return (*this);
187 }
188
191 {
192 x *= b;
193 y *= b;
194 return (*this);
195 }
196
199 {
200 x /= b;
201 y /= b;
202 return (*this);
203 }
204
207
210
212 //Real2x2Proxy& operator*=(Real2x2Proxy b) { return mul(b); }
213
216 {
217 x *= b;
218 y *= b;
219 }
220
222 //Real2x2Proxy& operator/= (Real2x2 b) { return div(b); }
223
226 {
227 x /= b;
228 y /= b;
229 }
230
232 Real2x2 operator+(Real2x2 b) const { return Real2x2(x + b.x, y + b.y); }
233
235 Real2x2 operator-(Real2x2 b) const { return Real2x2(x - b.x, y - b.y); }
236
238 Real2x2 operator-() const { return Real2x2(-x, -y); }
239
244 //Real2x2 operator*(Real2x2Proxy b) const { return Real2x2Proxy(x*b.x,y*b.y); }
245
250 //Real2x2Proxy operator/(Real2x2Proxy b) const { return Real2x2Proxy(x/b.x,y/b.y); }
251
252 public:
253
254 const Real2x2& getValue() const
255 {
256 m_info.setRead();
257 return m_value;
258 }
259 Real2x2& getValueMutable()
260 {
261 m_info.setReadOrWrite();
262 return m_value;
263 }
264
265 private:
266
272 static bool _eq(Real a, Real b)
273 {
274 return TypeEqualT<Real>::isEqual(a, b);
275 }
276};
277
278/*---------------------------------------------------------------------------*/
279/*---------------------------------------------------------------------------*/
280
281inline bool
282operator==(const Real2x2& a, const Real2x2Proxy& b)
283{
284 return a == b.getValue();
285}
286inline bool
287operator==(const Real2x2Proxy& a, const Real2x2& b)
288{
289 return a.getValue() == b;
290}
291inline bool
292operator==(const Real2x2Proxy& a, const Real2x2Proxy& b)
293{
294 return a.getValue() == b.getValue();
295}
296
297/*---------------------------------------------------------------------------*/
298/*---------------------------------------------------------------------------*/
299
300inline bool
301operator!=(const Real2x2& a, const Real2x2Proxy& b)
302{
303 return a != b.getValue();
304}
305inline bool
306operator!=(const Real2x2Proxy& a, const Real2x2& b)
307{
308 return a.getValue() != b;
309}
310inline bool
311operator!=(const Real2x2Proxy& a, const Real2x2Proxy& b)
312{
313 return a.getValue() != b.getValue();
314}
315
316/*---------------------------------------------------------------------------*/
317/*---------------------------------------------------------------------------*/
318
323inline ostream&
324operator<<(ostream& o, const Real2x2Proxy& t)
325{
326 return t.printXy(o);
327}
328
333inline istream&
335{
336 return t.assign(i);
337}
338
339/*---------------------------------------------------------------------------*/
340/*---------------------------------------------------------------------------*/
341
343inline Real2x2
344operator*(Real sca, const Real2x2Proxy& vec)
345{
346 return Real2x2(vec.x * sca, vec.y * sca);
347}
348
349/*---------------------------------------------------------------------------*/
350/*---------------------------------------------------------------------------*/
351
353inline Real2x2
354operator*(const Real2x2Proxy& vec, Real sca)
355{
356 return Real2x2(vec.x * sca, vec.y * sca);
357}
358
359/*---------------------------------------------------------------------------*/
360/*---------------------------------------------------------------------------*/
361
363inline Real2x2
365{
366 return Real2x2(vec.x / sca, vec.y / sca);
367}
368
369/*---------------------------------------------------------------------------*/
370/*---------------------------------------------------------------------------*/
371
378inline bool
379operator<(const Real2x2Proxy& v1, const Real2x2Proxy& v2)
380{
381 return (v1.getValue() < v2.getValue());
382}
383
384/*---------------------------------------------------------------------------*/
385/*---------------------------------------------------------------------------*/
386
387} // namespace Arcane
388
389/*---------------------------------------------------------------------------*/
390/*---------------------------------------------------------------------------*/
391
392#endif
Class managing a 2-dimensional real vector.
Definition Real2Proxy.h:41
RealProxy x
first component of the pair
Definition Real2Proxy.h:88
Class managing a 2-dimensional real vector.
Definition Real2.h:122
Proxy of type 'Real2x2'.
Real2x2 operator-(Real2x2 b) const
Creates a pair that equals b subtracted from this pair.
static bool _eq(Real a, Real b)
Compares the values of a and b with the TypeEqualT comparator.
Real2x2Proxy & divSame(Real2 b)
Divides each component of the pair by b.
ostream & print(ostream &o) const
Writes the pair to the stream o readable by an assign().
Real2x2Proxy & add(Real2x2 b)
Adds b to the pair.
bool isNearlyZero() const
Compares the matrix with the zero matrix.
istream & operator>>(istream &i, Real2x2Proxy &t)
Reads the pair t from the stream o.
void operator*=(Real b)
Multiplies each component of the pair by the corresponding component of b.
Real2x2Proxy & assign(Real2x2Proxy f)
Copies the pair f.
Real2x2Proxy(const Real2x2Proxy &f)
Constructs a pair identical to f.
Real2x2Proxy & mulSame(Real2 b)
Multiplies each component of the pair by b.
Real2x2 operator-() const
Creates a tensor opposite to the current tensor.
Real2x2Proxy & operator+=(Real2x2 b)
Adds b to the pair.
Real2x2Proxy & subSame(Real2 b)
Subtracts b from each component of the pair.
Real2x2Proxy(Real2x2 &value, const MemoryAccessInfo &info)
Constructs the pair (ax,ay).
Real2x2 operator+(Real2x2 b) const
Creates a pair that equals this pair added to b.
Real2x2Proxy & addSame(Real2 b)
Adds b to each component of the pair.
const Real2x2Proxy & operator=(Real v)
Assigns the triplet (v,v,v) to the instance.
Real2x2Proxy & operator-=(Real2x2 b)
Subtracts b from the pair.
Real2x2Proxy & div(Real2x2 b)
Multiplies each component of the pair by the corresponding component of b.
const Real2x2 & getValue() const
Creates a pair that equals this pair whose each component has been multiplied by the corresponding co...
ostream & operator<<(ostream &o, const Real2x2Proxy &t)
Writes the pair t to the stream o.
Real2Proxy x
First component.
istream & assign(istream &i)
Reads the matrix from the stream i The matrix is read in the form of three Real2s.
Real2x2Proxy & assign(Real2 ax, Real2 ay)
Assigns the triplet (ax,ay,az) to the instance.
Real2Proxy y
Second component.
Real2x2Proxy & reset()
Resets the pair using default constructors.
Real2x2Proxy & sub(Real2x2 b)
Subtracts b from the pair.
Real2x2 copy() const
Returns a copy of the pair.
ostream & printXy(ostream &o) const
Writes the pair to the stream o in the form (x,y,z).
void operator/=(Real b)
Divides each component of the pair by the corresponding component of b.
Class managing a 2x2 matrix of reals.
Definition Real2x2.h:55
Real2 x
First component.
Definition Real2x2.h:112
Real2 y
Second component.
Definition Real2x2.h:113
constexpr __host__ static __device__ Real2x2 null()
Constructs the zero matrix.
Definition Real2x2.h:118
constexpr __host__ static __device__ bool isEqual(const T &a, const T &b)
Compares a to b.
Definition Numeric.h:94
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
bool operator<(const Item &item1, const Item &item2)
Compare two entities.
Definition Item.h:566
double Real
Type representing a real number.
Real2 operator/(const Real2Proxy &vec, Real sca)
Division by a scalar.
Definition Real2Proxy.h:388