Base Framework
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Related Functions | List of all members
Vector< TYPE > Class Template Reference

Vector. More...

#include <base/math/Vector.h>

Inherits Object.

Classes

class  Element
 
class  IncompatibleVectors
 Incompatible vector exception. More...
 
class  VectorException
 Exception raised by the Vector class. More...
 

Public Types

typedef ReferenceCountedAllocator< TYPE >::Iterator Iterator
 
typedef ReferenceCountedAllocator< TYPE >::ReadIterator ReadIterator
 
typedef ReferenceCountedAllocator< TYPE >::Enumerator Enumerator
 
typedef ReferenceCountedAllocator< TYPE >::ReadEnumerator ReadEnumerator
 

Public Member Functions

unsigned int getSize () const noexcept
 
 Vector (unsigned int size)
 
 Vector (const TYPE elements[], unsigned int size)
 
 Vector (std::initializer_list< TYPE > l)
 
 Vector (const Vector &copy) noexcept
 
Vectoroperator= (const Vector &assign)
 
Iterator getBeginIterator () noexcept
 
Iterator getEndIterator () noexcept
 
ReadIterator getBeginIterator () const noexcept
 
ReadIterator getEndIterator () const noexcept
 
Enumerator getEnumerator () noexcept
 
ReadEnumerator getReadEnumerator () const noexcept
 
const TYPE & getAt (unsigned int index) const
 
void setAt (unsigned int index, const TYPE &value)
 
Element operator[] (unsigned int index)
 
Vector plus () const noexcept
 
Vector minus () const noexcept
 
Vectorclear () noexcept
 
Vectornegate () noexcept
 
Vectoradd (const Vector &value)
 
Vectorsubtract (const Vector &value)
 
Vectormultiply (const TYPE &value) noexcept
 
Vectordivide (const TYPE &value) noexcept
 
Vectornegate (const Vector &value) noexcept
 
TYPE dotdot () const noexcept
 
TYPE norm () const noexcept
 
bool operator== (const Vector &vector) const
 
Vectoroperator+= (const Vector &value)
 
Vectoroperator-= (const Vector &value)
 
Vectoroperator*= (const TYPE &value) noexcept
 
Vectoroperator/= (const TYPE &value) noexcept
 
Vector operator+ () const noexcept
 
Vector operator- () const noexcept
 

Protected Member Functions

TYPE * getElements ()
 
const TYPE * getElements () const noexcept
 
const TYPE * getReadOnlyElements () const noexcept
 
void setSize (unsigned int size)
 

Protected Attributes

Reference< ReferenceCountedAllocator< TYPE > > elements
 

Related Functions

(Note that these are not member functions.)

template<class TYPE >
FormatOutputStreamoperator<< (FormatOutputStream &stream, const Vector< TYPE > &value)
 

Detailed Description

template<class TYPE>
class Vector< TYPE >

Vector.

Vector implementation.

Version
1.10

Constructor & Destructor Documentation

◆ Vector() [1/4]

template<class TYPE >
Vector< TYPE >::Vector ( unsigned int  size)
explicit

Initializes vector of the specified size. The elements are not initialized.

Parameters
sizeThe number of elements in the vector. Must be non zero.

◆ Vector() [2/4]

template<class TYPE >
Vector< TYPE >::Vector ( const TYPE  elements[],
unsigned int  size 
)

Initializes vector from the specified array.

Parameters
elementsThe desired elements.
sizeThe number of elements in the array.

◆ Vector() [3/4]

template<class TYPE >
Vector< TYPE >::Vector ( std::initializer_list< TYPE >  l)
inline

Initializes vector from initializer list.

◆ Vector() [4/4]

template<class TYPE >
Vector< TYPE >::Vector ( const Vector< TYPE > &  copy)
inlinenoexcept

Initializes vector from other vector.

Parameters
copyThe vector to be copied.

Member Function Documentation

◆ add()

template<class TYPE >
Vector& Vector< TYPE >::add ( const Vector< TYPE > &  value)

Adds the specified vector to this vector.

Parameters
valueThe vector to be added.

◆ clear()

template<class TYPE >
Vector& Vector< TYPE >::clear ( )
noexcept

Sets this vector to the zero vector.

◆ divide()

template<class TYPE >
Vector& Vector< TYPE >::divide ( const TYPE &  value)
noexcept

Divides this vector with the specified value.

Parameters
valueThe divisor.

◆ dotdot()

template<class TYPE >
TYPE Vector< TYPE >::dotdot ( ) const
noexcept

Returns the dot product of this vector with itself.

◆ getAt()

template<class TYPE >
const TYPE& Vector< TYPE >::getAt ( unsigned int  index) const

Returns the element at the specified index.

Parameters
indexThe index of the desired element.

◆ getBeginIterator() [1/2]

template<class TYPE >
ReadIterator Vector< TYPE >::getBeginIterator ( ) const
inlinenoexcept

Returns the first element of the allocator as a non-modifying array.

◆ getBeginIterator() [2/2]

template<class TYPE >
Iterator Vector< TYPE >::getBeginIterator ( )
inlinenoexcept

Returns the first element of the allocator as a modifying array.

◆ getElements() [1/2]

