Arcane  4.1.15.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.
__host__ __device__ void fill (const T &v)
 Fill the matrix with the value 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==().
std::ostream & operator<< (std::ostream &o, const NumMatrix &t)

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 41 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 56 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 55 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 54 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 64 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 72 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 81 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 92 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 105 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 111 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 115 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 395 of file NumMatrix.h.

◆ fill()

template<typename T, int RowSize, int ColumnSize>
__host__ __device__ void Arcane::NumMatrix< T, RowSize, ColumnSize >::fill ( const T & v)
inline

Fill the matrix with the value v.

Definition at line 335 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 158 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 165 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 184 of file NumMatrix.h.

◆ isSquare()

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

Definition at line 48 of file NumMatrix.h.

◆ isSquare2()

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

Definition at line 49 of file NumMatrix.h.

◆ isSquare3()

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

Definition at line 50 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 139 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 144 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 298 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 312 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 320 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 207 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 193 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 237 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 200 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 214 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 127 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 133 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 120 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 305 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 328 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 354 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 359 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 364 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 369 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 374 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 379 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 152 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 290 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 254 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 246 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 221 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 229 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 262 of file NumMatrix.h.

◆ operator<<

template<typename T, int RowSize, int ColumnSize>
std::ostream & operator<< ( std::ostream & o,
const NumMatrix< T, RowSize, ColumnSize > & t )
friend

Definition at line 342 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 276 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 386 of file NumMatrix.h.

◆ Size

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

Definition at line 47 of file NumMatrix.h.


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