3#include <iolink/IOLinkAPI.h>
7#include <initializer_list>
22 using Iterator = ValueType*;
23 using ConstIterator =
const ValueType*;
48 VectorX(std::initializer_list<ValueType> init);
60 for (
size_t i = 0; i < m_size; ++i)
62 m_data[i] =
static_cast<ValueType
>(other[i]);
77 inline size_t size()
const {
return m_size; }
82 inline ValueType
at(
size_t index)
const {
return m_data[index]; }
87 inline void setAt(
size_t index, ValueType value) { m_data[index] = value; }
89 inline ValueType& operator[](
size_t index) {
return m_data[index]; }
90 inline ValueType operator[](
size_t index)
const {
return m_data[index]; }
92 inline Iterator begin() noexcept {
return m_data; }
93 inline ConstIterator begin() const noexcept {
return m_data; }
94 inline Iterator end() noexcept {
return static_cast<Iterator
>(m_data + m_size); }
95 inline ConstIterator end() const noexcept {
return static_cast<ConstIterator
>(m_data + m_size); }
97 bool operator==(
const VectorX& other)
const;
98 bool operator!=(
const VectorX& other)
const;
119 std::string toString()
const;
133 VectorX& operator*=(ValueType value);
134 VectorX& operator/=(ValueType value);
136 inline VectorX operator*(ValueType s)
const {
return VectorX(*
this) *= s; }
137 inline VectorX operator/(ValueType s)
const {
return VectorX(*
this) /= s; }
139 friend inline VectorX operator*(ValueType s,
VectorX v) {
return v *= s; }
163 bool operator<(
const VectorX& other)
const;
164 bool operator<=(
const VectorX& other)
const;
165 bool operator>(
const VectorX& other)
const;
166 bool operator>=(
const VectorX& other)
const;
178 std::array<ValueType, 4> m_array;
183operator<<(std::ostream& os,
const VectorX<T>& v)
193extern template class IOLINK_API_IMPORT VectorX<uint8_t>;
194extern template class IOLINK_API_IMPORT VectorX<int8_t>;
195extern template class IOLINK_API_IMPORT VectorX<uint16_t>;
196extern template class IOLINK_API_IMPORT VectorX<int16_t>;
197extern template class IOLINK_API_IMPORT VectorX<uint32_t>;
198extern template class IOLINK_API_IMPORT VectorX<int32_t>;
199extern template class IOLINK_API_IMPORT VectorX<uint64_t>;
200extern template class IOLINK_API_IMPORT VectorX<int64_t>;
201extern template class IOLINK_API_IMPORT VectorX<float>;
202extern template class IOLINK_API_IMPORT VectorX<double>;
A dynamically sized arithmetic vector.
Definition: VectorX.h:18
VectorX(std::initializer_list< ValueType > init)
Creates a vector from an initialization list.
static VectorX createUniform(size_t size, ValueType value)
Creates a vector filled with one value.
void setAt(size_t index, ValueType value)
Set value as given index.
Definition: VectorX.h:87
ValueType dot(const VectorX &v) const
Dot product.
void normalize()
Normalize the vector.
VectorX(size_t size)
Creates an unitialized vector.
double squaredLength() const
Returns the vector's norm, squared.
double length() const
Returns the vector's norm.
size_t size() const
Returns the size of the vector, which also correspond to vector number of dimension.
Definition: VectorX.h:77
VectorX(const VectorX< U > &other)
Build a vector from a vector storing another type.
Definition: VectorX.h:57
ValueType at(size_t index) const
Access vector's value at given index.
Definition: VectorX.h:82
VectorX()
Creates an empty vector.
VectorX cross(const VectorX &v) const
Cross product of two vectors.
All IOLink symbols are enclosed in this namespace.
Definition: ArrayX.h:8