template<class TYPE >
TYPE* Vector< TYPE >::getElements ( )
inlineprotected

Returns the elements of the vector for modification.

◆ getElements() [2/2]

template<class TYPE >
const TYPE* Vector< TYPE >::getElements ( ) const
inlineprotectednoexcept

Returns the elements of the vector for read-only.

◆ getEndIterator() [1/2]

template<class TYPE >
ReadIterator Vector< TYPE >::getEndIterator ( ) const
inlinenoexcept

Returns the end of the allocator as a non-modifying array.

◆ getEndIterator() [2/2]

template<class TYPE >
Iterator Vector< TYPE >::getEndIterator ( )
inlinenoexcept

Returns the end of the allocator as a modifying array.

◆ getEnumerator()

template<class TYPE >
Enumerator Vector< TYPE >::getEnumerator ( )
inlinenoexcept

Returns a modifying enumerator of the array.

◆ getReadEnumerator()

template<class TYPE >
ReadEnumerator Vector< TYPE >::getReadEnumerator ( ) const
inlinenoexcept

Returns a non-modifying enumerator of the array.

◆ getReadOnlyElements()

template<class TYPE >
const TYPE* Vector< TYPE >::getReadOnlyElements ( ) const
inlineprotectednoexcept

Returns the elements of the vector for read-only.

◆ getSize()

template<class TYPE >
unsigned int Vector< TYPE >::getSize ( ) const
inlinenoexcept

Gets the size of the vector.

◆ minus()

template<class TYPE >
Vector Vector< TYPE >::minus ( ) const
noexcept

Unary minus.

◆ multiply()

template<class TYPE >
Vector& Vector< TYPE >::multiply ( const TYPE &  value)
noexcept

Multiplies this vector with the specified value.

Parameters
valueThe multiplicator.

◆ negate() [1/2]

template<class TYPE >
Vector& Vector< TYPE >::negate ( )
noexcept

Negates this vector.

◆ negate() [2/2]

template<class TYPE >
Vector& Vector< TYPE >::negate ( const Vector< TYPE > &  value)
noexcept

Negates the specified vector and stores the result in this vector.

◆ norm()

template<class TYPE >
TYPE Vector< TYPE >::norm ( ) const
noexcept

Returns the L2-norm of the vector.

◆ operator*=()

template<class TYPE >
Vector& Vector< TYPE >::operator*= ( const TYPE &  value)
inlinenoexcept

Multiplies this vector with the specified value.

Parameters
valueThe multiplicator.

◆ operator+()

template<class TYPE >
Vector Vector< TYPE >::operator+ ( ) const
inlinenoexcept

Unary plus.

◆ operator+=()

template<class TYPE >
Vector& Vector< TYPE >::operator+= ( const Vector< TYPE > &  value)
inline

Adds the specified vector from this vector.

Parameters
valueThe value to be added.

◆ operator-()

template<class TYPE >
Vector Vector< TYPE >::operator- ( ) const
inlinenoexcept

Unary minus.

◆ operator-=()

template<class TYPE >
Vector& Vector< TYPE >::operator-= ( const Vector< TYPE > &  value)
inline

Subtracts the specified vector from this vector.

Parameters
valueThe value to be subtracted.

◆ operator/=()

template<class TYPE >
Vector& Vector< TYPE >::operator/= ( const TYPE &  value)
inlinenoexcept

Divides this vector with the specified value.

Parameters
valueThe divisor.

◆ operator=()

template<class TYPE >
Vector& Vector< TYPE >::operator= ( const Vector< TYPE > &  assign)

Assigns vector to this vector.

Parameters
eqThe vector containing the desired elements.

◆ operator==()

template<class TYPE >
bool Vector< TYPE >::operator== ( const Vector< TYPE > &  vector) const

Returns true if the vectors are equal.

Parameters
vectorVector to be compared.

◆ operator[]()

template<class TYPE >
Element Vector< TYPE >::operator[] ( unsigned int  index)
inline

Returns the element at the specified index.

Parameters
indexThe index of the desired element.

◆ plus()

template<class TYPE >
Vector Vector< TYPE >::plus ( ) const
noexcept

Unary plus.

◆ setAt()

template<class TYPE >
void Vector< TYPE >::setAt ( unsigned int  index,
const TYPE &  value 
)

Sets the element at the specified index.

Parameters
indexThe index of the desired element.
valueThe desired value.

◆ setSize()

template<class TYPE >
void Vector< TYPE >::setSize ( unsigned int  size)
inlineprotected

Sets the size of the vector. Only invocated by constructors.

◆ subtract()

template<class TYPE >
Vector& Vector< TYPE >::subtract ( const Vector< TYPE > &  value)

Subtracts the specified vector from this vector.

Parameters
vectorThe vector to be subtracted.

Friends And Related Function Documentation

◆ operator<<()

template<class TYPE >
FormatOutputStream & operator<< ( FormatOutputStream stream,
const Vector< TYPE > &  value 
)
related

Writes a string representation of a vector object to a format stream.

Member Data Documentation

◆ elements

template<class TYPE >
Reference<ReferenceCountedAllocator<TYPE> > Vector< TYPE >::elements
protected

The elements of the vector stored in an array. The array is guarantied to be non-empty when the vector object has been initialized.