Lodestar
An integrated real-time control package in C++
ls::primitives::sets::Singleton< TDimension, TScalarType > Class Template Reference

A singleton set. More...

#include <Singleton.hpp>

Inheritance diagram for ls::primitives::sets::Singleton< TDimension, TScalarType >:
[legend]
Collaboration diagram for ls::primitives::sets::Singleton< TDimension, TScalarType >:
[legend]

Public Types

using Base = SetExpression< Singleton< TDimension, TScalarType > >
 
using type = Singleton< TDimension, TScalarType >
 Base class.
 
typedef Eigen::Matrix< TScalarType, LS_STATIC_UNLESS_DYNAMIC(TDimension), 1 > TDValue
 Expression type.
 
- Public Types inherited from ls::primitives::sets::SetExpression< Singleton< -1, double > >
using type = Singleton< -1, double >
 

Public Member Functions

 Singleton ()
 Value typedef. More...
 
template<typename TDerived >
 Singleton (const Eigen::EigenBase< TDerived > &value)
 Constructs a Singleton instance from a vector. More...
 
template<int T_TDimension = TDimension>
int dimension (typename std::enable_if<(T_TDimension< 0)>::type *=nullptr) const
 Returns the singleton dimension. More...
 
template<int T_TDimension = TDimension>
int dimension (typename std::enable_if<(T_TDimension >=0)>::type *=nullptr) const
 Returns the singleton dimension. More...
 
template<int T_TDimension = TDimension>
void setDimension (size_t dim, typename std::enable_if<(T_TDimension< 0)>::type *=nullptr)
 Changes the dimension of the singleton. More...
 
template<int T_TDimension = TDimension>
void setDimension (size_t dim, typename std::enable_if<(T_TDimension >=0)>::type *=nullptr)
 Changes the dimension of the singleton. More...
 
template<typename TExpression >
std::enable_if< std::is_same< TExpression, type >::value, bool >::type contains (const SetExpression< TExpression > &expr, double tol=1e-6) const
 Returns true if this expression contains expr. More...
 
template<typename TExpression >
std::enable_if<!std::is_same< TExpression, type >::value, bool >::type contains (const SetExpression< TExpression > &expr, double tol=1e-6) const
 Returns true if this expression contains expr. More...
 
template<typename TExpression >
std::enable_if< std::is_same< TExpression, type >::value, bool >::type operator== (const SetExpression< TExpression > &expr) const
 Checks if this expression is equal to \expr. More...
 
template<typename TExpression >
std::enable_if<!std::is_same< TExpression, type >::value, bool >::type operator== (const SetExpression< TExpression > &expr) const
 Checks if this expression is equal to \expr. More...
 
template<typename TExpression >
std::enable_if< std::is_same< TExpression, type >::value, bool >::type operator!= (const SetExpression< TExpression > &expr) const
 Checks if this expression is not equal to \expr. More...
 
template<typename TExpression >
std::enable_if<!std::is_same< TExpression, type >::value, bool >::type operator!= (const SetExpression< TExpression > &expr) const
 Checks if this expression is not equal to \expr. More...
 
template<typename TExpression >
SetUnion< type, TExpression > unionize (const SetExpression< TExpression > &expr)
 Creates a union between this expression and another SetExpression. More...
 
template<typename TExpression >
bool isSubset (const SetExpression< TExpression > &expr)
 Checks if this expression is a subset of expr. More...
 
template<typename TExpression >
bool isSuperset (const SetExpression< TExpression > &expr)
 Checks if this expression is a superset of expr. More...
 
bool isEmpty () const
 Returns true if the expression is the empty set. More...
 
template<typename TExpression >
SetComplement< type, TExpression > relComplement (const SetExpression< TExpression > &expr)
 Computes the relative complement of this expression and expr. More...
 
template<typename TDerived >
double sdf (Eigen::MatrixBase< TDerived > &p) const
 Returns signed distance to p. More...
 
- Public Member Functions inherited from ls::primitives::sets::SetExpression< Singleton< -1, double > >
 SetExpression (const SetEnum setEnum)
 
bool operator== (const TElementType &el) const
 
bool operator!= (const TElementType &el) const
 
bool contains (const TElementType &el) const
 
bool isSubset (const TElementType &el) const
 
bool isSuperset (const TElementType &el) const
 
bool isEmpty () const
 
SetExpression< TReturnType > relComplement (const TElementType &el) const
 
SetExpression< TReturnType > unionize (const TOtherExpr &expr)
 
double sdf (Eigen::MatrixBase< Derived > &p) const
 
