Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::NumVector< T, Size > Class Template Reference

Small fixed-size vector of N numerical data points. More...

#include <arcane/utils/NumVector.h>

Collaboration diagram for Arcane::NumVector< T, Size >:

Public Types

using ThatClass = NumVector<T, Size>
using DataType = T

Public Member Functions

 NumVector ()=default
 Constructs the zero vector.
constexpr __host__ __device__ NumVector (T ax, T ay)
 Constructs with the pair (ax,ay).
constexpr __host__ __device__ NumVector (T ax, T ay, T az)
 Constructs with the triplet (ax,ay,az).
constexpr __host__ __device__ NumVector (T a1, T a2, T a3, T a4)
 Constructs with the quadruplet (a1,a2,a3,a4).
constexpr __host__ __device__ NumVector (T a1, T a2, T a3, T a4, T a5)
 Constructs with the quintuplet (a1,a2,a3,a4,a5).
template<bool = true>
constexpr __host__ __device__ NumVector (const T(&v)[Size])
 Constructs the instance with the value v for each component.
constexpr __host__ __device__ NumVector (std::array< T, Size > v)
 Constructs the instance with the value v for each component.
constexpr __host__ __device__ NumVector (T v)
 Constructs the instance with the value v for each component.
constexpr __host__ __device__ NumVector (Real2 v)
constexpr __host__ __device__ NumVector (Real3 v)
constexpr __host__ __device__ ThatClass & operator= (Real v)
 Assigns the triplet (v,v,v) to the instance.
constexpr __host__ __device__ ThatClass & operator= (const Real2 &v)
constexpr __host__ __device__ ThatClass & operator= (const Real3 &v)
 operator Real2 () const
 operator Real3 () const
constexpr __host__ __device__ bool isNearlyZero () const
constexpr __host__ __device__ Real squareNormL2 () const
 Returns the square of the L2 norm of the triplet \(x^2+y^2+z^2\).
__host__ __device__ Real normL2 () const
 Returns the L2 norm of the triplet \(\sqrt{x^2+y^2+z^2}\).
__host__ __device__ ThatClass absolute () const
 Absolute value component by component.
constexpr __host__ __device__ ThatClass & operator+= (T b)
 Adds b to each component of the instance.
constexpr __host__ __device__ ThatClass & operator+= (const ThatClass &b)
 Adds b to the instance.
constexpr __host__ __device__ ThatClass & operator-= (T b)
 Subtracts b from each component of the instance.
constexpr __host__ __device__ ThatClass & operator-= (const ThatClass &b)
 Subtracts b from the instance.
constexpr __host__ __device__ ThatClass & operator*= (T b)
 Multiplies each component by b.
constexpr __host__ __device__ ThatClass & operator/= (T b)
 Divides each component by b.
constexpr __host__ __device__ ThatClass operator- () const
 Creates a triplet opposite to the current triplet.
constexpr __host__ __device__ T & operator() (Int32 i)
constexpr __host__ __device__ T operator() (Int32 i) const
constexpr __host__ __device__ T & operator[] (Int32 i)
constexpr __host__ __device__ T operator[] (Int32 i) const
T & vx ()
 Value of the first component.
vx () const
 Value of the first component.
T & vy ()
 Value of the second component.
vy () const
 Value of the second component.
T & vz ()
 Value of the third component.
vz () const
 Value of the third component.

Static Public Member Functions

constexpr __host__ static __device__ ThatClass zero ()

Static Private Member Functions

constexpr __host__ static __device__ bool _eq (T a, T b)
 Compares the values of a and b using the TypeEqualT comparator.
__host__ static __device__ T _sqrt (T a)
 Returns the square root of a.

Private Attributes

m_values [Size] = {}
 Vector values.

Friends

constexpr __host__ __device__ ThatClass operator+ (const ThatClass &a, const ThatClass &b)
 Creates a triplet that equals this triplet added to b.
constexpr __host__ __device__ ThatClass operator- (const ThatClass &a, const ThatClass &b)
 Creates a triplet that equals b subtracted from this triplet.
constexpr __host__ __device__ ThatClass operator* (T a, const ThatClass &vec)
 Multiplication by a scalar.
constexpr __host__ __device__ ThatClass operator* (const ThatClass &vec, T b)
 Multiplication by a scalar.
