Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::NumMatrix< T, RowSize, ColumnSize > Class Template Reference

Small fixed-size matrix containing RowSize rows and ColumnSize columns. More...

#include <arcane/utils/NumMatrix.h>

Collaboration diagram for Arcane::NumMatrix< T, RowSize, ColumnSize >:

Public Types

using VectorType = NumVector<T, ColumnSize>
using ThatClass = NumMatrix<T, RowSize, ColumnSize>
using DataType = T

Public Member Functions

 NumMatrix ()=default
 Constructs the matrix with all coefficients zero.
constexpr __host__ __device__ NumMatrix (const VectorType &ax, const VectorType &ay)
 Constructs the matrix with rows (ax, ay).
constexpr __host__ __device__ NumMatrix (const VectorType &ax, const VectorType &ay, const VectorType &az)
 Constructs the matrix with rows (ax, ay, az).
constexpr __host__ __device__ NumMatrix (const VectorType &a1, const VectorType &a2, const VectorType &a3, const VectorType &a4)
 Constructs the matrix with rows (a1, a2, a3, a4).
constexpr __host__ __device__ NumMatrix (const VectorType &a1, const VectorType &a2, const VectorType &a3, const VectorType &a4, const VectorType &a5)
 Constructs the matrix with rows (a1, a2, a3, a4, a5).
constexpr __host__ __device__ NumMatrix (T v)
 Constructs the instance with the triplet (v, v, v).
constexpr __host__ __device__ NumMatrix (Real2x2 v)
constexpr __host__ __device__ NumMatrix (Real3x3 v)
constexpr __host__ __device__ ThatClass & operator= (T v)
 Assigns the triplet (v, v, v) to the instance.
constexpr __host__ __device__ ThatClass & operator= (const Real2x2 &v)
constexpr __host__ __device__ ThatClass & operator= (const Real3x3 &v)
 operator Real2x2 () const
 operator Real3x3 () const
constexpr __host__ __device__ bool isNearlyZero () const
 Compares the matrix with the zero matrix.
constexpr __host__ __device__ ThatClass & operator+= (const ThatClass &b)
 Adds b to the triplet.
constexpr __host__ __device__ ThatClass & operator-= (const ThatClass &b)
 Subtracts b from the triplet.
constexpr __host__ __device__ ThatClass & operator*= (T b)
 Multiplies each component of the matrix by the real number b.
constexpr __host__ __device__ ThatClass & operator/= (T b)
 Divides each component of the matrix by the real number b.
constexpr __host__ __device__ ThatClass operator- () const
 Creates a tensor opposite to the current tensor.
constexpr __host__ __device__ VectorType operator() (Int32 i) const
constexpr __host__ __device__ VectorType operator[] (Int32 i) const
constexpr __host__ __device__ T & operator() (Int32 i, Int32 j)
constexpr __host__ __device__ T operator() (Int32 i, Int32 j) const
constexpr __host__ __device__ void setLine (Int32 i, const VectorType &v)
 Sets the value of the i-th row to v.
VectorType & vx ()
VectorType vx () const
VectorType & vy ()
VectorType vy () const
VectorType & vz ()
VectorType vz () const

Static Public Member Functions

constexpr __host__ static __device__ ThatClass zero ()
 Constructs the zero matrix.
constexpr __host__ static __device__ ThatClass fromColumns (T ax, T ay, T az, T bx, T by, T bz, T cx, T cy, T cz)
 Constructs the matrix ((ax,bx,cx), (ay,by,cy), (az,bz,cz)).
constexpr __host__ static __device__ ThatClass fromLines (T ax, T bx, T cx, T ay, T by, T cy, T az, T bz, T cz)
 Constructs the matrix ((ax,bx,cx), (ay,by,cy), (az,bz,cz)).

Static Private Member Functions

static constexpr bool isSquare ()
static constexpr bool isSquare2 ()
static constexpr bool isSquare3 ()
constexpr __host__ static __device__ bool _eq (T a, T b)
 Compares the values of a and b using the TypeEqualT comparator.

Private Attributes

VectorType m_values [RowSize] = {}

Static Private Attributes