SetEnum getEnum () const
 

Protected Attributes

TDValue value_
 
- Protected Attributes inherited from ls::primitives::sets::SetExpression< Singleton< -1, double > >
SetEnum sEnum_
 

Friends

template<typename , typename >
class SetUnion
 

Detailed Description

template<int TDimension = -1, typename TScalarType = double>
class ls::primitives::sets::Singleton< TDimension, TScalarType >

A singleton set.

A singleton contains a single element, represented by the vector value_.

Template Parameters
TDimensionThe dimension of the singleton; if -1, it is dynamically sized.
TScalarTypeThe scalar type.

Constructor & Destructor Documentation

◆ Singleton() [1/2]

template<int TDimension = -1, typename TScalarType = double>
ls::primitives::sets::Singleton< TDimension, TScalarType >::Singleton ( )
inline

Value typedef.

Default constructor.

◆ Singleton() [2/2]

template<int TDimension = -1, typename TScalarType = double>
template<typename TDerived >
ls::primitives::sets::Singleton< TDimension, TScalarType >::Singleton ( const Eigen::EigenBase< TDerived > &  value)
inline

Constructs a Singleton instance from a vector.

Template Parameters
TDerivedDerived EigenBase class.
Parameters
valueSingleton value.

Member Function Documentation

◆ contains() [1/2]

template<int TDimension = -1, typename TScalarType = double>
template<typename TExpression >
std::enable_if<std::is_same<TExpression, type>::value, bool>::type ls::primitives::sets::Singleton< TDimension, TScalarType >::contains ( const SetExpression< TExpression > &  expr,
double  tol = 1e-6 
) const
inline

Returns true if this expression contains expr.

This specialization handles a singleton expression of the same type.

Template Parameters
TExpressionType of the other expression.
Parameters
exprExpression to check containment of.
tolNumerical tolerance.
Returns
True if this expression contains expr, false otherwise.

◆ contains() [2/2]

template<int TDimension = -1, typename TScalarType = double>
template<typename TExpression >
std::enable_if<!std::is_same<TExpression, type>::value, bool>::type ls::primitives::sets::Singleton< TDimension, TScalarType >::contains ( const SetExpression< TExpression > &  expr,
double  tol = 1e-6 
) const
inline

Returns true if this expression contains expr.

This specialization handles all other cases.

Template Parameters
TExpressionType of the other expression.
Parameters
exprExpression to check containment of.
tolNumerical tolerance.
Returns
False.

◆ dimension() [1/2]

template<int TDimension = -1, typename TScalarType = double>
template<int T_TDimension = TDimension>
int ls::primitives::sets::Singleton< TDimension, TScalarType >::dimension ( typename std::enable_if<(T_TDimension >=0)>::type = nullptr) const
inline

Returns the singleton dimension.

This specialization deals with the dynamic case.

Template Parameters
T_TDimensionCopy of TDimension.
Returns
Dimension of the singleton instance.

◆ dimension() [2/2]

template<int TDimension = -1, typename TScalarType = double>
template<int T_TDimension = TDimension>
int ls::primitives::sets::Singleton< TDimension, TScalarType >::dimension ( typename std::enable_if<(T_TDimension< 0)>::type = nullptr) const
inline

Returns the singleton dimension.

This specialization deals with the static case.

Template Parameters
T_TDimensionCopy of TDimension.
Returns
Dimension of the singleton instance.

◆ isEmpty()

template<int TDimension = -1, typename TScalarType = double>
bool ls::primitives::sets::Singleton< TDimension, TScalarType >::isEmpty ( ) const
inline

Returns true if the expression is the empty set.

Note
This always returns false, since a singleton always contains one element.
Returns
False.

◆ isSubset()

template<int TDimension = -1, typename TScalarType = double>
template<typename TExpression >
bool ls::primitives::sets::Singleton< TDimension, TScalarType >::isSubset ( const SetExpression< TExpression > &  expr)
inline

Checks if this expression is a subset of expr.

Template Parameters
TExpressionType of the other expression.
Parameters
exprExpression to check inclusion on.
Returns
True if this expression is a subset of expr, false otherwise.

◆ isSuperset()

template<int TDimension = -1, typename TScalarType = double>
template<typename TExpression >
bool ls::primitives::sets::Singleton< TDimension, TScalarType >::isSuperset ( const SetExpression< TExpression > &  expr)
inline

Checks if this expression is a superset of expr.

Template Parameters
TExpressionType of the other expression.
Parameters
exprExpression to check subsumption on.
Returns
True if this expression is a superset of expr, false otherwise.