constexpr __host__ __device__ ThatClass operator/ (const ThatClass &vec, T b)
 Division by a scalar.
constexpr __host__ __device__ bool operator== (const ThatClass &a, const ThatClass &b)
 Compares the current instance component by component to b.
constexpr __host__ __device__ bool operator!= (const ThatClass &a, const ThatClass &b)
 Compares two vectors For the notion of equality, see operator==().

Detailed Description

template<typename T, int Size>
class Arcane::NumVector< T, Size >

Small fixed-size vector of N numerical data points.

Note
Currently only implemented for the Real type.
Warning
API is currently under definition. Do not use outside of Arcane.

It is possible to access each component of the vector using 'operator[]' or 'operator()' or via the methods vx(), vy(), vz() if the dimension is sufficient (for example, vz() is only accessible if Size>=3.

Definition at line 43 of file NumVector.h.

Member Typedef Documentation

◆ DataType

template<typename T, int Size>
using Arcane::NumVector< T, Size >::DataType = T

Definition at line 51 of file NumVector.h.

◆ ThatClass

template<typename T, int Size>
using Arcane::NumVector< T, Size >::ThatClass = NumVector<T, Size>

Definition at line 50 of file NumVector.h.

Constructor & Destructor Documentation

◆ NumVector() [1/9]

template<typename T, int Size>
__host__ __device__ Arcane::NumVector< T, Size >::NumVector ( T ax,
T ay )
inlineconstexpr

Constructs with the pair (ax,ay).

Definition at line 59 of file NumVector.h.

◆ NumVector() [2/9]

template<typename T, int Size>
__host__ __device__ Arcane::NumVector< T, Size >::NumVector ( T ax,
T ay,
T az )
inlineconstexpr

Constructs with the triplet (ax,ay,az).

Definition at line 67 of file NumVector.h.

◆ NumVector() [3/9]

template<typename T, int Size>
__host__ __device__ Arcane::NumVector< T, Size >::NumVector ( T a1,
T a2,
T a3,
T a4 )
inlineconstexpr

Constructs with the quadruplet (a1,a2,a3,a4).

Definition at line 76 of file NumVector.h.

◆ NumVector() [4/9]

template<typename T, int Size>
__host__ __device__ Arcane::NumVector< T, Size >::NumVector ( T a1,
T a2,
T a3,
T a4,
T a5 )
inlineconstexpr

Constructs with the quintuplet (a1,a2,a3,a4,a5).

Definition at line 86 of file NumVector.h.

◆ NumVector() [5/9]

template<typename T, int Size>
template<bool = true>
__host__ __device__ Arcane::NumVector< T, Size >::NumVector ( const T(&) v[Size])
inlineexplicitconstexpr

Constructs the instance with the value v for each component.

Definition at line 97 of file NumVector.h.

◆ NumVector() [6/9]

template<typename T, int Size>
__host__ __device__ Arcane::NumVector< T, Size >::NumVector ( std::array< T, Size > v)
inlineexplicitconstexpr

Constructs the instance with the value v for each component.

Definition at line 104 of file NumVector.h.

◆ NumVector() [7/9]

template<typename T, int Size>
__host__ __device__ Arcane::NumVector< T, Size >::NumVector ( T v)
inlineexplicitconstexpr

Constructs the instance with the value v for each component.

Definition at line 111 of file NumVector.h.

◆ NumVector() [8/9]

template<typename T, int Size>
__host__ __device__ Arcane::NumVector< T, Size >::NumVector ( Real2 v)
inlineexplicitconstexpr

Definition at line 117 of file NumVector.h.

◆ NumVector() [9/9]

template<typename T, int Size>
__host__ __device__ Arcane::NumVector< T, Size >::NumVector ( Real3 v)
inlineexplicitconstexpr

Definition at line 121 of file NumVector.h.

Member Function Documentation

◆ _eq()

template<typename T, int Size>
__host__ static __device__ bool Arcane::NumVector< T, Size >::_eq ( T a,
T b )
inlinestaticconstexprprivate

Compares the values of a and b using the TypeEqualT comparator.

Return values
trueif a and b are equal,
falseotherwise.

Definition at line 376 of file NumVector.h.

Referenced by Arcane::NumVector< DataType, Size >::operator==.

Here is the caller graph for this function:

◆ _sqrt()

template<typename T, int Size>
__host__ static __device__ T Arcane::NumVector< T, Size >::_sqrt ( T a)
inlinestaticprivate

Returns the square root of a.

Definition at line 382 of file NumVector.h.

Referenced by Arcane::NumVector< DataType, Size >::normL2().

Here is the caller graph for this function:

◆ absolute()

template<typename T, int Size>
__host__ __device__ ThatClass Arcane::NumVector< T, Size >::absolute ( ) const
inline

Absolute value component by component.

Definition at line 176 of file NumVector.h.

◆ isNearlyZero()

template<typename T, int Size>
__host__ __device__ bool Arcane::NumVector< T, Size >::isNearlyZero ( ) const
inlineconstexpr

Definition at line 155 of file NumVector.h.

◆ normL2()

template<typename T, int Size>
__host__ __device__ Real Arcane::NumVector< T, Size >::normL2 ( ) const
inline

Returns the L2 norm of the triplet \(\sqrt{x^2+y^2+z^2}\).

Definition at line 173 of file NumVector.h.

◆ operator Real2()

template<typename T, int Size>
Arcane::NumVector< T, Size >::operator Real2 ( ) const
inline

Definition at line 145 of file NumVector.h.

◆ operator Real3()

template<typename T, int Size>
Arcane::NumVector< T, Size >::operator Real3 ( ) const
inline

Definition at line 147 of file NumVector.h.

◆ operator()() [1/2]

template<typename T, int Size>
__host__ __device__ T & Arcane::NumVector< T, Size >::operator() ( Int32 i)
inlineconstexpr

Definition at line 309 of file NumVector.h.

◆ operator()() [2/2]

template<typename T, int Size>
__host__ __device__ T Arcane::NumVector< T, Size >::operator() ( Int32 i) const
inlineconstexpr

Definition at line 314 of file NumVector.h.

◆ operator*=()

template<typename T, int Size>
__host__ __device__ ThatClass & Arcane::NumVector< T, Size >::operator*= ( T b)
inlineconstexpr

Multiplies each component by b.

Definition at line 217 of file NumVector.h.

◆ operator+=() [1/2]

template<typename T, int Size>
__host__ __device__ ThatClass & Arcane::NumVector< T, Size >::operator+= ( const ThatClass & b)
inlineconstexpr

Adds b to the instance.

Definition at line 193 of file NumVector.h.

◆ operator+=() [2/2]

template<typename T, int Size>
__host__ __device__ ThatClass & Arcane::NumVector< T, Size >::operator+= ( T b)
inlineconstexpr

Adds b to each component of the instance.

Definition at line 185 of file NumVector.h.

◆ operator-()

template<typename T, int Size>
__host__ __device__ ThatClass Arcane::NumVector< T, Size >::operator- ( ) const
inlineconstexpr

Creates a triplet opposite to the current triplet.

Definition at line 251 of file NumVector.h.

◆ operator-=() [1/2]

template<typename T, int Size>
__host__ __device__ ThatClass & Arcane::NumVector< T, Size >::operator-= ( const ThatClass & b)
inlineconstexpr

Subtracts b from the instance.

Definition at line 209 of file NumVector.h.

◆ operator-=() [2/2]

template<typename T, int Size>
__host__ __device__ ThatClass & Arcane::NumVector< T, Size >::operator-= ( T b)
inlineconstexpr

Subtracts b from each component of the instance.

Definition at line 201 of file NumVector.h.

◆ operator/=()

template<typename T, int Size>
__host__ __device__ ThatClass & Arcane::NumVector< T, Size >::operator/= ( T b)
inlineconstexpr

Divides each component by b.

Definition at line 225 of file NumVector.h.

◆ operator=() [1/3]

template<typename T, int Size>
__host__ __device__ ThatClass & Arcane::NumVector< T, Size >::operator= ( const Real2 & v)
inlineconstexpr

Definition at line 133 of file NumVector.h.

◆ operator=() [2/3]

template<typename T, int Size>
__host__ __device__ ThatClass & Arcane::NumVector< T, Size >::operator= ( const Real3 & v)
inlineconstexpr

Definition at line 139 of file NumVector.h.

◆ operator=() [3/3]

template<typename T, int Size>
__host__ __device__ ThatClass & Arcane::NumVector< T, Size >::operator= ( Real v)
inlineconstexpr

Assigns the triplet (v,v,v) to the instance.

Definition at line 126 of file NumVector.h.

◆ operator[]() [1/2]

template<typename T, int Size>
__host__ __device__ T & Arcane::NumVector< T, Size >::operator[] ( Int32 i)
inlineconstexpr

Definition at line 319 of file NumVector.h.

◆ operator[]() [2/2]

template<typename T, int Size>
__host__ __device__ T Arcane::NumVector< T, Size >::operator[] ( Int32 i) const
inlineconstexpr

Definition at line 324 of file NumVector.h.

◆ squareNormL2()

template<typename T, int Size>
__host__ __device__ Real Arcane::NumVector< T, Size >::squareNormL2 ( ) const
inlineconstexpr

Returns the square of the L2 norm of the triplet \(x^2+y^2+z^2\).

Definition at line 164 of file NumVector.h.

Referenced by Arcane::NumVector< DataType, Size >::normL2().

Here is the caller graph for this function:

◆ vx() [1/2]

template<typename T, int Size>
T & Arcane::NumVector< T, Size >::vx ( )
inline

Value of the first component.

Definition at line 331 of file NumVector.h.

◆ vx() [2/2]

template<typename T, int Size>
T Arcane::NumVector< T, Size >::vx ( ) const
inline

Value of the first component.

Definition at line 336 of file NumVector.h.

◆ vy() [1/2]

template<typename T, int Size>
T & Arcane::NumVector< T, Size >::vy ( )
inline

Value of the second component.

Definition at line 342 of file NumVector.h.

◆ vy() [2/2]

template<typename T, int Size>
T Arcane::NumVector< T, Size >::vy ( ) const
inline

Value of the second component.

Definition at line 347 of file NumVector.h.

◆ vz() [1/2]

template<typename T, int Size>
T & Arcane::NumVector< T, Size >::vz ( )
inline

Value of the third component.

Definition at line 353 of file NumVector.h.

◆ vz() [2/2]

template<typename T, int Size>
T Arcane::NumVector< T, Size >::vz ( ) const
inline

Value of the third component.

Definition at line 358 of file NumVector.h.

◆ zero()

template<typename T, int Size>
__host__ static __device__ ThatClass Arcane::NumVector< T, Size >::zero ( )
inlinestaticconstexpr

Definition at line 151 of file NumVector.h.

◆ operator!=

template<typename T, int Size>
__host__ __device__ bool operator!= ( const ThatClass & a,
const ThatClass & b )
friend

Compares two vectors For the notion of equality, see operator==().

Definition at line 304 of file NumVector.h.

◆ operator* [1/2]

template<typename T, int Size>
__host__ __device__ ThatClass operator* ( const ThatClass & vec,
T b )
friend

Multiplication by a scalar.

Definition at line 269 of file NumVector.h.

◆ operator* [2/2]

template<typename T, int Size>
__host__ __device__ ThatClass operator* ( T a,
const ThatClass & vec )
friend

Multiplication by a scalar.

Definition at line 260 of file NumVector.h.

◆ operator+

template<typename T, int Size>
__host__ __device__ ThatClass operator+ ( const ThatClass & a,
const ThatClass & b )
friend

Creates a triplet that equals this triplet added to b.

Definition at line 233 of file NumVector.h.

◆ operator-

template<typename T, int Size>
__host__ __device__ ThatClass operator- ( const ThatClass & a,
const ThatClass & b )
friend

Creates a triplet that equals b subtracted from this triplet.

Definition at line 242 of file NumVector.h.

◆ operator/

template<typename T, int Size>
__host__ __device__ ThatClass operator/ ( const ThatClass & vec,
T b )
friend

Division by a scalar.

Definition at line 278 of file NumVector.h.

◆ operator==

template<typename T, int Size>
__host__ __device__ bool operator== ( const ThatClass & a,
const ThatClass & b )
friend

Compares the current instance component by component to b.

Return values
trueif this.x==b.x and this.y==b.y and this.z==b.z.
falseotherwise.

Definition at line 292 of file NumVector.h.

Member Data Documentation

◆ m_values


The documentation for this class was generated from the following file: