| IOLink 1.11.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
iolink::Vector< T, N > Class Template Referencefinal

An arithmetic vector. More...

`#include <iolink/Vector.h>`

## Public Types
using | ValueType = T
using | Iterator = typename std::array< T, N >::iterator
using | ConstIterator = typename std::array< T, N >::const_iterator

## Public Member Functions
| Vector ()
| Create a vector with unitialized values.
| Vector (std::initializer_list< ValueType > init)
| Create a vector with the values contained in a bracket list.
| Vector (const VectorX< ValueType > &other)
| Build a Vector from a VectorX of same type.
| Vector (const VectorX< ValueType > &other, ValueType padding)
| Build a vector from a VectorX of same type.
template<typename U >
| Vector (const Vector< U, N > &other)
| Build a vector from a vector storing another type.
| Vector (const Vector &other)=default
Vector & | operator= (const Vector &other)=default
| Vector (Vector &&other) noexcept=default
Vector & | operator= (Vector &&other) noexcept=default
size_t | size () const
| Returns the size of the vector, which also correspond to vector number of dimension.
ValueType | at (size_t index) const
| Access vector's value at given index.
void | setAt (size_t index, ValueType value)
| Set value as given index.
ValueType | operator[] (size_t index) const
ValueType & | operator[] (size_t index)
ValueType * | data ()
| Direct access to the vector's data.
const ValueType * | data () const
| Direct const access to the vector's data.
double | squaredLength () const
| Returns the vector's norm, squared.
double | length () const
| Returns the vector's norm.
void | normalize ()
| Normalize the vector.
Iterator | begin () noexcept
ConstIterator | begin () const noexcept
Iterator | end () noexcept
ConstIterator | end () const noexcept
bool | operator== (const Vector &other) const
bool | operator!= (const Vector &other) const
std::string | toString () const
Vector | operator- () const
Vector & | operator+= (const Vector &v)
Vector & | operator-= (const Vector &v)
Vector | operator+ (const Vector &v) const
Vector | operator- (const Vector &v) const
Vector & | operator*= (ValueType value)
Vector & | operator/= (ValueType value)
Vector | operator* (ValueType v) const
Vector | operator/ (ValueType v) const
ValueType | dot (const Vector &v) const
| Dot product of two vectors.
Vector | cross (const Vector &v) const
| Cross product of two vectors.
Vector & | operator*= (const Vector &v)
Vector & | operator/= (const Vector &v)
Vector | operator* (const Vector &v) const
Vector | operator/ (const Vector &v) const
bool | operator< (const Vector &other) const
bool | operator<= (const Vector &other) const
bool | operator> (const Vector &other) const
bool | operator>= (const Vector &other) const
| operator VectorX< ValueType > () const

## Static Public Member Functions
static Vector | createUniform (ValueType value)
| Create a vector with the given value for all components.

## Friends
Vector | operator* (ValueType value, Vector v)

## Detailed Description

template<typename T, size_t N>
class iolink::Vector< T, N >

An arithmetic vector.

Template Parameters

  T | The type wrote in the vector.
  N | The size, or number of dimension of the vector.

Aliases can be used to made this class more practical to use. They use the following convention: VectorNX Where N is the size and X the type. The types currently available are:

- U8 and I8 respectively for unsigned and signed 8bits integers.
- U16 and I16 respectively for unsigned and signed 16bits integers.
- U32 and I32 respectively for unsigned and signed 32bits integers.
- U64 and I64 respectively for unsigned and signed 64bits integers.
- F for single precision floats.
- D for double precision floats.

Examples:

- Vector2i32: 2 dimensional 32bits signed integer.
- Vector3f: 3 dimensionnal single precision float.

Examples
  colorWheel.cpp, createDataFrame.cpp, customImageView.cpp, and gradientFloatToInt.cpp.

## Constructor & Destructor Documentation

## ◆ Vector() [1/4]

template<typename T , size_t N>

iolink::Vector< T, N >::Vector | ( | std::initializer_list< ValueType > | init | ) |

Create a vector with the values contained in a bracket list.

Exceptions

  InvalidArgument | when initializing with a wrong number of elements

## ◆ Vector() [2/4]

template<typename T , size_t N>

iolink::Vector< T, N >::Vector | ( | const VectorX< ValueType > & | other | ) |

Build a Vector from a VectorX of same type.

If the VectorX has a size different of N, behavior is undefined.

## ◆ Vector() [3/4]

template<typename T , size_t N>

iolink::Vector< T, N >::Vector | ( | const VectorX< ValueType > & | other,
|  | ValueType | padding
| ) |  |

Build a vector from a VectorX of same type.

Parameters

  other | VectorX to use to build the new vector
  padding | Value to put at the end of vector to fill missing values. Fox example, Vector4({4, 5}, 0) will create the Vector {4, 5, 0, 0}.

## ◆ Vector() [4/4]

template<typename T , size_t N>
template<typename U >

iolink::Vector< T, N >::Vector | ( | const Vector< U, N > & | other | ) |
| inline explicit

Build a vector from a vector storing another type.

Template Parameters

  U | The type of the source vector.

Parameters

  other | The vector to convert.

## Member Function Documentation

## ◆ createUniform()

template<typename T , size_t N>

static Vector iolink::Vector< T, N >::createUniform | ( | ValueType | value | ) |
| static

Create a vector with the given value for all components.

Parameters

  value | The value wich the vector's data will be filled.

## ◆ cross()

template<typename T , size_t N>

Vector iolink::Vector< T, N >::cross | ( | const Vector< T, N > & | v | ) | const

Cross product of two vectors.

Work only for vectors of size 3.

## ◆ length()

template<typename T , size_t N>

double iolink::Vector< T, N >::length | ( |  | ) | const

Returns the vector's norm.

Specifically, it is the L1 norm that's computed here.

Examples
  colorWheel.cpp.

## ◆ squaredLength()

template<typename T , size_t N>

double iolink::Vector< T, N >::squaredLength | ( |  | ) | const

Returns the vector's norm, squared.

Specifically, it is the L1 norm that's computed here.

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

- iolink/public/include/iolink/Vector.h