SOFA API  fdacdac3
Open source framework for multi-physics simuation
sofa::type::Vec< N, ValueType > Class Template Reference

#include <Vec.h>

Inheritance diagram for sofa::type::Vec< N, ValueType >:

Public Attributes

ArrayType elems {}
 

Static Public Attributes

static constexpr sofa::Size static_size = N
 
static constexpr Size total_size = N
 Compile-time constant specifying the number of scalars within this vector (equivalent to static_size and size() method) More...
 
static constexpr Size spatial_dimensions = N
 Compile-time constant specifying the number of dimensions of space (equivalent to total_size here) More...
 

Public Member Functions

constexpr Vec ()=default
 Default constructor: sets all values to 0. More...
 
constexpr Vec (NoInit)
 Fast constructor: no initialization. More...
 
template<Size NN = N, typename std::enable_if< NN==1, int >::type = 0>
constexpr Vec (const ValueType r1) noexcept
 Specific constructor for 1-element vectors. More...
 
template<typename... ArgsT, typename = std::enable_if_t< (std::is_convertible_v<ArgsT, ValueType> && ...) >, typename = std::enable_if_t< (sizeof...(ArgsT) == N && sizeof...(ArgsT) > 1) >>
constexpr Vec (ArgsT &&... r) noexcept
 
template<typename R , typename T , Size NN = N, typename std::enable_if< NN==6, int >::type = 0>
 Vec (const Vec< 3, R > &a, const Vec< 3, T > &b)
 Specific constructor for 6-elements vectors, taking two 3-elements vectors. More...
 
template<Size NN = N, typename std::enable_if< NN==1, int >::type = 0>
constexpr void set (const ValueType r1) noexcept
 Specific set function for 1-element vectors. More...
 
template<typename... ArgsT, typename = std::enable_if_t< (std::is_convertible_v<ArgsT, ValueType> && ...) >, typename = std::enable_if_t< (sizeof...(ArgsT) == N && sizeof...(ArgsT) > 1) >>
constexpr void set (const ArgsT... r) noexcept
 
template<Size N2, class real2 >
constexpr void set (const Vec< N2, real2 > &v, ValueType defaultvalue=0) noexcept
 Specific set from a different size vector (given default value and ignored outside entries) More...
 
template<Size NN = N, typename std::enable_if<(NN >1), int >::type = 0>
constexpr Vec (const Vec< N-1, ValueType > &v, ValueType r1) noexcept
 Constructor from an N-1 elements vector and an additional value (added at the end). More...
 
constexpr Vec (const sofa::type::fixed_array< ValueType, N > &p) noexcept
 
template<Size N2, typename real2 >
constexpr Vec (const Vec< N2, real2 > &v) noexcept
 Constructor from a different size vector (null default value and ignoring outside entries) More...
 
template<typename real2 >
constexpr Vec (const Vec< N, real2 > &p) noexcept
 
template<typename real2 >
constexpr Vec (const real2 *p) noexcept
 Constructor from an array of values. More...
 
template<Size NN = N, typename std::enable_if<(NN >=1), int >::type = 0>
constexpr ValueType & x () noexcept
 Special access to first element. More...
 
template<Size NN = N, typename std::enable_if<(NN >=2), int >::type = 0>
constexpr ValueType & y () noexcept
 Special access to second element. More...
 
template<Size NN = N, typename std::enable_if<(NN >=3), int >::type = 0>
constexpr ValueType & z () noexcept
 Special access to third element. More...
 
template<Size NN = N, typename std::enable_if<(NN >=4), int >::type = 0>
constexpr ValueType & w () noexcept
 Special access to fourth element. More...
 
template<Size NN = N, typename std::enable_if<(NN >=1), int >::type = 0>
constexpr const ValueType & x () const noexcept
 Special const access to first element. More...
 
template<Size NN = N, typename std::enable_if<(NN >=2), int >::type = 0>
constexpr const ValueType & y () const noexcept
 Special const access to second element. More...
 
