PTEMS  0.1.0-dev+git.81fd0e4
PolyTopic Element Method Solver
ptems::BasicVector< T, 1 > Struct Template Reference

Vector representing a point in one-dimensional space. More...

#include <ptems/vector.hpp>

Public Types

using ConjugateType = BasicVector< typename std::conditional_t< is_complex_v< T >, T, std::complex< T > >, 1 >
 The type of the conjugate of the vector. More...
 

Public Member Functions

constexpr BasicVector ()
 Construct a zero vector. More...
 
constexpr BasicVector (T x)
 Construct a vector for the specified point. More...
 
template<typename U >
constexpr BasicVector (const BasicVector< U, 1 > rhs)
 Construct a vector by copying the specified vector. More...
 
template<typename U >
constexpr BasicVectoroperator= (const BasicVector< U, 1 > rhs)
 Copy the specified vector to this. More...
 
constexpr BasicVectoroperator= (T rhs)
 Set all components tof vector equal to a constants. More...
 
constexpr BasicVectoroperator+= (T rhs)
 Adds a constant to every component to this vector. More...
 
constexpr BasicVectoroperator-= (T rhs)
 Subtracts constant from every component to this vector. More...
 
template<typename U >
constexpr BasicVectoroperator+= (const BasicVector< U, 1 > &rhs)
 Adds another 1D vector to this vector. More...
 
template<typename U >
constexpr BasicVectoroperator-= (const BasicVector< U, 1 > &rhs)
 Subtracts another 1D vector to this vector. More...
 
template<typename U >
constexpr BasicVectoroperator/= (U rhs)
 Divides all components of this vector by a constant. More...
 
template<typename U >
constexpr BasicVectoroperator/= (const BasicVector< U, 1 > &rhs)
 Performs elementwise division of all components of this vector by the other vector. More...
 
template<typename U >
constexpr BasicVectoroperator*= (U rhs)
 Multiplies all components of this vector by a constant. More...
 
template<typename U >
constexpr BasicVectoroperator*= (const BasicVector< U, 1 > &rhs)
 Performs elementwise multiplication of all components of this vector by the other vector. More...
 
constexpr BasicVector operator- () const
 Returns the negated vector. More...
 
template<typename U >
constexpr std::common_type_t< T, U > Dot (const BasicVector< U, 1 > &rhs) const
 Computes the dot product of this vector with the specified vector. More...
 
constexpr remove_complex_t< T > Length () const
 Computes the length of the vector. More...
 
constexpr T operator[] (std::size_t i) const
 Gets a component of the vector by index. More...
 
constexpr T & operator[] (std::size_t i)
 Gets a mutable reference to the component of the vector by index. More...
 
constexpr remove_complex_t< T > LengthSquared () const
 Gets the square of the length of the vector. More...
 
constexpr BasicVectorNormalise ()
 Normalises the current vector. More...
 
constexpr BasicVector Normalised () const
 Gets a new vector which is the normalised version of this vector. More...
 
ConjugateType Conjugate () const
 Computes the complex conjugate of the vector. More...
 
BasicVectorConjugateOverwrite () const
 Overwrites the vector with its complex conjugate. More...
 
constexpr operator T () const
 Implicit conversion to underlying type. More...
 
std::size_t size () const
 Gets the number of elements in the vector. More...
 

Public Attributes

X
 The x-component of the vector. More...
 

Detailed Description

template<typename T>
struct ptems::BasicVector< T, 1 >

Vector representing a point in one-dimensional space.

Can be implicitly converted to/from the underlying type.

Template Parameters
TThe type of the vector component

Member Typedef Documentation

◆ ConjugateType

template<typename T >
using ptems::BasicVector< T, 1 >::ConjugateType = BasicVector<typename std::conditional_t<is_complex_v<T>, T, std::complex<T> >,1>

The type of the conjugate of the vector.

Will either be the same type if T is complex, otherwise a vector of std::complex<T>.

Constructor & Destructor Documentation

◆ BasicVector() [1/3]

template<typename T >
constexpr ptems::BasicVector< T, 1 >::BasicVector ( )
inlineconstexpr

Construct a zero vector.

◆ BasicVector() [2/3]

template<typename T >
constexpr ptems::BasicVector< T, 1 >::BasicVector ( x)
inlineexplicitconstexpr

Construct a vector for the specified point.

Parameters
xThe x-component of the vector

◆ BasicVector() [3/3]

template<typename T >
template<typename U >
constexpr ptems::BasicVector< T, 1 >::BasicVector ( const BasicVector< U, 1 >  rhs)
inlineconstexpr

Construct a vector by copying the specified vector.

Template Parameters
UType of the vector to copy
Parameters
rhsVector to copy

Member Function Documentation

◆ Conjugate()

template<typename T >
ConjugateType ptems::BasicVector< T, 1 >::Conjugate ( ) const
inline

Computes the complex conjugate of the vector.

Returns
The complex conjugate of the vector

◆ ConjugateOverwrite()

template<typename T >
BasicVector& ptems::BasicVector< T, 1 >::ConjugateOverwrite ( ) const
inline

Overwrites the vector with its complex conjugate.

Returns
this

◆ Dot()

template<typename T >
template<typename U >
constexpr std::common_type_t<T,U> ptems::BasicVector< T, 1 >::Dot ( const BasicVector< U, 1 > &  rhs) const
inlineconstexpr

Computes the dot product of this vector with the specified vector.

