- 3.0.2 core module.
TimeArray.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 #include "../Time.h"
10 
11 #include "ScalarArray.h"
12 
13 namespace ct {
14 namespace core {
15 namespace tpl {
16 
18 
21 template <typename SCALAR>
22 class TimeArray : public ScalarArray<SCALAR>
23 {
24 public:
26  TimeArray() {}
28 
33  TimeArray(const SCALAR& dt, const size_t& N, const SCALAR& t0 = 0.0)
34  : ScalarArray<SCALAR>(linspace<ScalarArray<SCALAR>>(t0, t0 + (N - 1) * dt, N))
35  {
36  }
37 
39 
44  TimeArray(size_t n, const SCALAR& value = SCALAR()) : ScalarArray<SCALAR>(n, value){};
45 
47  TimeArray(const TimeArray& other) : ScalarArray<SCALAR>(other){};
48 
50  TimeArray(const std::vector<SCALAR>& arg) : ScalarArray<SCALAR>()
51  {
52  for (size_t i = 0; i < arg.size(); i++)
53  this->push_back(arg[i]);
54  }
55 };
56 }
57 
59 }
60 }
TimeArray(const SCALAR &dt, const size_t &N, const SCALAR &t0=0.0)
evenly spaced constructor
Definition: TimeArray.h:33
TimeArray(size_t n, const SCALAR &value=SCALAR())
resize constructor
Definition: TimeArray.h:44
TRAJECTORY_T linspace(const typename TRAJECTORY_T::value_type &a, const typename TRAJECTORY_T::value_type &b, const size_t N)
replicates the well-known linspace command from MATLAB in C++
Definition: linspace.h:23
CppAD::AD< CppAD::cg::CG< double > > SCALAR
constexpr size_t n
Definition: MatrixInversionTest.cpp:14
for i
TimeArray()
default constructor
Definition: TimeArray.h:26
An array in time.
Definition: TimeArray.h:22
An array of scalar data types.
Definition: ScalarArray.h:18
TimeArray(const TimeArray &other)
copy constructor
Definition: TimeArray.h:47
TimeArray(const std::vector< SCALAR > &arg)
std::vector constructor
Definition: TimeArray.h:50