template<Size NN = N, typename std::enable_if<(NN >=3), int >::type = 0>
constexpr const ValueType & z () const noexcept
 Special const access to third element. More...
 
template<Size NN = N, typename std::enable_if<(NN >=4), int >::type = 0>
constexpr const ValueType & w () const noexcept
 Special const access to fourth element. More...
 
template<Size NN = N, typename std::enable_if< NN==1, int >::type = 0>
constexpr void operator= (const ValueType r1) noexcept
 Specific Assignment operator for 1-element vectors. More...
 
template<typename real2 >
constexpr void operator= (const real2 *p) noexcept
 Assignment operator from an array of values. More...
 
template<Size M, typename real2 >
constexpr void operator= (const Vec< M, real2 > &v) noexcept
 Assignment from a vector with different dimensions. More...
 
constexpr void assign (const ValueType &value) noexcept
 
constexpr void clear () noexcept
 Sets every element to 0. More...
 
constexpr void fill (ValueType r) noexcept
 Sets every element to r. More...
 
constexpr ValueType & operator() (Size i) noexcept
 Access to i-th element. More...
 
constexpr const ValueType & operator() (Size i) const noexcept
 Const access to i-th element. More...
 
constexpr const ValueType * ptr () const noexcept
 Cast into a const array of values. More...
 
constexpr ValueType * ptr () noexcept
 Cast into an array of values. More...
 
template<Size N2, std::enable_if_t<(N2< N), bool > = true>
constexpr void getsub (const Size i, Vec< N2, ValueType > &m) const noexcept
 
constexpr void getsub (const Size i, ValueType &m) const noexcept
 
constexpr Vec< N, ValueType > mulscalar (const ValueType f) const noexcept
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec< N, ValueType > mulscalar (const real2 f) const noexcept
 Multiplication by a scalar f. More...
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec< N, ValueType > operator* (const real2 f) const noexcept
 
constexpr void eqmulscalar (const ValueType f) noexcept
 In-place multiplication by a scalar f. More...
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void eqmulscalar (const real2 f) noexcept
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void operator*= (const real2 f) noexcept
 
constexpr Vec< N, ValueType > divscalar (const ValueType f) const noexcept
 Division by a scalar f. More...
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec< N, ValueType > divscalar (const real2 f) const noexcept
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec< N, ValueType > operator/ (const real2 f) const noexcept
 
constexpr void eqdivscalar (const ValueType f) noexcept
 In-place division by a scalar f. More...
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void eqdivscalar (const real2 f) noexcept
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void operator/= (const real2 f) noexcept
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr ValueType operator* (const Vec< N, real2 > &v) const noexcept
 Dot product. More...
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec< N, ValueType > linearProduct (const Vec< N, real2 > &v) const noexcept
 linear product. More...
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec< N, ValueType > linearDivision (const Vec< N, real2 > &v) const noexcept
 linear division. More...
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec< N, ValueType > operator+ (const Vec< N, real2 > &v) const noexcept
 Vector addition. More...
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void operator+= (const Vec< N, real2 > &v) noexcept
 In-place vector addition. More...
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec< N, ValueType > operator- (const Vec< N, real2 > &v) const noexcept
 Vector subtraction. More...
 
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void operator-= (const Vec< N, real2 > &v) noexcept
 In-place vector subtraction. More...
 
template<typename T = ValueType, std::enable_if_t< !std::is_unsigned_v< T >, int > = 0>
constexpr Vec< N, ValueType > operator- () const noexcept
 Vector negation. More...
 
constexpr ValueType norm2 () const noexcept
 Squared norm. More...
 
ValueType norm () const noexcept
 Euclidean norm. More...
 
ValueType lNorm (int l) const
 
constexpr bool normalizeWithNorm (ValueType norm, ValueType threshold=std::numeric_limits< ValueType >::epsilon()) noexcept
 
bool normalize (ValueType threshold=std::numeric_limits< ValueType >::epsilon()) noexcept
 
void normalize (Vec< N, ValueType > failsafe, ValueType threshold=std::numeric_limits< ValueType >::epsilon()) noexcept
 
