Sequoia
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
sequoia::maths::coordinates_base< ConvexSpace, Basis, Origin, Validator, DisplacementCoordinates > Class Template Reference

Class designed for inheritance by concerete coordinate types. More...

#include <Spaces.hpp>

Inheritance diagram for sequoia::maths::coordinates_base< ConvexSpace, Basis, Origin, Validator, DisplacementCoordinates >:
sequoia::maths::coordinates< ConvexSpace, Basis, Origin, Validator > sequoia::physics::physical_value< ValueSpace, Unit, Convention, Origin, Validator >

Public Types

using convex_space_type = ConvexSpace
 
using basis_type = Basis
 
using validator_type = Validator
 
using origin_type = Origin
 
using set_type = ConvexSpace::set_type
 
using free_module_type = free_module_type_of_t< ConvexSpace >
 
using commutative_ring_type = commutative_ring_type_of_t< ConvexSpace >
 
using value_type = commutative_ring_type
 
using displacement_coordinates_type = DisplacementCoordinates
 

Public Member Functions

constexpr coordinates_base (std::span< const value_type, D > vals) noexcept(has_identity_validator)
 
template<class... Ts>
requires (D > 1) && (sizeof...(Ts) == D) && (std::convertible_to<Ts, value_type> && ...)
constexpr coordinates_base (Ts... ts) noexcept(has_identity_validator)
 
template<class T >
requires (D == 1) && (std::convertible_to<T, value_type>)
constexpr coordinates_base (T val) noexcept(has_identity_validator)
 
template<class Self >
constexpr Self & operator+= (this Self &self, const displacement_coordinates_type &v) noexcept(has_identity_validator)
 
template<class Self >
requires has_distinguished_origin
&&!std ::is_same_v< coordinates_base, displacement_coordinates_type > constexpr Self & operator+= (this Self &self, const coordinates_base &v) noexcept(has_identity_validator)
 
template<class Self >
constexpr Self & operator-= (this Self &self, const displacement_coordinates_type &v) noexcept(has_identity_validator)
 
template<class Self >
requires has_distinguished_origin
constexpr Self & operator*= (this Self &self, value_type u) noexcept(has_identity_validator)
 
template<class Self >
requires has_distinguished_origin
constexpr Self & operator/= (this Self &self, value_type u)
 
constexpr const validator_type & validator () const noexcept
 
constexpr std::span< const value_type, D > values () const noexcept
 
constexpr std::span< value_type, D > values () noexcept
 
constexpr const value_type & value () const noexcept
 
constexpr value_type & value () noexcept
 
constexpr operator bool () const noexcept
 This is explicit since otherwise, given two vectors a,b, a/b is well-formed due to implicit boolean conversion.
 
constexpr value_type operator[] (std::size_t i) const
 
constexpr value_type & operator[] (std::size_t i)
 

Static Public Attributes

static constexpr bool has_distinguished_origin {std::is_same_v<Origin, distinguished_origin>}
 
static constexpr bool has_identity_validator {is_identity_validator_v<Validator>}
 
static constexpr std::size_t dimension {free_module_type::dimension}
 
static constexpr std::size_t D {dimension}
 

Protected Member Functions

 coordinates_base (const coordinates_base &)=default
 
 coordinates_base (coordinates_base &&) noexcept=default
 
coordinates_baseoperator= (const coordinates_base &)=default
 
coordinates_baseoperator= (coordinates_base &&) noexcept=default
 
template<class Self , class Fn >
requires std::invocable<Fn, value_type&, value_type>
constexpr void apply_to_each_element (this Self &self, std::span< const value_type, D > rhs, Fn f)
 
template<class Self , class Fn >
requires std::invocable<Fn, value_type&>
constexpr void for_each_element (this Self &self, Fn f)
 

Friends

template<class Derived >
requires std::is_base_of_v<coordinates_base, Derived>
constexpr Derived operator+ (Derived c, const displacement_coordinates_type &v) noexcept(has_identity_validator)
 
template<class Derived >
requires std::is_base_of_v<coordinates_base, Derived> && (!std::is_same_v<Derived, displacement_coordinates_type>)
constexpr Derived operator+ (const displacement_coordinates_type &v, Derived c) noexcept(has_identity_validator)
 
template<class Derived >
requires has_distinguished_origin
constexpr Derived operator+ (Derived c, const Derived &v) noexcept(has_identity_validator)
 
template<class Derived >
requires std::is_base_of_v<coordinates_base, Derived>
constexpr Derived operator- (Derived c, const displacement_coordinates_type &v) noexcept(has_identity_validator)
 
template<class Derived >
requires has_distinguished_origin
constexpr Derived operator* (Derived v, value_type u) noexcept(has_identity_validator)
 
template<class Derived >
requires has_distinguished_origin
constexpr Derived operator* (value_type u, Derived v) noexcept(has_identity_validator)
 
template<class Derived >
requires has_distinguished_origin
constexpr Derived operator/ (Derived v, value_type u)
 
constexpr bool operator== (const coordinates_base &lhs, const coordinates_base &rhs) noexcept
 
constexpr auto operator<=> (const coordinates_base &lhs, const coordinates_base &rhs) noexcept
 

Detailed Description

template<convex_space ConvexSpace, basis_for< free_module_type_of_t< ConvexSpace > > Basis, class Origin, validator_for< ConvexSpace > Validator, class DisplacementCoordinates = free_module_coordinates<free_module_type_of_t<ConvexSpace>, Basis>>
class sequoia::maths::coordinates_base< ConvexSpace, Basis, Origin, Validator, DisplacementCoordinates >

Class designed for inheritance by concerete coordinate types.

The type has protected special member functions (including the destructor) and uses deducing-this patterns as a type-rich alternative to virtual dispatch.

From the perspective of the enclosing namespace, maths, there is actually no need for a base class. Indeed, there is a single coordinates class template which derives from coordinates_base, begging the question as to why a base class is necessary at all. The reason is that there are applications in physics which have enough in common with maths::coordinates, but are sufficiently distinct, for a base class to be extremely useful in terms of reducing what would otherwise be very significant code duplication.

One of the novelties in the context of physics is the notion of units and quantities of different types that can nevertheless by multipled and in some cases (like widths and heights) added.

Noteable omissions from the base class are unary+ and unary- as well as subtraction of two coordinates. Since these turn out to require a different implementation for physical quantities, insofar as maths is concerned they are defined only in the derived coordinates class template.


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