tesseract++ 0.0.1
N-dimensional tensor library for embedded systems
Loading...
Searching...
No Matches
vector.h
Go to the documentation of this file.
1#ifndef VECTOR_H
2#define VECTOR_H
3
4#include "tensor.h"
5
6// Derived class: Vector
7template <typename T, my_size_t Size>
8class Vector : public TensorND<T, Size, 1>
9{
10public:
11 // Default constructor
12 Vector() : TensorND<T, Size, 1>() {}
13 // Constructor to initialize all elements to a specific value
14 Vector(T initValue) : TensorND<T, Size, 1>(initValue) {}
15 // Copy constructor
16 Vector(const Vector &other) : TensorND<T, Size, 1>(other) {}
17 // Move constructor
18 Vector(Vector &&other) noexcept : TensorND<T, Size, 1>(std::move(other)) {}
19 // Constructor from an array
20 Vector(const T (&array)[Size]) : TensorND<T, Size, 1>()
21 {
22 for (my_size_t i = 0; i < Size; ++i)
23 {
24 this->data_[i] = array[i];
25 }
26 }
27
28 // overload () operator to access elements
30 {
31 return TensorND<T, Size, 1>::operator()(index, 0);
32 }
33
34 const T &operator()(my_size_t index) const
35 {
36 return TensorND<T, Size, 1>::operator()(index, 0);
37 }
38};
39
40#endif // VECTOR_H
Definition tensor.h:15
T & operator()(Indices... indices)
Definition tensor.h:52
Definition vector.h:9
Vector(const Vector &other)
Definition vector.h:16
Vector(Vector &&other) noexcept
Definition vector.h:18
Vector()
Definition vector.h:12
Vector(const T(&array)[Size])
Definition vector.h:20
T & operator()(my_size_t index)
Definition vector.h:29
Vector(T initValue)
Definition vector.h:14
const T & operator()(my_size_t index) const
Definition vector.h:34
#define my_size_t
Size/index type used throughout the library.
Definition config.h:126