static constexpr int Size = RowSize

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 a subtracted from this triplet.
constexpr __host__ __device__ ThatClass operator* (DataType a, const ThatClass &mat)
 Multiplication by a scalar.
constexpr __host__ __device__ ThatClass operator* (const ThatClass &mat, DataType b)
 Multiplication by a scalar.
constexpr __host__ __device__ ThatClass operator/ (const ThatClass &mat, DataType 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 triplets. For the notion of equality, see operator==().

Detailed Description

template<typename T, int RowSize, int ColumnSize>
class Arcane::NumMatrix< T, RowSize, ColumnSize >

Small fixed-size matrix containing RowSize rows and ColumnSize columns.

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

It is possible to access each vector component 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 42 of file NumMatrix.h.

Member Typedef Documentation

◆ DataType

template<typename T, int RowSize, int ColumnSize>
using Arcane::NumMatrix< T, RowSize, ColumnSize >::DataType = T

Definition at line 57 of file NumMatrix.h.

◆ ThatClass

template<typename T, int RowSize, int ColumnSize>
using Arcane::NumMatrix< T, RowSize, ColumnSize >::ThatClass = NumMatrix<T, RowSize, ColumnSize>

Definition at line 56 of file NumMatrix.h.

◆ VectorType

template<typename T, int RowSize, int ColumnSize>
using Arcane::NumMatrix< T, RowSize, ColumnSize >::VectorType = NumVector<T, ColumnSize>

Definition at line 55 of file NumMatrix.h.

Constructor & Destructor Documentation

◆ NumMatrix() [1/7]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ Arcane::NumMatrix< T, RowSize, ColumnSize >::NumMatrix ( const VectorType & ax,
const VectorType & ay )
inlineconstexpr

Constructs the matrix with rows (ax, ay).

Definition at line 65 of file NumMatrix.h.

◆ NumMatrix() [2/7]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ Arcane::NumMatrix< T, RowSize, ColumnSize >::NumMatrix ( const VectorType & ax,
const VectorType & ay,
const VectorType & az )
inlineconstexpr

Constructs the matrix with rows (ax, ay, az).

Definition at line 73 of file NumMatrix.h.

◆ NumMatrix() [3/7]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ Arcane::NumMatrix< T, RowSize, ColumnSize >::NumMatrix ( const VectorType & a1,
const VectorType & a2,
const VectorType & a3,
const VectorType & a4 )
inlineconstexpr

Constructs the matrix with rows (a1, a2, a3, a4).

Definition at line 82 of file NumMatrix.h.

◆ NumMatrix() [4/7]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ Arcane::NumMatrix< T, RowSize, ColumnSize >::NumMatrix ( const VectorType & a1,
const VectorType & a2,
const VectorType & a3,
const VectorType & a4,
const VectorType & a5 )
inlineconstexpr

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

Definition at line 93 of file NumMatrix.h.

◆ NumMatrix() [5/7]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ Arcane::NumMatrix< T, RowSize, ColumnSize >::NumMatrix ( T v)
inlineexplicitconstexpr

Constructs the instance with the triplet (v, v, v).

Definition at line 106 of file NumMatrix.h.

◆ NumMatrix() [6/7]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ Arcane::NumMatrix< T, RowSize, ColumnSize >::NumMatrix ( Real2x2 v)
inlineexplicitconstexpr

Definition at line 112 of file NumMatrix.h.

◆ NumMatrix() [7/7]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ Arcane::NumMatrix< T, RowSize, ColumnSize >::NumMatrix ( Real3x3 v)
inlineexplicitconstexpr

Definition at line 116 of file NumMatrix.h.

Member Function Documentation

◆ _eq()

template<typename T, int RowSize, int ColumnSize>
__host__ static __device__ bool Arcane::NumMatrix< T, RowSize, ColumnSize >::_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 378 of file NumMatrix.h.

◆ fromColumns()

template<typename T, int RowSize, int ColumnSize>
__host__ static __device__ ThatClass Arcane::NumMatrix< T, RowSize, ColumnSize >::fromColumns ( T ax,
T ay,
T az,
T bx,
T by,
T bz,
T cx,
T cy,
T cz )
inlinestaticconstexpr

Constructs the matrix ((ax,bx,cx), (ay,by,cy), (az,bz,cz)).

Definition at line 159 of file NumMatrix.h.

◆ fromLines()

template<typename T, int RowSize, int ColumnSize>
__host__ static __device__ ThatClass Arcane::NumMatrix< T, RowSize, ColumnSize >::fromLines ( T ax,
T bx,
T cx,
T ay,
T by,
T cy,
T az,
T bz,
T cz )
inlinestaticconstexpr

Constructs the matrix ((ax,bx,cx), (ay,by,cy), (az,bz,cz)).

Definition at line 166 of file NumMatrix.h.

◆ isNearlyZero()

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ bool Arcane::NumMatrix< T, RowSize, ColumnSize >::isNearlyZero ( ) const
inlineconstexpr

Compares the matrix with the zero matrix.

The matrix is zero if and only if each of its components is less than a given epsilon. The epsilon value used is that of float_info<value_type>::nearlyEpsilon():

\[A=0 \Leftrightarrow |A.x|<\epsilon,|A.y|<\epsilon,|A.z|<\epsilon \]

Return values
trueif the matrix is equal to the zero matrix,
falseotherwise.

Definition at line 185 of file NumMatrix.h.

◆ isSquare()

template<typename T, int RowSize, int ColumnSize>
constexpr bool Arcane::NumMatrix< T, RowSize, ColumnSize >::isSquare ( )
inlinestaticconstexprprivate

Definition at line 49 of file NumMatrix.h.

◆ isSquare2()

template<typename T, int RowSize, int ColumnSize>
constexpr bool Arcane::NumMatrix< T, RowSize, ColumnSize >::isSquare2 ( )
inlinestaticconstexprprivate

Definition at line 50 of file NumMatrix.h.

◆ isSquare3()

template<typename T, int RowSize, int ColumnSize>
constexpr bool Arcane::NumMatrix< T, RowSize, ColumnSize >::isSquare3 ( )
inlinestaticconstexprprivate

Definition at line 51 of file NumMatrix.h.

◆ operator Real2x2()

template<typename T, int RowSize, int ColumnSize>
Arcane::NumMatrix< T, RowSize, ColumnSize >::operator Real2x2 ( ) const
inline

Definition at line 140 of file NumMatrix.h.

◆ operator Real3x3()

template<typename T, int RowSize, int ColumnSize>
Arcane::NumMatrix< T, RowSize, ColumnSize >::operator Real3x3 ( ) const
inline

Definition at line 145 of file NumMatrix.h.

◆ operator()() [1/3]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ VectorType Arcane::NumMatrix< T, RowSize, ColumnSize >::operator() ( Int32 i) const
inlineconstexpr

Definition at line 299 of file NumMatrix.h.

◆ operator()() [2/3]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ T & Arcane::NumMatrix< T, RowSize, ColumnSize >::operator() ( Int32 i,
Int32 j )
inlineconstexpr

Definition at line 313 of file NumMatrix.h.

◆ operator()() [3/3]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ T Arcane::NumMatrix< T, RowSize, ColumnSize >::operator() ( Int32 i,
Int32 j ) const
inlineconstexpr

Definition at line 321 of file NumMatrix.h.

◆ operator*=()

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

Multiplies each component of the matrix by the real number b.

Definition at line 208 of file NumMatrix.h.

◆ operator+=()

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

Adds b to the triplet.

Definition at line 194 of file NumMatrix.h.

◆ operator-()

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ ThatClass Arcane::NumMatrix< T, RowSize, ColumnSize >::operator- ( ) const
inlineconstexpr

Creates a tensor opposite to the current tensor.

Definition at line 238 of file NumMatrix.h.

◆ operator-=()

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

Subtracts b from the triplet.

Definition at line 201 of file NumMatrix.h.

◆ operator/=()

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

Divides each component of the matrix by the real number b.

Definition at line 215 of file NumMatrix.h.

◆ operator=() [1/3]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ ThatClass & Arcane::NumMatrix< T, RowSize, ColumnSize >::operator= ( const Real2x2 & v)
inlineconstexpr

Definition at line 128 of file NumMatrix.h.

◆ operator=() [2/3]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ ThatClass & Arcane::NumMatrix< T, RowSize, ColumnSize >::operator= ( const Real3x3 & v)
inlineconstexpr

Definition at line 134 of file NumMatrix.h.

◆ operator=() [3/3]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ ThatClass & Arcane::NumMatrix< T, RowSize, ColumnSize >::operator= ( T v)
inlineconstexpr

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

Definition at line 121 of file NumMatrix.h.

◆ operator[]()

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ VectorType Arcane::NumMatrix< T, RowSize, ColumnSize >::operator[] ( Int32 i) const
inlineconstexpr

Definition at line 306 of file NumMatrix.h.

◆ setLine()

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ void Arcane::NumMatrix< T, RowSize, ColumnSize >::setLine ( Int32 i,
const VectorType & v )
inlineconstexpr

Sets the value of the i-th row to v.

Definition at line 329 of file NumMatrix.h.

◆ vx() [1/2]

template<typename T, int RowSize, int ColumnSize>
VectorType & Arcane::NumMatrix< T, RowSize, ColumnSize >::vx ( )
inline

Definition at line 337 of file NumMatrix.h.

◆ vx() [2/2]

template<typename T, int RowSize, int ColumnSize>
VectorType Arcane::NumMatrix< T, RowSize, ColumnSize >::vx ( ) const
inline

Definition at line 342 of file NumMatrix.h.

◆ vy() [1/2]

template<typename T, int RowSize, int ColumnSize>
VectorType & Arcane::NumMatrix< T, RowSize, ColumnSize >::vy ( )
inline

Definition at line 347 of file NumMatrix.h.

◆ vy() [2/2]

template<typename T, int RowSize, int ColumnSize>
VectorType Arcane::NumMatrix< T, RowSize, ColumnSize >::vy ( ) const
inline

Definition at line 352 of file NumMatrix.h.

◆ vz() [1/2]

template<typename T, int RowSize, int ColumnSize>
VectorType & Arcane::NumMatrix< T, RowSize, ColumnSize >::vz ( )
inline

Definition at line 357 of file NumMatrix.h.

◆ vz() [2/2]

template<typename T, int RowSize, int ColumnSize>
VectorType Arcane::NumMatrix< T, RowSize, ColumnSize >::vz ( ) const
inline

Definition at line 362 of file NumMatrix.h.

◆ zero()

template<typename T, int RowSize, int ColumnSize>
__host__ static __device__ ThatClass Arcane::NumMatrix< T, RowSize, ColumnSize >::zero ( )
inlinestaticconstexpr

Constructs the zero matrix.

Definition at line 153 of file NumMatrix.h.

◆ operator!=

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

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

Return values
trueif the two triplets are different,
falseotherwise.

Definition at line 291 of file NumMatrix.h.

◆ operator* [1/2]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ ThatClass operator* ( const ThatClass & mat,
DataType b )
friend

Multiplication by a scalar.

Definition at line 255 of file NumMatrix.h.

◆ operator* [2/2]

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ ThatClass operator* ( DataType a,
const ThatClass & mat )
friend

Multiplication by a scalar.

Definition at line 247 of file NumMatrix.h.

◆ operator+

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

Creates a triplet that equals this triplet added to b.

Definition at line 222 of file NumMatrix.h.

◆ operator-

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

Creates a triplet that equals a subtracted from this triplet.

Definition at line 230 of file NumMatrix.h.

◆ operator/

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ ThatClass operator/ ( const ThatClass & mat,
DataType b )
friend

Division by a scalar.

Definition at line 263 of file NumMatrix.h.

◆ operator==

template<typename T, int RowSize, int ColumnSize>
__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 277 of file NumMatrix.h.

Member Data Documentation

◆ m_values

template<typename T, int RowSize, int ColumnSize>
VectorType Arcane::NumMatrix< T, RowSize, ColumnSize >::m_values[RowSize] = {}
private

Definition at line 369 of file NumMatrix.h.

◆ Size

template<typename T, int RowSize, int ColumnSize>
int Arcane::NumMatrix< T, RowSize, ColumnSize >::Size = RowSize
staticconstexprprivate

Definition at line 48 of file NumMatrix.h.


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