Vec< N, ValueType > normalized () const noexcept
 
bool isNormalized (ValueType threshold=std::numeric_limits< ValueType >::epsilon() *(ValueType) 10) const
 return true if norm()==1 More...
 
template<typename R , Size NN = N, typename std::enable_if<(NN==3), int >::type = 0>
constexpr Vec cross (const Vec< 3, R > &b) const noexcept
 
constexpr ValueType sum () const noexcept
 sum of all elements of the vector More...
 
Tests operators
constexpr bool operator== (const Vec &b) const noexcept
 
constexpr bool operator!= (const Vec &b) const noexcept
 
constexpr reference operator[] (size_type i)
 
constexpr const_reference operator[] (size_type i) const
 
constexpr const ValueType * data () const noexcept
 
constexpr iterator begin () noexcept
 
constexpr const_iterator begin () const noexcept
 
constexpr iterator end () noexcept
 
constexpr const_iterator end () const noexcept
 
constexpr reference front ()
 
constexpr const_reference front () const
 
constexpr reference back ()
 
constexpr const_reference back () const
 

Static Public Member Functions

static constexpr sofa::Size size ()
 

Attribute details

◆ elems

template<sofa::Size N, typename ValueType >
ArrayType sofa::type::Vec< N, ValueType >::elems {}

◆ spatial_dimensions

template<sofa::Size N, typename ValueType >
constexpr Size sofa::type::Vec< N, ValueType >::spatial_dimensions = N
staticconstexpr

Compile-time constant specifying the number of dimensions of space (equivalent to total_size here)

◆ static_size

template<sofa::Size N, typename ValueType >
constexpr sofa::Size sofa::type::Vec< N, ValueType >::static_size = N
staticconstexpr

◆ total_size

template<sofa::Size N, typename ValueType >
constexpr Size sofa::type::Vec< N, ValueType >::total_size = N
staticconstexpr

Compile-time constant specifying the number of scalars within this vector (equivalent to static_size and size() method)

Constructor details

◆ Vec() [1/10]

template<sofa::Size N, typename ValueType >
constexpr sofa::type::Vec< N, ValueType >::Vec ( )
constexprdefault

Default constructor: sets all values to 0.

◆ Vec() [2/10]

template<sofa::Size N, typename ValueType >
constexpr sofa::type::Vec< N, ValueType >::Vec ( NoInit  )
inlineexplicitconstexpr

Fast constructor: no initialization.

◆ Vec() [3/10]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if< NN==1, int >::type = 0>
constexpr sofa::type::Vec< N, ValueType >::Vec ( const ValueType  r1)
inlineexplicitconstexprnoexcept

Specific constructor for 1-element vectors.

◆ Vec() [4/10]

template<sofa::Size N, typename ValueType >
template<typename... ArgsT, typename = std::enable_if_t< (std::is_convertible_v<ArgsT, ValueType> && ...) >, typename = std::enable_if_t< (sizeof...(ArgsT) == N && sizeof...(ArgsT) > 1) >>
constexpr sofa::type::Vec< N, ValueType >::Vec ( ArgsT &&...  r)
inlineconstexprnoexcept

◆ Vec() [5/10]

template<sofa::Size N, typename ValueType >
template<typename R , typename T , Size NN = N, typename std::enable_if< NN==6, int >::type = 0>
sofa::type::Vec< N, ValueType >::Vec ( const Vec< 3, R > &  a,
const Vec< 3, T > &  b 
)
inline

Specific constructor for 6-elements vectors, taking two 3-elements vectors.

◆ Vec() [6/10]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if<(NN >1), int >::type = 0>
constexpr sofa::type::Vec< N, ValueType >::Vec ( const Vec< N-1, ValueType > &  v,
ValueType  r1 
)
inlineconstexprnoexcept

Constructor from an N-1 elements vector and an additional value (added at the end).

◆ Vec() [7/10]

template<sofa::Size N, typename ValueType >
constexpr sofa::type::Vec< N, ValueType >::Vec ( const sofa::type::fixed_array< ValueType, N > &  p)
inlineconstexprnoexcept

