Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | Friends | List of all members
Phyth::Vector< N, T > Struct Template Reference

#include <Vector.hpp>

Public Member Functions

constexpr Vector ()=default
 
template<typename... Args, std::enable_if_t< sizeof...(Args)==N &&std::conjunction_v< std::is_convertible< Args, T >... >, int > = 0>
constexpr Vector (Args... comps)
 
constexpr T & At (const size_t i)
 
constexpr const T & At (const size_t i) const
 
constexpr T & operator[] (const size_t i)
 
constexpr const T & operator[] (const size_t i) const
 
template<typename U >
constexpr auto operator+ (const Vector< N, U > &other) const
 
template<typename U >
constexpr auto operator- (const Vector< N, U > &other) const
 
constexpr auto operator- () const
 
template<typename U , typename = std::enable_if_t<!std::is_same_v<std::decay_t<U>, Vector>>>
constexpr auto operator* (U scalar) const
 
template<typename U >
constexpr auto operator/ (U scalar) const
 
template<typename U >
constexpr Vector & operator+= (const Vector< N, U > &other)
 
template<typename U >
constexpr Vector & operator-= (const Vector< N, U > &other)
 
template<typename U >
constexpr Vector & operator*= (U scalar)
 
template<typename U >
constexpr Vector & operator/= (U scalar)
 
constexpr bool operator== (const Vector &other) const
 
constexpr bool operator!= (const Vector &other) const
 
auto LengthSquared () const
 
auto Length () const
 
auto Normalized () const
 
template<typename U >
constexpr auto Dot (const Vector< N, U > &other) const
 
template<typename U >
auto Project (const Vector< N, U > &other) const
 
template<typename UnitT >
auto As () const
 

Public Attributes

std::array< T, N > datas
 

Private Member Functions

template<typename ResultScalar , typename U , std::size_t... I, typename F >
constexpr auto make_binary (const Vector< N, U > &other, std::index_sequence< I... >, F f) const
 
template<typename ResultScalar , std::size_t... I, typename F >
constexpr auto make_unary (std::index_sequence< I... >, F f) const
 
template<typename ResultScalar , typename U , std::size_t... I, typename F >
constexpr auto make_scalar (U scalar, std::index_sequence< I... >, F f) const
 
template<typename ResultScalar , typename UnitT , std::size_t... I>
constexpr auto make_as (std::index_sequence< I... >) const
 

Friends

std::ostream & operator<< (std::ostream &os, const Vector &v)
 

Detailed Description

template<std::size_t N, typename T>
struct Phyth::Vector< N, T >

Definition at line 16 of file Vector.hpp.

Constructor & Destructor Documentation

◆ Vector() [1/2]

template<std::size_t N, typename T >
constexpr Phyth::Vector< N, T >::Vector ( )
constexprdefault

◆ Vector() [2/2]

template<std::size_t N, typename T >
template<typename... Args, std::enable_if_t< sizeof...(Args)==N &&std::conjunction_v< std::is_convertible< Args, T >... >, int > = 0>
constexpr Phyth::Vector< N, T >::Vector ( Args...  comps)
inlineconstexpr

Definition at line 29 of file Vector.hpp.

Member Function Documentation

◆ As()

template<std::size_t N, typename T >
template<typename UnitT >
auto Phyth::Vector< N, T >::As ( ) const
inline

Definition at line 165 of file Vector.hpp.

◆ At() [1/2]

template<std::size_t N, typename T >
constexpr T & Phyth::Vector< N, T >::At ( const size_t  i)
inlineconstexpr

Definition at line 32 of file Vector.hpp.

◆ At() [2/2]

template<std::size_t N, typename T >
constexpr const T & Phyth::Vector< N, T >::At ( const size_t  i) const
inlineconstexpr

Definition at line 36 of file Vector.hpp.

◆ Dot()

template<std::size_t N, typename T >
template<typename U >
constexpr auto Phyth::Vector< N, T >::Dot ( const Vector< N, U > &  other) const
inlineconstexpr

Definition at line 151 of file Vector.hpp.

◆ Length()

template<std::size_t N, typename T >
auto Phyth::Vector< N, T >::Length ( ) const
inline

Definition at line 135 of file Vector.hpp.

◆ LengthSquared()

template<std::size_t N, typename T >
auto Phyth::Vector< N, T >::LengthSquared ( ) const
inline

Definition at line 127 of file Vector.hpp.

◆ make_as()

template<std::size_t N, typename T >
template<typename ResultScalar , typename UnitT , std::size_t... I>
constexpr auto Phyth::Vector< N, T >::make_as ( std::index_sequence< I... >  ) const
inlineconstexprprivate

Definition at line 199 of file Vector.hpp.

◆ make_binary()

