The Vish Visualization Shell 0.3
Vish
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
Eagle::FixedArray< value, N > Class Template Reference

A FixedArray is a simple copy-by-value array providing random access to its elements. More...

#include <elementary/eagle/FixedArray.hpp>

Inheritance diagram for Eagle::FixedArray< value, N >:
Eagle::Vector< Value, Dims *Dims - Dims *(Dims+1)/2 > Eagle::Vector< Row< Dims, Value >, N *(N+1)/2 > Eagle::Vector< Value, R *C > Eagle::Vector< value, R *C > Eagle::Vector< ScalarType, N > Eagle::Vector< value, N *(N+1)/2 > Eagle::Vector< META::PreciserType< FirstVector::value_type, SecondVector::value_type >::result, FirstVector::SIZE+SecondVector::SIZE > Eagle::Vector< double, 8 > Eagle::Vector< double, 4 > Eagle::Vector< double, 1 > Eagle::Vector< double, 2 > Eagle::Vector< real, 4 > Eagle::Vector< Row< Dims, Value >, Dims *Dims - Dims *(Dims+1)/2 > Eagle::Vector< double, Dims > Eagle::Vector< float, R *C > Eagle::Vector< color8_t, 4 >

Public Types

typedef FlattenedArray_t::value_type Element_t
 The maximally reduced type of elements stored here.
 
typedef GetFixedArrayType< value >::result_t ElementAsFixedArray_t
 Element type as fixed array, if it is convertible to a fixed array.
 
typedef FixedArray FixedArray_t
 Exporting the type definition of this array cass type.
 
typedef FixedArrayFlattener< FixedArrayOfElements_tFixedArrayFlattener_t
 Internal helper class.
 
typedef FixedArray< ElementAsFixedArray_t, N > FixedArrayOfElements_t
 If the value is derived from a fixed array type itself, then the FixedArrayOfElements_t is an FixedArray<FixedArray<>> type.
 
typedef FixedArrayFlattener_t::result_t FlattenedArray_t
 Reduction of this array type, if it is nested, to an flattened type which contains elementary types.
 
typedef value value_type
 Export the type of the respective element value type.
 

Public Member Functions

void expandMinMax (FixedArray &MinValues, FixedArray &MaxValues) const
 Expand a range given by MinValues,MaxValues to include the values of this array, done per component.
 
constexpr FixedArray () noexcept
 Default constructor.
 
template<class AType , class BType , OperatorID_t CompType>
constexpr FixedArray (const FixedArray< AType, N > &l, const FixedArray< BType, N > &r, const Operator< CompType > &)
 Computational constructor for binary operations on two fixed arrays, calls the Operator's ternary() member function for each element.
 
template<typename T , dimension_t M>
constexpr FixedArray (const FixedArray< T, M > &F, const T &DefaultValue)
 Construct array from another array type of variable length.
 
template<typename T >
constexpr FixedArray (const FixedArray< T, N > &F)
 Automatic type conversion function.
 
template<typename T , typename ConversionFunctor >
constexpr FixedArray (const FixedArray< T, N > &F, const ConversionFunctor &CF, const FA_CONVERT &)
 Construct array from another array type of same length.
 
template<class InitType >
constexpr FixedArray (const std::initializer_list< InitType > &Init)
 Construct from a initialization array.
 
constexpr FixedArray (const value &a)
 Convenience Constructor: initialize the first element.
 
constexpr FixedArray (const value &a, const value &b)
 Convenience Constructor: initialize the first two elements.
 
 FixedArray (const value &a, const value &b, const value &c)
 Convenience Constructor: initialize the first three elements.
 
constexpr FixedArray (const value &a, const value &b, const value &c, const value &d)
 Convenience Constructor: initialize the first four elements.
 
constexpr FixedArray (const value &a, const value &b, const value &c, const value &d, const value &e)
 Convenience Constructor: initialize the first five elements.
 
constexpr value & get (int i)
 writable element access
 
constexpr const value & get (int i) const
 read-only element access
 
template<int subsize, int offset>
constexpr const FixedArray< value, subsize > * get_subarray () const
 Helper class for retrieve a subset of the current array.
 
constexpr const FixedArray< value, SIZE-1 > & get_subdim () const
 Mainly introduced because of Interpolate::operator[].
 
const FixedArray_tgetFixedArray () const noexcept
 convenience function for base classes
 
FixedArray_tgetFixedArray () noexcept
 convenience function for base classes
 
constexpr value getMax () const
 Compute the maximum element value of this array.
 
constexpr value getMin () const
 Compute the maximum element value of this array.
 
template<typename T >
constexpr bool operator!= (const FixedArray< T, N > &F) const
 Compare two arrays.
 
template<typename T >
constexpr bool operator== (const FixedArray< T, N > &F) const
 Compare two arrays.
 
constexpr value & operator[] (int i)
 writeable element access operator
 
constexpr const value & operator[] (int i) const
 read-only element access operator
 
constexpr value * ptr (int i=0) noexcept
 Return a pointer to the ith element, no range checking.
 
template<class Value >
constexpr void set (const Value &x)
 Set all array elements to the same value.
 
void setFromArray (const value *x, int length=SIZE, int offset=0)
 Set all array elements to an array's element value.
 
void sort (FixedArray< int, N > &I) const
 Sort the elements of an array into the index array.
 

Static Public Member Functions

