Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Arcane::Real2 Class Reference

Class managing a 2-dimensional real vector. More...

#include <arcane/utils/Real2.h>

Public Member Functions

constexpr __host__ __device__ Real2 ()
 Constructs the zero vector.
constexpr __host__ __device__ Real2 (Real ax, Real ay)
 Constructs the pair (ax,ay).
 Real2 (const Real2 &f)=default
 Constructs a copy identical to f.
constexpr __host__ __device__ Real2 (const Real2POD &f)
 Constructs a copy identical to f.
constexpr __host__ __device__ Real2 (Real v)
 Constructs the instance with the triplet (v,v,v).
constexpr __host__ __device__ Real2 (const Real3 &v)
 Constructs the instance using the first two components of Real3.
constexpr __host__ __device__ Real2 (ConstArrayView< Real > av)
 Constructs the pair (av[0], av[1]).
Real2operator= (const Real2 &f)=default
constexpr __host__ __device__ Real2operator= (Real v)
 Assigns the pair (v,v) to the instance.
constexpr __host__ __device__ Real2 copy () const
 Returns a copy of the pair.
constexpr __host__ __device__ Real2reset ()
 Resets the pair using default constructors.
constexpr __host__ __device__ Real2assign (Real ax, Real ay)
 Assigns the triplet (ax,ay,az) to the instance.
constexpr __host__ __device__ Real2assign (Real2 f)
 Copies the pair f.
constexpr __host__ __device__ ArrayView< Realview ()
 Returns a view of the two elements of the vector.
constexpr __host__ __device__ ConstArrayView< RealconstView () const
 Returns a constant view of the two elements of the vector.
__host__ __device__ Real2 absolute () const
 Absolute value component by component.
std::istream & assign (std::istream &i)
 Reads a pair from stream i The pair is read in the form of three values of type #value_type.
std::ostream & print (std::ostream &o) const
 Writes the pair to stream o readable by an assign().
std::ostream & printXy (std::ostream &o) const
 Writes the pair to stream o in the form (x,y).
constexpr __host__ __device__ Real2add (Real2 b)
 Adds b to the pair.
constexpr __host__ __device__ Real2sub (Real2 b)
 Subtracts b from the pair.
constexpr __host__ __device__ Real2mul (Real2 b)
 Multiplies each component of the pair by the corresponding component of b.
constexpr __host__ __device__ Real2div (Real2 b)
 Divides each component of the pair by the corresponding component of b.
constexpr __host__ __device__ Real2addSame (Real b)
 Adds b to each component of the pair.
constexpr __host__ __device__ Real2subSame (Real b)
 Subtracts b from each component of the pair.
constexpr __host__ __device__ Real2mulSame (Real b)
 Multiplies each component of the pair by b.
constexpr __host__ __device__ Real2divSame (Real b)
 Divides each component of the pair by b.
constexpr __host__ __device__ Real2operator+= (Real2 b)
 Adds b to the pair.
constexpr __host__ __device__ Real2operator-= (Real2 b)
 Subtracts b from the pair.
constexpr __host__ __device__ Real2operator*= (Real2 b)
 Multiplies each component of the pair by the corresponding component of b.
constexpr __host__ __device__ void operator*= (Real b)
 Multiplies each component of the pair by the real number b.
constexpr __host__ __device__ Real2operator/= (Real2 b)
 Divides each component of the pair by the corresponding component of b.
constexpr __host__ __device__ void operator/= (Real b)
 Divides each component of the pair by the real number b.
constexpr __host__ __device__ Real2 operator+ (Real2 b) const
 Creates a pair that equals this pair added to b.
constexpr __host__ __device__ Real2 operator- (Real2 b) const
 Creates a pair that equals b subtracted from this pair.
constexpr __host__ __device__ Real2 operator- () const
 Creates a pair opposite to the current pair.
constexpr __host__ __device__ Real2 operator* (Real2 b) const
 Creates a pair that equals this pair, where each component has been multiplied by the corresponding component of b.
constexpr __host__ __device__ Real2 operator/ (Real2 b) const
 Creates a pair that equals this pair, where each component has been divided by the corresponding component of b.
constexpr __host__ __device__ bool operator== (Real2 b) const
 Compares the current instance component by component to b.
constexpr __host__ __device__ bool operator!= (Real2 b) const
 Compares two pairs. For the concept of equality, see operator==().
