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

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

#include <arccore/base/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 at line 121 of file arccore/src/base/arccore/base/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 134 of file arccore/src/base/arccore/base/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 143 of file arccore/src/base/arccore/base/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 151 of file arccore/src/base/arccore/base/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 487 of file arccore/src/base/arccore/base/Real3.h.

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

◆ Real2() [6/6]

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

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

Definition at line 161 of file arccore/src/base/arccore/base/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 105 of file MathReal2.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 421 of file arccore/src/base/arccore/base/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 222 of file arccore/src/base/arccore/base/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 240 of file arccore/src/base/arccore/base/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 272 of file arccore/src/base/arccore/base/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 194 of file arccore/src/base/arccore/base/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 202 of file arccore/src/base/arccore/base/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 27 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 216 of file arccore/src/base/arccore/base/Real2.h.

References Arcane::Real2POD::x.

◆ copy()

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

Returns a copy of the pair.

Definition at line 184 of file arccore/src/base/arccore/base/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 264 of file arccore/src/base/arccore/base/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 296 of file arccore/src/base/arccore/base/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 87 of file MathReal2.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 256 of file arccore/src/base/arccore/base/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 288 of file arccore/src/base/arccore/base/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 99 of file MathReal2.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 93 of file MathReal2.h.

◆ null()

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

Definition at line 179 of file arccore/src/base/arccore/base/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 411 of file arccore/src/base/arccore/base/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 342 of file arccore/src/base/arccore/base/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 313 of file arccore/src/base/arccore/base/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 310 of file arccore/src/base/arccore/base/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 330 of file arccore/src/base/arccore/base/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 304 of file arccore/src/base/arccore/base/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 336 of file arccore/src/base/arccore/base/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 333 of file arccore/src/base/arccore/base/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 307 of file arccore/src/base/arccore/base/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 348 of file arccore/src/base/arccore/base/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 323 of file arccore/src/base/arccore/base/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 320 of file arccore/src/base/arccore/base/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 171 of file arccore/src/base/arccore/base/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 400 of file arccore/src/base/arccore/base/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 37 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 47 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 187 of file arccore/src/base/arccore/base/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 417 of file arccore/src/base/arccore/base/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 248 of file arccore/src/base/arccore/base/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 280 of file arccore/src/base/arccore/base/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 210 of file arccore/src/base/arccore/base/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 351 of file arccore/src/base/arccore/base/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 357 of file arccore/src/base/arccore/base/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 363 of file arccore/src/base/arccore/base/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 374 of file arccore/src/base/arccore/base/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 383 of file arccore/src/base/arccore/base/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 389 of file arccore/src/base/arccore/base/Real2.h.

References assign(), and Real2().


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