template<typename T , typename ConversionFunctor >
static constexpr FixedArray convert (const FixedArray< T, N > &F, const ConversionFunctor &CF)
 Perform a type conversion on a given fixed array into another basis type:
 
static constexpr dimension_t size ()
 The number of elements here.
 

Protected Attributes

value data [SIZE]
 The actual data values, intentional no-initialization for data member, which increases performance on vector creation.
 

Friends

template<OperatorID_t CompType>
constexpr FixedArray component_wise (const FixedArray &l, const FixedArray &r, const Operator< CompType > &Op)
 Apply a certain operator component-wise.
 
template<typename T >
constexpr bool isEqual (const FixedArray< value, N > &L, const FixedArray< T, N > &R, double precision)
 Compare two arrays with limited precision.
 

Detailed Description

template<class value, dimension_t N>
class Eagle::FixedArray< value, N >

A FixedArray is a simple copy-by-value array providing random access to its elements.

Its purpose is to implement small, light-weight types such as 3-vectors, 3x3 matrices and similar, useful for small efficient numerical operations, as they don't have an new/delete memory allocation overhead. The FixedArray does not provide operations on its elements - use class Vector for this purpose.

@Note Copying or creating temporary FixedArray objects should be avoided, as the entire data fields are copied.

See also
Vector

Member Function Documentation

◆ convert()

template<class value , dimension_t N>
template<typename T , typename ConversionFunctor >
static constexpr FixedArray Eagle::FixedArray< value, N >::convert ( const FixedArray< T, N > &  F,
const ConversionFunctor &  CF 
)
inlinestaticconstexpr

Perform a type conversion on a given fixed array into another basis type:

A FixedArray is a simple copy-by-value array providing random access to its elements.
Definition FixedArray.hpp:217
value data[SIZE]
The actual data values, intentional no-initialization for data member, which increases performance on...
Definition FixedArray.hpp:262
static constexpr FixedArray convert(const FixedArray< T, N > &F, const ConversionFunctor &CF)
Perform a type conversion on a given fixed array into another basis type:
Definition FixedArray.hpp:397

This is implemented as a type-safe static member function, thus allows explicit type conversion when calling polymorphic or template functions.

References Eagle::FixedArray< value, N >::FixedArray().

◆ get_subarray()

template<class value , dimension_t N>
template<int subsize, int offset>
constexpr const FixedArray< value, subsize > * Eagle::FixedArray< value, N >::get_subarray ( ) const
inlineconstexpr

Helper class for retrieve a subset of the current array.

The array subset will be a reference to the original array, i.e. all arrayelements are shared. Example:

 FixedArray<3, float>*Point3D;
 FixedArray<2, float>*Point2Dt = FixedArray<N , float>::subarray<2,0>::get(Point);
 
 The FixedArray's member function get_subarray() serves the same
 purpose and functionality via a simpler interface using template
 function parameters, which unfortunately might not be supported by
 every compiler. If so, the more explicit subarray syntax needs to
 be used.
*/
template <int subsize, int offset=0>
        struct  subarray
{
        typedef FixedArray<value, subsize> Subarray_t;
        typedef Assert< offset+subsize <= SIZE > RangeCheck_t;

static  constexpr   FixedArray<value, subsize>&get(FixedArray&A)
        {
                return *Subarray_tfa_cast(A.data+offset);
        }

static constexpr const FixedArray<value, subsize>&get(const FixedArray&A)
        {
                return *Subarray_tfa_cast(A.data+offset);
        }

static constexpr  FixedArray<value, subsize>*get(FixedArray*A)
        {
                assert(A);
                return Subarray_t::fa_cast(A->data+offset);
        }

static constexpr const FixedArray<value, subsize>*get(const FixedArray*A)
        {
                assert(A);
                return Subarray_t::fa_cast(A->data+offset);
        }
};

/**
 Same functionality as the  subarray template member class,
 but simpler interface.

Example:
const FixedArray<3 , CoordinateType>*P3D;
const FixedArray<2 , CoordinateType>*P2D;
        P2D = P3D->get_subarray<2,0>();

◆ operator!=()

template<class value , dimension_t N>
template<typename T >
constexpr bool Eagle::FixedArray< value, N >::operator!= ( const FixedArray< T, N > &  F) const
inlineconstexpr

Compare two arrays.

The types might differ, but the length must be identical. The comparision loop is terminated at the first type mismatch.

References Eagle::FixedArray< value, N >::data.

◆ operator==()

template<class value , dimension_t N>
template<typename T >
constexpr bool Eagle::FixedArray< value, N >::operator== ( const FixedArray< T, N > &  F) const
inlineconstexpr

Compare two arrays.

The types might differ, but the length must be identical. The comparision loop is terminated at the first type mismatch.

References Eagle::FixedArray< value, N >::data.

◆ setFromArray()

template<class value , dimension_t N>
void Eagle::FixedArray< value, N >::setFromArray ( const value *  x,
int  length = SIZE,
int  offset = 0 
)
inline

Set all array elements to an array's element value.

Note that the array must have at least the same length as the FixedArray.

References Eagle::FixedArray< value, N >::data.

Friends And Related Symbol Documentation

◆ isEqual

template<class value , dimension_t N>
template<typename T >
constexpr bool isEqual ( const FixedArray< value, N > &  L,
const FixedArray< T, N > &  R,
double  precision 
)
friend

Compare two arrays with limited precision.

The types might differ, but the length must be identical. The comparision loop is terminated at the first type mismatch.