constexpr __host__ __device__ Real squareNormL2 () const
 Returns the squared norm of the pair $ \(x^2+y^2+z^2$\).
__host__ __device__ Real abs2 () const
 Returns the squared norm of the pair $ \(x^2+y^2+z^2$\).
__host__ __device__ Real abs () const
 Returns the norm of the pair $ \(\sqrt{x^2+y^2+z^2}$\).
constexpr __host__ __device__ bool isNearlyZero () const
 Indicates if the instance is close to the zero instance.
__host__ __device__ Real normL2 () const
 Returns the norm of the pair $ \(\sqrt{x^2+y^2+z^2}$\).
Real2normalize ()
 Normalizes the pair.
Public Member Functions inherited from Arcane::Real2POD
__host__ __device__ Real operator[] (Integer i) const
__host__ __device__ Real operator() (Integer i) const
__host__ __device__ Realoperator[] (Integer i)
__host__ __device__ Realoperator() (Integer i)
__host__ __device__ void setComponent (Integer i, Real value)
 Positions the i th component at value.

Static Public Member Functions

constexpr __host__ static __device__ Real2 null ()

Friends

constexpr __host__ __device__ Real2 operator* (Real sca, Real2 vec)
 Multiplication by a scalar.
constexpr __host__ __device__ Real2 operator* (Real2 vec, Real sca)
 Multiplication by a scalar.
constexpr __host__ __device__ Real2 operator/ (Real2 vec, Real sca)
 Division by a scalar.
constexpr __host__ __device__ bool operator< (Real2 v1, Real2 v2)
 Comparison operator.
std::ostream & operator<< (std::ostream &o, Real2 t)
 Writes the pair t to the stream o.
std::istream & operator>> (std::istream &i, Real2 &t)
 Reads the pair t from the stream o.

Additional Inherited Members

Public Attributes inherited from Arcane::Real2POD
Real x
 first component of the pair
Real y
 second component of the pair

Detailed Description

Class managing a 2-dimensional real vector.

The vector includes two components x and y which are of type Real.

Real2 value (1.0,2.3); // Creates a pair (x=1.0, y=2.3)
cout << value.x; // Prints the x component
value.y += 3.2; // Adds 3.2 to the \b y component
constexpr __host__ __device__ Real2()
Constructs the zero vector.
Definition Real2.h:126

Definition at line 120 of file Real2.h.

Constructor & Destructor Documentation

◆ Real2() [1/6]

◆ Real2() [2/6]

__host__ __device__ Arcane::Real2::Real2 ( Real ax,
Real ay )
inlineconstexpr

Constructs the pair (ax,ay).

Definition at line 133 of file Real2.h.

References Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ Real2() [3/6]

__host__ __device__ Arcane::Real2::Real2 ( const Real2POD & f)
inlineexplicitconstexpr

Constructs a copy identical to f.

Definition at line 142 of file Real2.h.

References Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ Real2() [4/6]

__host__ __device__ Arcane::Real2::Real2 ( Real v)
inlineexplicitconstexpr

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

Definition at line 150 of file Real2.h.

References Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ Real2() [5/6]

__host__ __device__ Arcane::Real2::Real2 ( const Real3 & v)
inlineexplicitconstexpr

Constructs the instance using the first two components of Real3.

Definition at line 491 of file Real3.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ Real2() [6/6]

__host__ __device__ Arcane::Real2::Real2 ( ConstArrayView< Real > av)
inlineconstexpr

Constructs the pair (av[0], av[1]).

Definition at line 160 of file Real2.h.

References Arcane::Real2POD::x, and Arcane::Real2POD::y.

Member Function Documentation

◆ abs()

__host__ __device__ Real Arcane::Real2::abs ( ) const
inline

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

Definition at line 550 of file Real2.h.

◆ abs2()

__host__ __device__ Real Arcane::Real2::abs2 ( ) const
inline

Returns the squared norm of the pair $ \(x^2+y^2+z^2$\).

Definition at line 417 of file Real2.h.

References abs2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

Referenced by abs2().

◆ absolute()

__host__ __device__ Real2 Arcane::Real2::absolute ( ) const
inline

Absolute value component by component.

Definition at line 221 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ add()

__host__ __device__ Real2 & Arcane::Real2::add ( Real2 b)
inlineconstexpr

Adds b to the pair.

Definition at line 236 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

Referenced by operator+=().

◆ addSame()