◆ Vec() [8/10]

template<sofa::Size N, typename ValueType >
template<Size N2, typename real2 >
constexpr sofa::type::Vec< N, ValueType >::Vec ( const Vec< N2, real2 > &  v)
inlineexplicitconstexprnoexcept

Constructor from a different size vector (null default value and ignoring outside entries)

◆ Vec() [9/10]

template<sofa::Size N, typename ValueType >
template<typename real2 >
constexpr sofa::type::Vec< N, ValueType >::Vec ( const Vec< N, real2 > &  p)
inlineconstexprnoexcept

◆ Vec() [10/10]

template<sofa::Size N, typename ValueType >
template<typename real2 >
constexpr sofa::type::Vec< N, ValueType >::Vec ( const real2 *  p)
inlineexplicitconstexprnoexcept

Constructor from an array of values.

Function details

◆ assign()

template<sofa::Size N, typename ValueType >
constexpr void sofa::type::Vec< N, ValueType >::assign ( const ValueType &  value)
inlineconstexprnoexcept

◆ back() [1/2]

template<sofa::Size N, typename ValueType >
constexpr reference sofa::type::Vec< N, ValueType >::back ( )
inlineconstexpr

◆ back() [2/2]

template<sofa::Size N, typename ValueType >
constexpr const_reference sofa::type::Vec< N, ValueType >::back ( ) const
inlineconstexpr

◆ begin() [1/2]

template<sofa::Size N, typename ValueType >
constexpr const_iterator sofa::type::Vec< N, ValueType >::begin ( ) const
inlineconstexprnoexcept

◆ begin() [2/2]

template<sofa::Size N, typename ValueType >
constexpr iterator sofa::type::Vec< N, ValueType >::begin ( )
inlineconstexprnoexcept

◆ clear()

template<sofa::Size N, typename ValueType >
constexpr void sofa::type::Vec< N, ValueType >::clear ( )
inlineconstexprnoexcept

Sets every element to 0.

◆ cross()

template<sofa::Size N, typename ValueType >
template<typename R , Size NN = N, typename std::enable_if<(NN==3), int >::type = 0>
constexpr Vec sofa::type::Vec< N, ValueType >::cross ( const Vec< 3, R > &  b) const
inlineconstexprnoexcept

◆ data()

template<sofa::Size N, typename ValueType >
constexpr const ValueType* sofa::type::Vec< N, ValueType >::data ( ) const
inlineconstexprnoexcept

◆ divscalar() [1/2]

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec<N,ValueType> sofa::type::Vec< N, ValueType >::divscalar ( const real2  f) const
inlineconstexprnoexcept

◆ divscalar() [2/2]

template<sofa::Size N, typename ValueType >
constexpr Vec<N,ValueType> sofa::type::Vec< N, ValueType >::divscalar ( const ValueType  f) const
inlineconstexprnoexcept

Division by a scalar f.

◆ end() [1/2]

template<sofa::Size N, typename ValueType >
constexpr const_iterator sofa::type::Vec< N, ValueType >::end ( ) const
inlineconstexprnoexcept

◆ end() [2/2]

template<sofa::Size N, typename ValueType >
constexpr iterator sofa::type::Vec< N, ValueType >::end ( )
inlineconstexprnoexcept

◆ eqdivscalar() [1/2]

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void sofa::type::Vec< N, ValueType >::eqdivscalar ( const real2  f)
inlineconstexprnoexcept

◆ eqdivscalar() [2/2]

template<sofa::Size N, typename ValueType >
constexpr void sofa::type::Vec< N, ValueType >::eqdivscalar ( const ValueType  f)
inlineconstexprnoexcept

In-place division by a scalar f.

◆ eqmulscalar() [1/2]

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void sofa::type::Vec< N, ValueType >::eqmulscalar ( const real2  f)
inlineconstexprnoexcept

◆ eqmulscalar() [2/2]

template<sofa::Size N, typename ValueType >
constexpr void sofa::type::Vec< N, ValueType >::eqmulscalar ( const ValueType  f)
inlineconstexprnoexcept

In-place multiplication by a scalar f.

◆ fill()

template<sofa::Size N, typename ValueType >
constexpr void sofa::type::Vec< N, ValueType >::fill ( ValueType  r)
inlineconstexprnoexcept

Sets every element to r.

◆ front() [1/2]

template<sofa::Size N, typename ValueType >
constexpr reference sofa::type::Vec< N, ValueType >::front ( )
inlineconstexpr

◆ front() [2/2]

template<sofa::Size N, typename ValueType >
constexpr const_reference sofa::type::Vec< N, ValueType >::front ( ) const
inlineconstexpr

◆ getsub() [1/2]

template<sofa::Size N, typename ValueType >
constexpr void sofa::type::Vec< N, ValueType >::getsub ( const Size  i,
ValueType &  m 
) const
inlineconstexprnoexcept

◆ getsub() [2/2]

template<sofa::Size N, typename ValueType >
template<Size N2, std::enable_if_t<(N2< N), bool > = true>
constexpr void sofa::type::Vec< N, ValueType >::getsub ( const Size  i,
Vec< N2, ValueType > &  m 
) const
inlineconstexprnoexcept

◆ isNormalized()

template<sofa::Size N, typename ValueType >
bool sofa::type::Vec< N, ValueType >::isNormalized ( ValueType  threshold = std::numeric_limits<ValueType>::epsilon()*(ValueType)10) const
inline

return true if norm()==1

◆ linearDivision()

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec<N,ValueType> sofa::type::Vec< N, ValueType >::linearDivision ( const Vec< N, real2 > &  v) const
inlineconstexprnoexcept

linear division.

◆ linearProduct()

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec<N,ValueType> sofa::type::Vec< N, ValueType >::linearProduct ( const Vec< N, real2 > &  v) const
inlineconstexprnoexcept

linear product.

◆ lNorm()

template<sofa::Size N, typename ValueType >
ValueType sofa::type::Vec< N, ValueType >::lNorm ( int  l) const
inline

l-norm of the vector The type of norm is set by parameter l. Use l<0 for the infinite norm.

◆ mulscalar() [1/2]

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec<N,ValueType> sofa::type::Vec< N, ValueType >::mulscalar ( const real2  f) const
inlineconstexprnoexcept

Multiplication by a scalar f.

◆ mulscalar() [2/2]

template<sofa::Size N, typename ValueType >
constexpr Vec<N,ValueType> sofa::type::Vec< N, ValueType >::mulscalar ( const ValueType  f) const
inlineconstexprnoexcept

◆ norm()

template<sofa::Size N, typename ValueType >
ValueType sofa::type::Vec< N, ValueType >::norm ( ) const
inlinenoexcept

Euclidean norm.

◆ norm2()

template<sofa::Size N, typename ValueType >
constexpr ValueType sofa::type::Vec< N, ValueType >::norm2 ( ) const
inlineconstexprnoexcept

Squared norm.

◆ normalize() [1/2]

template<sofa::Size N, typename ValueType >
bool sofa::type::Vec< N, ValueType >::normalize ( ValueType  threshold = std::numeric_limits<ValueType>::epsilon())
inlinenoexcept

Normalize the vector. returns false iff the norm is too small

◆ normalize() [2/2]

template<sofa::Size N, typename ValueType >
void sofa::type::Vec< N, ValueType >::normalize ( Vec< N, ValueType >  failsafe,
ValueType  threshold = std::numeric_limits<ValueType>::epsilon() 
)
inlinenoexcept

Normalize the vector with a failsafe. If the norm is too small, the vector becomes the failsafe.

◆ normalized()

template<sofa::Size N, typename ValueType >
Vec<N,ValueType> sofa::type::Vec< N, ValueType >::normalized ( ) const
inlinenoexcept

Return the normalized vector.

Warning
'this' is not normalized.

◆ normalizeWithNorm()

template<sofa::Size N, typename ValueType >
constexpr bool sofa::type::Vec< N, ValueType >::normalizeWithNorm ( ValueType  norm,
ValueType  threshold = std::numeric_limits<ValueType>::epsilon() 
)
inlineconstexprnoexcept

