Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Real3.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/* Real3.h (C) 2000-2026 */
9/* */
10/* Vector of 3 dimensions of 'Real'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_REAL3_H
13#define ARCANE_UTILS_REAL3_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Numeric.h"
18#include "arcane/utils/Real2.h"
19
20#include <iosfwd>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
32{
33 public:
34
35 Real x; //!< first component of the triplet
36 Real y; //!< second component of the triplet
37 Real z; //!< third component of the triplet
38
39 /*!
40 * Read-only access to the @a i-th component of Real3POD
41 *
42 * @note only works for x, y, and z ordered in the POD
43 *
44 * @param i component number to return
45 *
46 * @return (&x)[i]
47 */
48 ARCCORE_HOST_DEVICE Real operator[](Integer i) const
49 {
50 ARCCORE_CHECK_AT(i, 3);
51 return (&x)[i];
52 }
53
54 /*!
55 * Read-only access to the @a i-th component of Real3POD
56 *
57 * @note only works for x, y, and z ordered in the POD
58 *
59 * @param i component number to return
60 *
61 * @return (&x)[i]
62 */
63 ARCCORE_HOST_DEVICE Real operator()(Integer i) const
64 {
65 ARCCORE_CHECK_AT(i, 3);
66 return (&x)[i];
67 }
68
69 /*!
70 * Access to the @a i-th component of Real3POD
71 *
72 * @note only works for x, y, and z ordered in the POD
73 *
74 * @param i component number to return
75 *
76 * @return (&x)[i]
77 */
78 ARCCORE_HOST_DEVICE Real& operator[](Integer i)
79 {
80 ARCCORE_CHECK_AT(i, 3);
81 return (&x)[i];
82 }
83
84 /*!
85 * Access to the @a i-th component of Real3POD
86 *
87 * @note only works for x, y, and z ordered in the POD
88 *
89 * @param i component number to return
90 *
91 * @return (&x)[i]
92 */
93 ARCCORE_HOST_DEVICE Real& operator()(Integer i)
94 {
95 ARCCORE_CHECK_AT(i, 3);
96 return (&x)[i];
97 }
98
99 //! Sets the \a i-th component to \a value
100 ARCCORE_HOST_DEVICE void setComponent(Integer i, Real value)
101 {
102 ARCCORE_CHECK_AT(i, 3);
103 (&x)[i] = value;
104 }
105};
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
109
110/*!
111 * \brief Class managing a 3-dimensional real vector.
112
113 Le vector includes three components \a x, \a y, and \a z, which are of type \b Real.
114
115 \code
116 Real3 value (1.0,2.3,4.5); // Created a triplet (x=1.0, y=2.3, z=4.5)
117 cout << value.x; // Prints component x
118 value.y += 3.2; // Adds 3.2 to component \b y
119 \endcode
120
121 or equivalently
122
123 \code
124 Real3 value (1.0,2.3,4.5); // Created a triplet (x=1.0, y=2.3, z=4.5)
125 cout << value[0]; // Prints component x
126 value[1] += 3.2; // Adds 3.2 to component \b y
127 \endcode
128 */
129
130class ARCANE_UTILS_EXPORT Real3
131: public Real3POD
132{
133 public:
134
135 //! Constructs the zero vector.
136 constexpr ARCCORE_HOST_DEVICE Real3()
137 : Real3POD()
138 {
139 x = 0.0;
140 y = 0.0;
141 z = 0.0;
142 }
143
144 //! Constructs the triplet (ax,ay,az)
145 constexpr ARCCORE_HOST_DEVICE Real3(Real ax, Real ay, Real az)
146 : Real3POD()
147 {
148 x = ax;
149 y = ay;
150 z = az;
151 }
152
153 //! Constructs a triplet identical to \a f
154 Real3(const Real3& f) = default;
155
156 //! Constructs a triplet identical to \a f
157 constexpr ARCCORE_HOST_DEVICE explicit Real3(const Real3POD& f)
158 : Real3POD()
159 {
160 x = f.x;
161 y = f.y;
162 z = f.z;
163 }
164
165 //! Constructs the instance with the triplet (v,v,v).
166 constexpr ARCCORE_HOST_DEVICE explicit Real3(Real v)
167 : Real3POD()
168 {
169 x = y = z = v;
170 }
171
172 //! Constructs a triplet identical to \a f
173 constexpr ARCCORE_HOST_DEVICE explicit Real3(const Real2& f)
174 : Real3POD()
175 {
176 x = f.x;
177 y = f.y;
178 z = 0.0;
179 }
180
181 //! Constructs the triplet (av[0], av[1], av[2])
182 constexpr ARCCORE_HOST_DEVICE Real3(ConstArrayView<Real> av)
183 : Real3POD()
184 {
185 x = av[0];
186 y = av[1];
187 z = av[2];
188 }
189
190 //! Copy assignment operator.
191 Real3& operator=(const Real3& f) = default;
192
193 //! Assigns the triplet (v,v,v) to the instance.
194 constexpr ARCCORE_HOST_DEVICE Real3& operator=(Real v)
195 {
196 x = y = z = v;
197 return (*this);
198 }
199
200 public:
201
202 constexpr ARCCORE_HOST_DEVICE static Real3 null() { return Real3(0., 0., 0.); }
203 constexpr ARCCORE_HOST_DEVICE static Real3 zero() { return Real3(0., 0., 0.); }
204
205 public:
206
207 //! Returns a copy of the triplet.
208 constexpr ARCCORE_HOST_DEVICE Real3 copy() const { return (*this); }
209
210 //! Resets the triplet using default constructors.
211 constexpr ARCCORE_HOST_DEVICE Real3& reset()
212 {
213 x = y = z = 0.;
214 return (*this);
215 }
216
217 //! Assigns the triplet (ax,ay,az) to the instance.
218 constexpr ARCCORE_HOST_DEVICE Real3& assign(Real ax, Real ay, Real az)
219 {
220 x = ax;
221 y = ay;
222 z = az;
223 return (*this);
224 }
225
226 //! Copies the triplet \a f
227 constexpr ARCCORE_HOST_DEVICE Real3& assign(Real3 f)
228 {
229 x = f.x;
230 y = f.y;
231 z = f.z;
232 return (*this);
233 }
234
235 //! Returns a view of the three elements of the vector.
236 constexpr ARCCORE_HOST_DEVICE ArrayView<Real> view()
237 {
238 return { 3, &x };
239 }
240
241 //! Returns a constant view of the three elements of the vector.
242 constexpr ARCCORE_HOST_DEVICE ConstArrayView<Real> constView() const
243 {
244 return { 3, &x };
245 }
246
247 //! Absolute value component by component.
248 ARCCORE_HOST_DEVICE Real3 absolute() const { return Real3(math::abs(x), math::abs(y), math::abs(z)); }
249
250 /*!
251 * \brief Reads a triplet from the stream \a i
252 * The triplet is read in the form of three values of type #value_type.
253 */
254 std::istream& assign(std::istream& i);
255
256 //! Writes the triplet to the stream \a o readable by an assign()
257 std::ostream& print(std::ostream& o) const;
258
259 //! Writes the triplet to the stream \a o in the form (x,y,z)
260 std::ostream& printXyz(std::ostream& o) const;
261
262 //! Adds \a b to the triplet
263 constexpr ARCCORE_HOST_DEVICE Real3& add(Real3 b)
264 {
265 x += b.x;
266 y += b.y;
267 z += b.z;
268 return (*this);
269 }
270
271 //! Subtracts \a b from the triplet
272 constexpr ARCCORE_HOST_DEVICE Real3& sub(Real3 b)
273 {
274 x -= b.x;
275 y -= b.y;
276 z -= b.z;
277 return (*this);
278 }
279
280 //! Multiplies each component of the triplet by the corresponding component of \a b
281 constexpr ARCCORE_HOST_DEVICE Real3& mul(Real3 b)
282 {
283 x *= b.x;
284 y *= b.y;
285 z *= b.z;
286 return (*this);
287 }
288
289 //! Divides each component of the triplet by the corresponding component of \a b
290 constexpr ARCCORE_HOST_DEVICE Real3& div(Real3 b)
291 {
292 x /= b.x;
293 y /= b.y;
294 z /= b.z;
295 return (*this);
296 }
297
298 //! Adds \a b to each component of the triplet
299 constexpr ARCCORE_HOST_DEVICE Real3& addSame(Real b)
300 {
301 x += b;
302 y += b;
303 z += b;
304 return (*this);
305 }
306
307 //! Subtracts b from each component of the triplet
308 constexpr ARCCORE_HOST_DEVICE Real3& subSame(Real b)
309 {
310 x -= b;
311 y -= b;
312 z -= b;
313 return (*this);
314 }
315
316 //! Multiplies each component of the triplet by b
317 constexpr ARCCORE_HOST_DEVICE Real3& mulSame(Real b)
318 {
319 x *= b;
320 y *= b;
321 z *= b;
322 return (*this);
323 }
324
325 //! Divides each component of the triplet by b
326 constexpr ARCCORE_HOST_DEVICE Real3& divSame(Real b)
327 {
328 x /= b;
329 y /= b;
330 z /= b;
331 return (*this);
332 }
333
334 //! Adds b to the triplet.
335 constexpr ARCCORE_HOST_DEVICE Real3& operator+=(Real3 b) { return add(b); }
336
337 //! Subtracts b from the triplet
338 constexpr ARCCORE_HOST_DEVICE Real3& operator-=(Real3 b) { return sub(b); }
339
340 //! Multiplies each component of the triplet by the corresponding component of b
341 constexpr ARCCORE_HOST_DEVICE Real3& operator*=(Real3 b) { return mul(b); }
342
343 //! Multiplies each component of the triplet by the real number b
344 constexpr ARCCORE_HOST_DEVICE void operator*=(Real b)
345 {
346 x *= b;
347 y *= b;
348 z *= b;
349 }
350
351 //! Divides each component of the triplet by the corresponding component of b
352 constexpr ARCCORE_HOST_DEVICE Real3& operator/=(Real3 b) { return div(b); }
353
354 //! Divides each component of the triplet by the real number b
355 constexpr ARCCORE_HOST_DEVICE void operator/=(Real b)
356 {
357 x /= b;
358 y /= b;
359 z /= b;
360 }
361
362 //! Creates a triplet that equals this triplet added to b
363 constexpr ARCCORE_HOST_DEVICE Real3 operator+(Real3 b) const { return Real3(x + b.x, y + b.y, z + b.z); }
364
365 //! Creates a triplet that equals b subtracted from this triplet
366 constexpr ARCCORE_HOST_DEVICE Real3 operator-(Real3 b) const { return Real3(x - b.x, y - b.y, z - b.z); }
367
368 //! Creates a triplet opposite to the current triplet
369 constexpr ARCCORE_HOST_DEVICE Real3 operator-() const { return Real3(-x, -y, -z); }
370
371 /*!
372 * \brief Creates a triplet that equals this triplet whose each component has been
373 * multiplied by the corresponding component of b.
374 */
375 constexpr ARCCORE_HOST_DEVICE Real3 operator*(Real3 b) const { return Real3(x * b.x, y * b.y, z * b.z); }
376
377 /*!
378 * \brief Creates a triplet that equals this triplet whose each component has been divided
379 * by the corresponding component of b.
380 */
381 constexpr ARCCORE_HOST_DEVICE Real3 operator/(Real3 b) const { return Real3(x / b.x, y / b.y, z / b.z); }
382
383 //! Multiplication by a scalar.
384 friend constexpr ARCCORE_HOST_DEVICE Real3 operator*(Real sca, Real3 vec)
385 {
386 return Real3(vec.x * sca, vec.y * sca, vec.z * sca);
387 }
388
389 //! Multiplication by a scalar.
390 friend constexpr ARCCORE_HOST_DEVICE Real3 operator*(Real3 vec, Real sca)
391 {
392 return Real3(vec.x * sca, vec.y * sca, vec.z * sca);
393 }
394
395 //! Division by a scalar.
396 friend constexpr ARCCORE_HOST_DEVICE Real3 operator/(Real3 vec, Real sca)
397 {
398 return Real3(vec.x / sca, vec.y / sca, vec.z / sca);
399 }
400
401 public:
402
403 /*!
404 * \brief Comparison operator.
405 *
406 * This operator allows sorting Real3 for example
407 * in std::set
408 */
409 friend constexpr ARCCORE_HOST_DEVICE bool operator<(Real3 v1, Real3 v2)
410 {
411 if (v1.x == v2.x) {
412 if (v1.y == v2.y)
413 return v1.z < v2.z;
414 else
415 return v1.y < v2.y;
416 }
417 return (v1.x < v2.x);
418 }
419
420 //! Writes the triplet t to the stream o
421 friend std::ostream& operator<<(std::ostream& o, Real3 t)
422 {
423 return t.printXyz(o);
424 }
425
426 //! Reads the triplet t from the stream o.
427 friend std::istream& operator>>(std::istream& i, Real3& t)
428 {
429 return t.assign(i);
430 }
431
432 /*!
433 * \brief Compares the current instance component by component to b.
434 *
435 * \retval true if this.x==b.x and this.y==b.y and this.z==b.z.
436 * \retval false otherwise.
437 */
438 constexpr ARCCORE_HOST_DEVICE bool operator==(Real3 b) const
439 {
440 return _eq(x, b.x) && _eq(y, b.y) && _eq(z, b.z);
441 }
442
443 /*!
444 * \brief Compares two triplets.
445 * For the notion of equality, see operator==()
446 * \retval true if the two triplets are different,
447 * \retval false otherwise.
448 */
449 constexpr ARCCORE_HOST_DEVICE bool operator!=(Real3 b) const { return !operator==(b); }
450
451 public:
452
453 //! Returns the square of the L2 norm of the triplet $\f$x^2+y^2+z^2$\f$
454 // TODO: deprecate mid-2025: ARCANE_DEPRECATED_REASON("Y2024: Use math::squareNormL2(const Real3&) instead")
455 constexpr ARCCORE_HOST_DEVICE Real squareNormL2() const { return x * x + y * y + z * z; }
456
457 //! Returns the L2 norm of the triplet $\f$\sqrt{x^2+y^2+z^2}\f$
458 // TODO: deprecate mid-2025: ARCANE_DEPRECATED_REASON("Y2024: Use math::normL2(const Real3&) instead")
459 inline ARCCORE_HOST_DEVICE Real normL2() const;
460
461 //! Returns the square of the norm of the triplet $\f$x^2+y^2+z^2\f$
462 ARCCORE_DEPRECATED_2021("Use math::squareNormL2(const Real3&) instead")
463 constexpr ARCCORE_HOST_DEVICE Real abs2() const { return x * x + y * y + z * z; }
464
465 //! Returns the norm of the triplet $\f$\sqrt{x^2+y^2+z^2}\f$
466 ARCCORE_DEPRECATED_2021("Use math::normL2(const Real3&) instead")
467 inline ARCCORE_HOST_DEVICE Real abs() const;
468
469 // TODO: deprecate mid-2025: ARCANE_DEPRECATED_REASON("Y2024: Use math::isNearlyZero(const Real3&) instead")
470 inline constexpr ARCCORE_HOST_DEVICE bool isNearlyZero() const;
471
472 // TODO: deprecate mid-2026: ARCANE_DEPRECATED_REASON("Y2024: Use math::mutableNormalize(Real3&) instead")
473 inline Real3& normalize();
474
475 private:
476
477 /*!
478 * \brief Compares the values of a and b using the TypeEqualT comparator
479 * \retval true if a and b are equal,
480 * \retval false otherwise.
481 */
482 inline constexpr ARCCORE_HOST_DEVICE static bool _eq(Real a, Real b);
483
484 //! Returns the square root of a
485 inline ARCCORE_HOST_DEVICE static Real _sqrt(Real a);
486};
487
488/*---------------------------------------------------------------------------*/
489/*---------------------------------------------------------------------------*/
490
491inline constexpr ARCCORE_HOST_DEVICE Real2::
492Real2(const Real3& v)
493: Real2POD()
494{
495 x = v.x;
496 y = v.y;
497}
498
499/*---------------------------------------------------------------------------*/
500/*---------------------------------------------------------------------------*/
501
502namespace math
503{
504 //! Returns the square of the L2 norm of the triplet $\f$x^2+y^2+z^2\f$
505 inline constexpr ARCCORE_HOST_DEVICE Real squareNormL2(const Real3& v)
506 {
507 return v.x * v.x + v.y * v.y + v.z * v.z;
508 }
509
510 /*!
511 * \brief Indicates if the instance is close to the zero instance.
512 *
513 * \retval true if math::isNearlyZero() is true for every component.
514 * \retval false otherwise.
515 */
516 inline constexpr ARCCORE_HOST_DEVICE bool isNearlyZero(const Real3& v)
517 {
518 return math::isNearlyZero(v.x) && math::isNearlyZero(v.y) && math::isNearlyZero(v.z);
519 }
520
521 //! Returns the L2 norm of the triplet $\f$\sqrt{v.x^2+v.y^2+v.z^2}\f$
522 inline ARCCORE_HOST_DEVICE Real normL2(const Real3& v)
523 {
525 }
526
527 /*!
528 * \brief Normalizes the triplet v
529 *
530 * If the triplet is non-zero, divides each component by the norm of the triplet
531 * (abs()), so that after calling this method, math::normL2() equals 1.
532 * If the triplet is zero, does nothing.
533 */
535 {
536 Real d = math::normL2(v);
537 if (!math::isZero(d))
538 v.divSame(d);
539 return v;
540 }
541
542 /*!
543 * \brief Returns the triplet v normalized with the L2 norm.
544 *
545 * If `math::normL2(v)` is non-zero, returns the triplet v divided by `math::normL2(v)`.
546 * Otherwise, returns v.
547 */
548 inline Real3 normalizeL2(const Real3& v)
549 {
550 Real d = math::normL2(v);
551 if (!math::isZero(d))
552 return v / d;
553 return v;
554 }
555} // namespace math
556
557/*---------------------------------------------------------------------------*/
558/*---------------------------------------------------------------------------*/
559
560inline Real3& Real3::
561normalize()
562{
563 return math::mutableNormalize(*this);
564}
565
566inline constexpr ARCCORE_HOST_DEVICE bool Real3::
567isNearlyZero() const
568{
569 return math::isNearlyZero(*this);
570}
571
572inline constexpr ARCCORE_HOST_DEVICE bool Real3::
573_eq(Real a, Real b)
574{
575 return math::isEqual(a, b);
576}
577
578ARCCORE_HOST_DEVICE inline Real Real3::
579_sqrt(Real a)
580{
581 return math::sqrt(a);
582}
583
584inline ARCCORE_HOST_DEVICE Real Real3::
585normL2() const
586{
587 return math::normL2(*this);
588}
589
590inline ARCCORE_HOST_DEVICE Real Real3::
591abs() const
592{
593 return math::normL2(*this);
594}
595
596/*---------------------------------------------------------------------------*/
597/*---------------------------------------------------------------------------*/
598
599} // End namespace Arcane
600
601/*---------------------------------------------------------------------------*/
602/*---------------------------------------------------------------------------*/
603
604#endif
Modifiable view of an array of type T.
Constant view of an array of type T.
Class managing a 2-dimensional real vector.
Definition Real2.h:122
constexpr __host__ __device__ Real2()
Constructs the zero vector.
Definition Real2.h:126
Class managing a 3-dimensional real vector.
Definition Real3.h:132
constexpr __host__ __device__ void operator*=(Real b)
Multiplies each component of the triplet by the real number b.
Definition Real3.h:344
Real3(const Real3 &f)=default
Constructs a triplet identical to f.
friend constexpr __host__ __device__ Real3 operator/(Real3 vec, Real sca)
Division by a scalar.
Definition Real3.h:396
Real3 & operator=(const Real3 &f)=default
Copy assignment operator.
constexpr __host__ __device__ Real3 & operator/=(Real3 b)
Divides each component of the triplet by the corresponding component of b.
Definition Real3.h:352
constexpr __host__ __device__ Real3 operator*(Real3 b) const
Creates a triplet that equals this triplet whose each component has been multiplied by the correspond...
Definition Real3.h:375
constexpr __host__ __device__ Real3(Real ax, Real ay, Real az)
Constructs the triplet (ax,ay,az).
Definition Real3.h:145
constexpr __host__ __device__ ArrayView< Real > view()
Returns a view of the three elements of the vector.
Definition Real3.h:236
constexpr __host__ __device__ Real3 & subSame(Real b)
Subtracts b from each component of the triplet.
Definition Real3.h:308
friend constexpr __host__ __device__ Real3 operator*(Real3 vec, Real sca)
Multiplication by a scalar.
Definition Real3.h:390
constexpr __host__ __device__ Real3 operator-() const
Creates a triplet opposite to the current triplet.
Definition Real3.h:369
constexpr __host__ __device__ Real3 operator+(Real3 b) const
Creates a triplet that equals this triplet added to b.
Definition Real3.h:363
constexpr __host__ __device__ Real3 & operator*=(Real3 b)
Multiplies each component of the triplet by the corresponding component of b.
Definition Real3.h:341
constexpr __host__ __device__ bool operator!=(Real3 b) const
Compares two triplets. For the notion of equality, see operator==().
Definition Real3.h:449
constexpr __host__ __device__ Real3 operator/(Real3 b) const
Creates a triplet that equals this triplet whose each component has been divided by the corresponding...
Definition Real3.h:381
constexpr __host__ __device__ bool operator==(Real3 b) const
Compares the current instance component by component to b.
Definition Real3.h:438
constexpr __host__ __device__ Real3 & mulSame(Real b)
Multiplies each component of the triplet by b.
Definition Real3.h:317
constexpr __host__ __device__ Real3 & operator=(Real v)
Assigns the triplet (v,v,v) to the instance.
Definition Real3.h:194
constexpr __host__ __device__ Real3 & add(Real3 b)
Adds b to the triplet.
Definition Real3.h:263
constexpr __host__ __device__ Real3(const Real3POD &f)
Constructs a triplet identical to f.
Definition Real3.h:157
friend constexpr __host__ __device__ Real3 operator*(Real sca, Real3 vec)
Multiplication by a scalar.
Definition Real3.h:384
constexpr __host__ __device__ Real3 & addSame(Real b)
Adds b to each component of the triplet.
Definition Real3.h:299
constexpr __host__ __device__ Real3(Real v)
Constructs the instance with the triplet (v,v,v).
Definition Real3.h:166
constexpr __host__ __device__ ConstArrayView< Real > constView() const
Returns a constant view of the three elements of the vector.
Definition Real3.h:242
constexpr __host__ __device__ void operator/=(Real b)
Divides each component of the triplet by the real number b.
Definition Real3.h:355
std::ostream & printXyz(std::ostream &o) const
Writes the triplet to the stream o in the form (x,y,z).
Definition Real3.cc:49
constexpr __host__ __device__ Real3 & operator-=(Real3 b)
Subtracts b from the triplet.
Definition Real3.h:338
constexpr __host__ __device__ Real3(ConstArrayView< Real > av)
Constructs the triplet (av[0], av[1], av[2]).
Definition Real3.h:182
friend constexpr __host__ __device__ bool operator<(Real3 v1, Real3 v2)
Comparison operator.
Definition Real3.h:409
constexpr __host__ __device__ Real squareNormL2() const
Returns the square of the L2 norm of the triplet $ .
Definition Real3.h:455
friend std::istream & operator>>(std::istream &i, Real3 &t)
Reads the triplet t from the stream o.
Definition Real3.h:427
constexpr __host__ __device__ Real3(const Real2 &f)
Constructs a triplet identical to f.
Definition Real3.h:173
constexpr __host__ __device__ Real3 copy() const
Returns a copy of the triplet.
Definition Real3.h:208
constexpr __host__ __device__ Real3 & reset()
Resets the triplet using default constructors.
Definition Real3.h:211
constexpr __host__ __device__ Real3 & divSame(Real b)
Divides each component of the triplet by b.
Definition Real3.h:326
constexpr __host__ __device__ Real3()
Constructs the zero vector.
Definition Real3.h:136
constexpr __host__ __device__ Real3 & sub(Real3 b)
Subtracts b from the triplet.
Definition Real3.h:272
__host__ __device__ Real3 absolute() const
Absolute value component by component.
Definition Real3.h:248
constexpr __host__ __device__ Real3 & operator+=(Real3 b)
Adds b to the triplet.
Definition Real3.h:335
constexpr __host__ __device__ Real3 operator-(Real3 b) const
Creates a triplet that equals b subtracted from this triplet.
Definition Real3.h:366
constexpr __host__ __device__ Real3 & div(Real3 b)
Divides each component of the triplet by the corresponding component of b.
Definition Real3.h:290
constexpr __host__ __device__ Real3 & assign(Real ax, Real ay, Real az)
Assigns the triplet (ax,ay,az) to the instance.
Definition Real3.h:218
constexpr __host__ __device__ Real abs2() const
Returns the square of the norm of the triplet $ .
Definition Real3.h:463
constexpr __host__ __device__ Real3 & assign(Real3 f)
Copies the triplet f.
Definition Real3.h:227
friend std::ostream & operator<<(std::ostream &o, Real3 t)
Writes the triplet t to the stream o.
Definition Real3.h:421
constexpr __host__ __device__ Real3 & mul(Real3 b)
Multiplies each component of the triplet by the corresponding component of b.
Definition Real3.h:281
Namespace for mathematical functions.
Definition MathUtils.h:36
Real2 normalizeL2(const Real2 &v)
Returns the pair v normalized by the L2 norm.
Definition Real2.h:508
constexpr __host__ __device__ Real squareNormL2(const Real2 &v)
Returns the squared norm of the pair $ .
Definition Real2.h:476
__host__ __device__ double sqrt(double v)
Square root of v.
Definition Math.h:142
bool isZero(const BuiltInProxy< _Type > &a)
Tests if a value is exactly equal to zero.
Real2 & mutableNormalize(Real2 &v)
Normalizes the pair.
Definition Real2.h:494
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
Real y
second component of the pair
Definition Real2.h:35
Real x
first component of the pair
Definition Real2.h:34
__host__ __device__ Real & operator()(Integer i)
Definition Real3.h:93
__host__ __device__ Real operator[](Integer i) const
Definition Real3.h:48
Real y
second component of the triplet
Definition Real3.h:36
Real z
third component of the triplet
Definition Real3.h:37
__host__ __device__ Real operator()(Integer i) const
Definition Real3.h:63
__host__ __device__ void setComponent(Integer i, Real value)
Sets the i-th component to value.
Definition Real3.h:100
__host__ __device__ Real & operator[](Integer i)
Definition Real3.h:78
Real x
first component of the triplet
Definition Real3.h:35