◆ operator!=() [1/2]

template<int TDimension = -1, typename TScalarType = double>
template<typename TExpression >
std::enable_if<std::is_same<TExpression, type>::value, bool>::type ls::primitives::sets::Singleton< TDimension, TScalarType >::operator!= ( const SetExpression< TExpression > &  expr) const
inline

Checks if this expression is not equal to \expr.

This specialization deals with singletons of the same type.

Template Parameters
TExpressionType of the other expression.
Parameters
exprExpression to check inequality with.
Returns
True if this expression is not equal to expr, false otherwise.

◆ operator!=() [2/2]

template<int TDimension = -1, typename TScalarType = double>
template<typename TExpression >
std::enable_if<!std::is_same<TExpression, type>::value, bool>::type ls::primitives::sets::Singleton< TDimension, TScalarType >::operator!= ( const SetExpression< TExpression > &  expr) const
inline

Checks if this expression is not equal to \expr.

This specialization deals with all other cases.

Template Parameters
TExpressionType of the other expression.
Parameters
exprExpression to check inequality with.
Returns
True.

◆ operator==() [1/2]

template<int TDimension = -1, typename TScalarType = double>
template<typename TExpression >
std::enable_if<std::is_same<TExpression, type>::value, bool>::type ls::primitives::sets::Singleton< TDimension, TScalarType >::operator== ( const SetExpression< TExpression > &  expr) const
inline

Checks if this expression is equal to \expr.

This specialization deals with singletons of the same type.

Template Parameters
TExpressionType of the other expression.
Parameters
exprExpression to check equality with.
Returns
True if this expression is equal to expr, false otherwise.

◆ operator==() [2/2]

template<int TDimension = -1, typename TScalarType = double>
template<typename TExpression >
std::enable_if<!std::is_same<TExpression, type>::value, bool>::type ls::primitives::sets::Singleton< TDimension, TScalarType >::operator== ( const SetExpression< TExpression > &  expr) const
inline

Checks if this expression is equal to \expr.

This specialization deals with all other cases.

Template Parameters
TExpressionType of the other expression.
Parameters
exprExpression to check equality with.
Returns
False.

◆ relComplement()

template<int TDimension = -1, typename TScalarType = double>
template<typename TExpression >
SetComplement<type, TExpression> ls::primitives::sets::Singleton< TDimension, TScalarType >::relComplement ( const SetExpression< TExpression > &  expr)
inline

Computes the relative complement of this expression and expr.

The syntax is as follows:

// A \ B
A.relComplement(B);
Template Parameters
TExpressionType of the other expression.
Parameters
exprExpression to take relative complement with.
Returns
Relative complement.

◆ sdf()

template<int TDimension = -1, typename TScalarType = double>
template<typename TDerived >
double ls::primitives::sets::Singleton< TDimension, TScalarType >::sdf ( Eigen::MatrixBase< TDerived > &  p) const
inline

Returns signed distance to p.

Template Parameters
TDerivedDerived MatrixBase class.
Parameters
pA point.
Returns
Signed distance.

◆ setDimension() [1/2]

template<int TDimension = -1, typename TScalarType = double>
template<int T_TDimension = TDimension>
void ls::primitives::sets::Singleton< TDimension, TScalarType >::setDimension ( size_t  dim,
typename std::enable_if<(T_TDimension >=0)>::type = nullptr 
)
inline

Changes the dimension of the singleton.

This specialization conservatively resizes value_.

Template Parameters
T_TDimensionCopy of TDimension.
Parameters
dimNew dimension.

◆ setDimension() [2/2]

template<int TDimension = -1, typename TScalarType = double>
template<int T_TDimension = TDimension>
void ls::primitives::sets::Singleton< TDimension, TScalarType >::setDimension ( size_t  dim,
typename std::enable_if<(T_TDimension< 0)>::type = nullptr 
)
inline

Changes the dimension of the singleton.

This specialization raises a static assert since statically type Singleton instances cannot be resized.

Template Parameters
T_TDimensionCopy of TDimension.
Parameters
dimNew dimension.

◆ unionize()

template<int TDimension = -1, typename TScalarType = double>
template<typename TExpression >
SetUnion<type, TExpression> ls::primitives::sets::Singleton< TDimension, TScalarType >::unionize ( const SetExpression< TExpression > &  expr)
inline

Creates a union between this expression and another SetExpression.

Template Parameters
TExpressionType of the other expression.
Parameters
exprExpression to create a union with.
Returns
Union.

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