template<std::size_t N, typename T >
template<typename ResultScalar , typename U , std::size_t... I, typename F >
constexpr auto Phyth::Vector< N, T >::make_binary ( const Vector< N, U > &  other,
std::index_sequence< I... >  ,
F  f 
) const
inlineconstexprprivate

Definition at line 182 of file Vector.hpp.

◆ make_scalar()

template<std::size_t N, typename T >
template<typename ResultScalar , typename U , std::size_t... I, typename F >
constexpr auto Phyth::Vector< N, T >::make_scalar ( U  scalar,
std::index_sequence< I... >  ,
F  f 
) const
inlineconstexprprivate

Definition at line 193 of file Vector.hpp.

◆ make_unary()

template<std::size_t N, typename T >
template<typename ResultScalar , std::size_t... I, typename F >
constexpr auto Phyth::Vector< N, T >::make_unary ( std::index_sequence< I... >  ,
F  f 
) const
inlineconstexprprivate

Definition at line 188 of file Vector.hpp.

◆ Normalized()

template<std::size_t N, typename T >
auto Phyth::Vector< N, T >::Normalized ( ) const
inline

Definition at line 139 of file Vector.hpp.

◆ operator!=()

template<std::size_t N, typename T >
constexpr bool Phyth::Vector< N, T >::operator!= ( const Vector< N, T > &  other) const
inlineconstexpr

Definition at line 123 of file Vector.hpp.

◆ operator*()

template<std::size_t N, typename T >
template<typename U , typename = std::enable_if_t<!std::is_same_v<std::decay_t<U>, Vector>>>
constexpr auto Phyth::Vector< N, T >::operator* ( U  scalar) const
inlineconstexpr

Definition at line 73 of file Vector.hpp.

◆ operator*=()

template<std::size_t N, typename T >
template<typename U >
constexpr Vector & Phyth::Vector< N, T >::operator*= ( U  scalar)
inlineconstexpr

Definition at line 103 of file Vector.hpp.

◆ operator+()

template<std::size_t N, typename T >
template<typename U >
constexpr auto Phyth::Vector< N, T >::operator+ ( const Vector< N, U > &  other) const
inlineconstexpr

Definition at line 49 of file Vector.hpp.

◆ operator+=()

template<std::size_t N, typename T >
template<typename U >
constexpr Vector & Phyth::Vector< N, T >::operator+= ( const Vector< N, U > &  other)
inlineconstexpr

Definition at line 89 of file Vector.hpp.

◆ operator-() [1/2]

template<std::size_t N, typename T >
constexpr auto Phyth::Vector< N, T >::operator- ( ) const
inlineconstexpr

Definition at line 64 of file Vector.hpp.

◆ operator-() [2/2]

template<std::size_t N, typename T >
template<typename U >
constexpr auto Phyth::Vector< N, T >::operator- ( const Vector< N, U > &  other) const
inlineconstexpr

Definition at line 57 of file Vector.hpp.

◆ operator-=()

template<std::size_t N, typename T >
template<typename U >
constexpr Vector & Phyth::Vector< N, T >::operator-= ( const Vector< N, U > &  other)
inlineconstexpr

Definition at line 96 of file Vector.hpp.

◆ operator/()

template<std::size_t N, typename T >
template<typename U >
constexpr auto Phyth::Vector< N, T >::operator/ ( U  scalar) const
inlineconstexpr

Definition at line 81 of file Vector.hpp.

◆ operator/=()

template<std::size_t N, typename T >
template<typename U >
constexpr Vector & Phyth::Vector< N, T >::operator/= ( U  scalar)
inlineconstexpr

Definition at line 110 of file Vector.hpp.

◆ operator==()

template<std::size_t N, typename T >
constexpr bool Phyth::Vector< N, T >::operator== ( const Vector< N, T > &  other) const
inlineconstexpr

Definition at line 116 of file Vector.hpp.

◆ operator[]() [1/2]

template<std::size_t N, typename T >
constexpr T & Phyth::Vector< N, T >::operator[] ( const size_t  i)
inlineconstexpr

Definition at line 40 of file Vector.hpp.

◆ operator[]() [2/2]

template<std::size_t N, typename T >
constexpr const T & Phyth::Vector< N, T >::operator[] ( const size_t  i) const
inlineconstexpr

Definition at line 44 of file Vector.hpp.

◆ Project()

template<std::size_t N, typename T >
template<typename U >
auto Phyth::Vector< N, T >::Project ( const Vector< N, U > &  other) const
inline

Definition at line 160 of file Vector.hpp.

Friends And Related Symbol Documentation

◆ operator<<

template<std::size_t N, typename T >
std::ostream & operator<< ( std::ostream &  os,
const Vector< N, T > &  v 
)
friend

Definition at line 170 of file Vector.hpp.

Member Data Documentation

◆ datas

template<std::size_t N, typename T >
std::array<T, N> Phyth::Vector< N, T >::datas

Definition at line 20 of file Vector.hpp.


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