codac 1.5.6
Loading...
Searching...
No Matches
codac2_AnalyticTraj.h
Go to the documentation of this file.
1
9
10#pragma once
11
13#include "codac2_TrajBase.h"
14#include "codac2_SampledTraj.h"
15
16namespace codac2
17{
18 template<typename O, typename S = typename O::Scalar>
19 class AnalyticTraj : public TrajBase<S>, public AnalyticFunction<O>
20 {
21 public:
22
23 AnalyticTraj(const AnalyticFunction<O>& f, const Interval& tdomain)
24 : TrajBase<S>(), AnalyticFunction<O>(f), _tdomain(tdomain)
25 {
26 assert_release(f.args().total_size() == 1 && "domain of f must be 1d");
27 }
28
29 virtual Index size() const
30 {
31 return AnalyticFunction<O>::output_size();
32 }
33
34 virtual bool is_empty() const
35 {
36 return _tdomain.is_empty();
37 }
38
39 virtual Interval tdomain() const
40 {
41 return _tdomain;
42 }
43
44 virtual void truncate_tdomain(const Interval& new_tdomain)
45 {
46 assert_release(this->tdomain().is_superset(new_tdomain));
47 _tdomain &= new_tdomain;
48 }
49
50 virtual typename Wrapper<S>::Domain codomain() const
51 {
52 return AnalyticFunction<O>::eval(this->_tdomain);
53 }
54
55 virtual S operator()(double t) const
56 {
57 if(!this->tdomain().contains(t))
58 return this->nan_value();
59 return AnalyticFunction<O>::real_eval(t);
60 }
61
62 virtual typename Wrapper<S>::Domain operator()(const Interval& t) const
63 {
64 if(!this->tdomain().is_superset(t))
65 return typename Wrapper<S>::Domain((*this)(tdomain().lb())) // we obtain the output dimension by an evalution...
66 .init(Interval(-oo,oo));
67 return AnalyticFunction<O>::eval(t);
68 }
69
70 protected:
71
72 Interval _tdomain;
73 };
74}