__host__ __device__ Real2 & Arcane::Real2::addSame ( Real b)
inlineconstexpr

Adds b to each component of the pair.

Definition at line 268 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ assign() [1/3]

__host__ __device__ Real2 & Arcane::Real2::assign ( Real ax,
Real ay )
inlineconstexpr

Assigns the triplet (ax,ay,az) to the instance.

Definition at line 193 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

Referenced by operator>>.

◆ assign() [2/3]

__host__ __device__ Real2 & Arcane::Real2::assign ( Real2 f)
inlineconstexpr

Copies the pair f.

Definition at line 201 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ assign() [3/3]

std::istream & Arcane::Real2::assign ( std::istream & i)

Reads a pair from stream i The pair is read in the form of three values of type #value_type.

Definition at line 26 of file Real2.cc.

References Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ constView()

__host__ __device__ ConstArrayView< Real > Arcane::Real2::constView ( ) const
inlineconstexpr

Returns a constant view of the two elements of the vector.

Definition at line 215 of file Real2.h.

References Arcane::Real2POD::x.

◆ copy()

__host__ __device__ Real2 Arcane::Real2::copy ( ) const
inlineconstexpr

Returns a copy of the pair.

Definition at line 183 of file Real2.h.

References Real2().

◆ div()

__host__ __device__ Real2 & Arcane::Real2::div ( Real2 b)
inlineconstexpr

Divides each component of the pair by the corresponding component of b.

Definition at line 260 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

Referenced by operator/=().

◆ divSame()

__host__ __device__ Real2 & Arcane::Real2::divSame ( Real b)
inlineconstexpr

Divides each component of the pair by b.

Definition at line 292 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

Referenced by Arcane::math::mutableNormalize().

◆ isNearlyZero()

__host__ __device__ bool Arcane::Real2::isNearlyZero ( ) const
inlineconstexpr

Indicates if the instance is close to the zero instance.

Return values
trueif math::isNearlyZero() is true for every component.
falseotherwise.

Definition at line 520 of file Real2.h.

◆ mul()

__host__ __device__ Real2 & Arcane::Real2::mul ( Real2 b)
inlineconstexpr

Multiplies each component of the pair by the corresponding component of b.

Definition at line 252 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

Referenced by operator*=().

◆ mulSame()

__host__ __device__ Real2 & Arcane::Real2::mulSame ( Real b)
inlineconstexpr

Multiplies each component of the pair by b.

Definition at line 284 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ normalize()

Real2 & Arcane::Real2::normalize ( )
inline

Normalizes the pair.

If the pair is non-zero, divides each component by the norm of the pair (abs()), such that after calling this method, abs() equals 1. If the pair is zero, does nothing.

Definition at line 544 of file Real2.h.

References Arcane::math::mutableNormalize(), and Real2().

◆ normL2()

__host__ __device__ Real Arcane::Real2::normL2 ( ) const
inline

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

Definition at line 538 of file Real2.h.

◆ null()

__host__ static __device__ Real2 Arcane::Real2::null ( )
inlinestaticconstexpr

Definition at line 178 of file Real2.h.

◆ operator!=()

__host__ __device__ bool Arcane::Real2::operator!= ( Real2 b) const
inlineconstexpr

Compares two pairs. For the concept of equality, see operator==().

Return values
trueif the two pairs are different,
falseotherwise.

Definition at line 407 of file Real2.h.

References operator==(), and Real2().

◆ operator*()

__host__ __device__ Real2 Arcane::Real2::operator* ( Real2 b) const
inlineconstexpr

Creates a pair that equals this pair, where each component has been multiplied by the corresponding component of b.

Definition at line 338 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator*=() [1/2]

__host__ __device__ void Arcane::Real2::operator*= ( Real b)
inlineconstexpr

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

Definition at line 309 of file Real2.h.

References Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator*=() [2/2]

__host__ __device__ Real2 & Arcane::Real2::operator*= ( Real2 b)
inlineconstexpr

Multiplies each component of the pair by the corresponding component of b.

Definition at line 306 of file Real2.h.

References mul(), and Real2().

◆ operator+()

__host__ __device__ Real2 Arcane::Real2::operator+ ( Real2 b) const
inlineconstexpr

Creates a pair that equals this pair added to b.

Definition at line 326 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator+=()

__host__ __device__ Real2 & Arcane::Real2::operator+= ( Real2 b)
inlineconstexpr

Adds b to the pair.

