Arcane  4.2.1.0
Developer documentation
Loading...
Searching...
No Matches
MathReal3.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/* MathReal3.h (C) 2000-2026 */
9/* */
10/* Mathematical operations on Real3. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_BASE_MATHREAL3_H
13#define ARCCORE_BASE_MATHREAL3_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/Real3.h"
18#include "arccore/base/MathBase.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace math
30{
32 inline constexpr ARCCORE_HOST_DEVICE Real squareNormL2(const Real3& v)
33 {
34 return v.x * v.x + v.y * v.y + v.z * v.z;
35 }
36
43 inline constexpr ARCCORE_HOST_DEVICE bool isNearlyZero(const Real3& v)
44 {
45 return math::isNearlyZero(v.x) && math::isNearlyZero(v.y) && math::isNearlyZero(v.z);
46 }
47
49 inline ARCCORE_HOST_DEVICE Real normL2(const Real3& v)
50 {
52 }
53
62 {
63 Real d = math::normL2(v);
64 if (!math::isZero(d))
65 v.divSame(d);
66 return v;
67 }
68
75 inline Real3 normalizeL2(const Real3& v)
76 {
77 Real d = math::normL2(v);
78 if (!math::isZero(d))
79 return v / d;
80 return v;
81 }
82} // namespace math
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
86
87inline Real3& Real3::
88normalize()
89{
90 return math::mutableNormalize(*this);
91}
92
93inline constexpr ARCCORE_HOST_DEVICE bool Real3::
94isNearlyZero() const
95{
96 return math::isNearlyZero(*this);
97}
98
99inline ARCCORE_HOST_DEVICE Real Real3::
100normL2() const
101{
102 return math::normL2(*this);
103}
104
105inline ARCCORE_HOST_DEVICE Real Real3::
106abs() const
107{
108 return math::normL2(*this);
109}
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
113
114} // End namespace Arcane
115
116/*---------------------------------------------------------------------------*/
117/*---------------------------------------------------------------------------*/
118
119#endif
Class managing a 3-dimensional real vector.
__host__ __device__ Real normL2() const
Returns the L2 norm of the triplet $ .
Definition MathReal3.h:100
constexpr __host__ __device__ Real3 & divSame(Real b)
Divides each component of the triplet by b.
__host__ __device__ Real abs() const
Returns the norm of the triplet $ .
Definition MathReal3.h:106
Namespace for mathematical functions.
Definition MathUtils.h:36
Real2 normalizeL2(const Real2 &v)
Returns the pair v normalized by the L2 norm.
Definition MathReal2.h:69
constexpr __host__ __device__ DataType squareNormL2(const NumVector< DataType, Size > &v)
Returns the square of the L2 norm of the vector.
Definition MathNumeric.h:77
bool isZero(const BuiltInProxy< _Type > &a)
Tests if a value is exactly equal to zero.
Real2 & mutableNormalize(Real2 &v)
Normalizes the pair.
Definition MathReal2.h:55
apfloat sqrt(apfloat v)
Square root of v.
Definition MathApfloat.h:69
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
double Real
Type representing a real number.
Real y
second component of the triplet
Real z
third component of the triplet
Real x
first component of the triplet