Template Parameters
UType of the components of the vector to dot product with
Parameters
rhsVector to dot product with this vector
Returns
The result of the dot product

◆ Length()

template<typename T >
constexpr remove_complex_t<T> ptems::BasicVector< T, 1 >::Length ( ) const
inlineconstexpr

Computes the length of the vector.

Returns
The vector length.

◆ LengthSquared()

template<typename T >
constexpr remove_complex_t<T> ptems::BasicVector< T, 1 >::LengthSquared ( ) const
inlineconstexpr

Gets the square of the length of the vector.

Returns
The length squared.

◆ Normalise()

template<typename T >
constexpr BasicVector& ptems::BasicVector< T, 1 >::Normalise ( )
inlineconstexpr

Normalises the current vector.

Returns
Reference to this vector after normalisation.

◆ Normalised()

template<typename T >
constexpr BasicVector ptems::BasicVector< T, 1 >::Normalised ( ) const
inlineconstexpr

Gets a new vector which is the normalised version of this vector.

Returns
The normalised vector

◆ operator T()

template<typename T >
constexpr ptems::BasicVector< T, 1 >::operator T ( ) const
inlineconstexpr

Implicit conversion to underlying type.

Returns
The x-component of the vector

◆ operator*=() [1/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 1 >::operator*= ( const BasicVector< U, 1 > &  rhs)
inlineconstexpr

Performs elementwise multiplication of all components of this vector by the other vector.

Template Parameters
UType of the components of the vector to multiply by
Parameters
rhsVector to multiply by elementwise
Returns
Reference to this vector after multiplying by rhs

◆ operator*=() [2/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 1 >::operator*= ( rhs)
inlineconstexpr

Multiplies all components of this vector by a constant.

Template Parameters
UType of right hand side
Parameters
rhsConstant to multiple vector by
Returns
Reference to this vector after multiplying by rhs

◆ operator+=() [1/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 1 >::operator+= ( const BasicVector< U, 1 > &  rhs)
inlineconstexpr

Adds another 1D vector to this vector.

Template Parameters
UType of the components of the vector to add
Parameters
rhsVector to add
Returns
Reference to this vector after adding rhs

◆ operator+=() [2/2]

template<typename T >
constexpr BasicVector& ptems::BasicVector< T, 1 >::operator+= ( rhs)
inlineconstexpr

Adds a constant to every component to this vector.

Parameters
rhsVector to add
Returns
Reference to this vector after adding rhs

◆ operator-()

template<typename T >
constexpr BasicVector ptems::BasicVector< T, 1 >::operator- ( ) const
inlineconstexpr

Returns the negated vector.

Parameters
rhsVector to negate
Returns
The negated vector

◆ operator-=() [1/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 1 >::operator-= ( const BasicVector< U, 1 > &  rhs)
inlineconstexpr

Subtracts another 1D vector to this vector.

Template Parameters
UType of the components of the vector to subtract
Parameters
rhsVector to subtract
Returns
Reference to this vector after subtracting rhs

◆ operator-=() [2/2]

template<typename T >
constexpr BasicVector& ptems::BasicVector< T, 1 >::operator-= ( rhs)
inlineconstexpr

Subtracts constant from every component to this vector.

Parameters
rhsVector to subtract
Returns
Reference to this vector after subtracting rhs

◆ operator/=() [1/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 1 >::operator/= ( const BasicVector< U, 1 > &  rhs)
inlineconstexpr

Performs elementwise division of all components of this vector by the other vector.

Template Parameters
UType of the components of the vector to divide by
Parameters
rhsVector to divide by elementwise
Returns
Reference to this vector after dividing by rhs

◆ operator/=() [2/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 1 >::operator/= ( rhs)
inlineconstexpr

Divides all components of this vector by a constant.

Template Parameters
UType of right hand side
Parameters
rhsConstant to divide vector by
Returns
Reference to this vector after dividing by rhs

◆ operator=() [1/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 1 >::operator= ( const BasicVector< U, 1 >  rhs)
inlineconstexpr

Copy the specified vector to this.

Template Parameters
UType of the vector to copy
Parameters
rhsVector to copy

◆ operator=() [2/2]

template<typename T >
constexpr BasicVector& ptems::BasicVector< T, 1 >::operator= ( rhs)
inlineconstexpr

Set all components tof vector equal to a constants.

Parameters
rhsScalar to set vector to

◆ operator[]() [1/2]

template<typename T >
constexpr T& ptems::BasicVector< T, 1 >::operator[] ( std::size_t  i)
inlineconstexpr

Gets a mutable reference to the component of the vector by index.

Parameters
iThe index of the component of the vector to get (must be 0).
Exceptions
std::out_of_rangeIf i is not 0.
Returns
Mutable reference to the value at the specified component

◆ operator[]() [2/2]

template<typename T >
constexpr T ptems::BasicVector< T, 1 >::operator[] ( std::size_t  i) const
inlineconstexpr

Gets a component of the vector by index.

Parameters
iThe index of the component of the vector to get (must be 0).
Exceptions
std::out_of_rangeIf i is not 0.
Returns
Value at the specified component

◆ size()

template<typename T >
std::size_t ptems::BasicVector< T, 1 >::size ( ) const
inline

Gets the number of elements in the vector.

Returns
1

Member Data Documentation

◆ X

template<typename T >
T ptems::BasicVector< T, 1 >::X

The x-component of the vector.


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