Normalize the vector taking advantage of its already computed norm, equivalent to /=norm returns false iff the norm is too small

◆ operator!=()

template<sofa::Size N, typename ValueType >
constexpr bool sofa::type::Vec< N, ValueType >::operator!= ( const Vec< N, ValueType > &  b) const
inlineconstexprnoexcept

◆ operator()() [1/2]

template<sofa::Size N, typename ValueType >
constexpr const ValueType& sofa::type::Vec< N, ValueType >::operator() ( Size  i) const
inlineconstexprnoexcept

Const access to i-th element.

◆ operator()() [2/2]

template<sofa::Size N, typename ValueType >
constexpr ValueType& sofa::type::Vec< N, ValueType >::operator() ( Size  i)
inlineconstexprnoexcept

Access to i-th element.

◆ operator*() [1/2]

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec<N,ValueType> sofa::type::Vec< N, ValueType >::operator* ( const real2  f) const
inlineconstexprnoexcept

◆ operator*() [2/2]

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr ValueType sofa::type::Vec< N, ValueType >::operator* ( const Vec< N, real2 > &  v) const
inlineconstexprnoexcept

Dot product.

◆ operator*=()

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void sofa::type::Vec< N, ValueType >::operator*= ( const real2  f)
inlineconstexprnoexcept

◆ operator+()

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec<N,ValueType> sofa::type::Vec< N, ValueType >::operator+ ( const Vec< N, real2 > &  v) const
inlineconstexprnoexcept

Vector addition.

◆ operator+=()

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void sofa::type::Vec< N, ValueType >::operator+= ( const Vec< N, real2 > &  v)
inlineconstexprnoexcept

In-place vector addition.

◆ operator-() [1/2]

template<sofa::Size N, typename ValueType >
template<typename T = ValueType, std::enable_if_t< !std::is_unsigned_v< T >, int > = 0>
constexpr Vec<N, ValueType> sofa::type::Vec< N, ValueType >::operator- ( ) const
inlineconstexprnoexcept

Vector negation.

◆ operator-() [2/2]

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec<N,ValueType> sofa::type::Vec< N, ValueType >::operator- ( const Vec< N, real2 > &  v) const
inlineconstexprnoexcept

Vector subtraction.

◆ operator-=()

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void sofa::type::Vec< N, ValueType >::operator-= ( const Vec< N, real2 > &  v)
inlineconstexprnoexcept

In-place vector subtraction.

◆ operator/()

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr Vec<N, ValueType> sofa::type::Vec< N, ValueType >::operator/ ( const real2  f) const
inlineconstexprnoexcept

◆ operator/=()

template<sofa::Size N, typename ValueType >
template<class real2 , std::enable_if_t< std::is_convertible_v< real2, ValueType >, bool > = true>
constexpr void sofa::type::Vec< N, ValueType >::operator/= ( const real2  f)
inlineconstexprnoexcept

◆ operator=() [1/3]

template<sofa::Size N, typename ValueType >
template<typename real2 >
constexpr void sofa::type::Vec< N, ValueType >::operator= ( const real2 *  p)
inlineconstexprnoexcept

Assignment operator from an array of values.

◆ operator=() [2/3]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if< NN==1, int >::type = 0>
constexpr void sofa::type::Vec< N, ValueType >::operator= ( const ValueType  r1)
inlineconstexprnoexcept

Specific Assignment operator for 1-element vectors.

◆ operator=() [3/3]

template<sofa::Size N, typename ValueType >
template<Size M, typename real2 >
constexpr void sofa::type::Vec< N, ValueType >::operator= ( const Vec< M, real2 > &  v)
inlineconstexprnoexcept

Assignment from a vector with different dimensions.

◆ operator==()

template<sofa::Size N, typename ValueType >
constexpr bool sofa::type::Vec< N, ValueType >::operator== ( const Vec< N, ValueType > &  b) const
inlineconstexprnoexcept