Definition at line 300 of file Real2.h.

References add(), and Real2().

◆ operator-() [1/2]

__host__ __device__ Real2 Arcane::Real2::operator- ( ) const
inlineconstexpr

Creates a pair opposite to the current pair.

Definition at line 332 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator-() [2/2]

__host__ __device__ Real2 Arcane::Real2::operator- ( Real2 b) const
inlineconstexpr

Creates a pair that equals b subtracted from this pair.

Definition at line 329 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator-=()

__host__ __device__ Real2 & Arcane::Real2::operator-= ( Real2 b)
inlineconstexpr

Subtracts b from the pair.

Definition at line 303 of file Real2.h.

References Real2(), and sub().

◆ operator/()

__host__ __device__ Real2 Arcane::Real2::operator/ ( Real2 b) const
inlineconstexpr

Creates a pair that equals this pair, where each component has been divided by the corresponding component of b.

Definition at line 344 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator/=() [1/2]

__host__ __device__ void Arcane::Real2::operator/= ( Real b)
inlineconstexpr

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

Definition at line 319 of file Real2.h.

References Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator/=() [2/2]

__host__ __device__ Real2 & Arcane::Real2::operator/= ( Real2 b)
inlineconstexpr

Divides each component of the pair by the corresponding component of b.

Definition at line 316 of file Real2.h.

References div(), and Real2().

◆ operator=()

__host__ __device__ Real2 & Arcane::Real2::operator= ( Real v)
inlineconstexpr

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

Definition at line 170 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator==()

__host__ __device__ bool Arcane::Real2::operator== ( Real2 b) const
inlineconstexpr

Compares the current instance component by component to b.

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

Definition at line 396 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

Referenced by operator!=().

◆ print()

std::ostream & Arcane::Real2::print ( std::ostream & o) const

Writes the pair to stream o readable by an assign().

Definition at line 36 of file Real2.cc.

References Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ printXy()

std::ostream & Arcane::Real2::printXy ( std::ostream & o) const

Writes the pair to stream o in the form (x,y).

Definition at line 46 of file Real2.cc.

References Arcane::Real2POD::x, and Arcane::Real2POD::y.

Referenced by operator<<.

◆ reset()

__host__ __device__ Real2 & Arcane::Real2::reset ( )
inlineconstexpr

Resets the pair using default constructors.

Definition at line 186 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ squareNormL2()

__host__ __device__ Real Arcane::Real2::squareNormL2 ( ) const
inlineconstexpr

Returns the squared norm of the pair $ \(x^2+y^2+z^2$\).

Definition at line 413 of file Real2.h.

References Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ sub()

__host__ __device__ Real2 & Arcane::Real2::sub ( Real2 b)
inlineconstexpr

Subtracts b from the pair.

Definition at line 244 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

Referenced by operator-=().

◆ subSame()

__host__ __device__ Real2 & Arcane::Real2::subSame ( Real b)
inlineconstexpr

Subtracts b from each component of the pair.

Definition at line 276 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ view()

__host__ __device__ ArrayView< Real > Arcane::Real2::view ( )
inlineconstexpr

Returns a view of the two elements of the vector.

Definition at line 209 of file Real2.h.

References Arcane::Real2POD::x.

◆ operator* [1/2]

__host__ __device__ Real2 operator* ( Real sca,
Real2 vec )
friend

Multiplication by a scalar.

Definition at line 347 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator* [2/2]

__host__ __device__ Real2 operator* ( Real2 vec,
Real sca )
friend

Multiplication by a scalar.

Definition at line 353 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator/

__host__ __device__ Real2 operator/ ( Real2 vec,
Real sca )
friend

Division by a scalar.

Definition at line 359 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator<

__host__ __device__ bool operator< ( Real2 v1,
Real2 v2 )
friend

Comparison operator.

This operator allows Real2 objects to be sorted for use, for example, in std::set

Definition at line 370 of file Real2.h.

References Real2(), Arcane::Real2POD::x, and Arcane::Real2POD::y.

◆ operator<<

std::ostream & operator<< ( std::ostream & o,
Real2 t )
friend

Writes the pair t to the stream o.

Definition at line 379 of file Real2.h.

References printXy(), and Real2().

◆ operator>>

std::istream & operator>> ( std::istream & i,
Real2 & t )
friend

Reads the pair t from the stream o.

Definition at line 385 of file Real2.h.

References assign(), and Real2().


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