◆ operator[]() [1/2]

template<sofa::Size N, typename ValueType >
constexpr reference sofa::type::Vec< N, ValueType >::operator[] ( size_type  i)
inlineconstexpr

◆ operator[]() [2/2]

template<sofa::Size N, typename ValueType >
constexpr const_reference sofa::type::Vec< N, ValueType >::operator[] ( size_type  i) const
inlineconstexpr

◆ ptr() [1/2]

template<sofa::Size N, typename ValueType >
constexpr const ValueType* sofa::type::Vec< N, ValueType >::ptr ( ) const
inlineconstexprnoexcept

Cast into a const array of values.

◆ ptr() [2/2]

template<sofa::Size N, typename ValueType >
constexpr ValueType* sofa::type::Vec< N, ValueType >::ptr ( )
inlineconstexprnoexcept

Cast into an array of values.

◆ set() [1/3]

template<sofa::Size N, typename ValueType >
template<typename... ArgsT, typename = std::enable_if_t< (std::is_convertible_v<ArgsT, ValueType> && ...) >, typename = std::enable_if_t< (sizeof...(ArgsT) == N && sizeof...(ArgsT) > 1) >>
constexpr void sofa::type::Vec< N, ValueType >::set ( const ArgsT...  r)
inlineconstexprnoexcept

◆ set() [2/3]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if< NN==1, int >::type = 0>
constexpr void sofa::type::Vec< N, ValueType >::set ( const ValueType  r1)
inlineconstexprnoexcept

Specific set function for 1-element vectors.

◆ set() [3/3]

template<sofa::Size N, typename ValueType >
template<Size N2, class real2 >
constexpr void sofa::type::Vec< N, ValueType >::set ( const Vec< N2, real2 > &  v,
ValueType  defaultvalue = 0 
)
inlineconstexprnoexcept

Specific set from a different size vector (given default value and ignored outside entries)

◆ size()

template<sofa::Size N, typename ValueType >
static constexpr sofa::Size sofa::type::Vec< N, ValueType >::size ( void  )
inlinestaticconstexpr

◆ sum()

template<sofa::Size N, typename ValueType >
constexpr ValueType sofa::type::Vec< N, ValueType >::sum ( ) const
inlineconstexprnoexcept

sum of all elements of the vector

◆ w() [1/2]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if<(NN >=4), int >::type = 0>
constexpr const ValueType& sofa::type::Vec< N, ValueType >::w ( ) const
inlineconstexprnoexcept

Special const access to fourth element.

◆ w() [2/2]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if<(NN >=4), int >::type = 0>
constexpr ValueType& sofa::type::Vec< N, ValueType >::w ( )
inlineconstexprnoexcept

Special access to fourth element.

◆ x() [1/2]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if<(NN >=1), int >::type = 0>
constexpr const ValueType& sofa::type::Vec< N, ValueType >::x ( ) const
inlineconstexprnoexcept

Special const access to first element.

◆ x() [2/2]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if<(NN >=1), int >::type = 0>
constexpr ValueType& sofa::type::Vec< N, ValueType >::x ( )
inlineconstexprnoexcept

Special access to first element.

◆ y() [1/2]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if<(NN >=2), int >::type = 0>
constexpr const ValueType& sofa::type::Vec< N, ValueType >::y ( ) const
inlineconstexprnoexcept

Special const access to second element.

◆ y() [2/2]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if<(NN >=2), int >::type = 0>
constexpr ValueType& sofa::type::Vec< N, ValueType >::y ( )
inlineconstexprnoexcept

Special access to second element.

◆ z() [1/2]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if<(NN >=3), int >::type = 0>
constexpr const ValueType& sofa::type::Vec< N, ValueType >::z ( ) const
inlineconstexprnoexcept

Special const access to third element.

◆ z() [2/2]

template<sofa::Size N, typename ValueType >
template<Size NN = N, typename std::enable_if<(NN >=3), int >::type = 0>
constexpr ValueType& sofa::type::Vec< N, ValueType >::z ( )
inlineconstexprnoexcept

Special access to third element.