isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Linspace.h
1 #pragma once
2 
3 #include "Common.h"
4 
5 namespace isce3 { namespace core {
6 
8 template<typename T>
9 class Linspace {
10 public:
11 
21  CUDA_HOSTDEV
22  constexpr
23  static
24  Linspace<T> from_interval(T first, T last, int size);
25 
26  Linspace() = default;
27 
35  CUDA_HOSTDEV
36  constexpr
37  Linspace(T first, T spacing, int size);
38 
39  template<typename U>
40  CUDA_HOSTDEV
41  constexpr
42  Linspace(const Linspace<U> &);
43 
44  template<typename U>
45  CUDA_HOSTDEV
46  constexpr
47  Linspace<T> & operator=(const Linspace<U> &);
48 
54  CUDA_HOSTDEV
55  constexpr
56  T operator[](int pos) const { return _first + pos * _spacing; }
57 
59  CUDA_HOSTDEV
60  constexpr
61  T first() const { return _first; }
62 
64  CUDA_HOSTDEV
65  constexpr
66  void first(T first) { _first = first; }
67 
69  CUDA_HOSTDEV
70  constexpr
71  T last() const { return operator[](_size - 1); }
72 
74  CUDA_HOSTDEV
75  constexpr
76  T spacing() const { return _spacing; }
77 
79  CUDA_HOSTDEV
80  constexpr
81  void spacing(T spacing) { _spacing = spacing; };
82 
84  CUDA_HOSTDEV
85  constexpr
86  int size() const { return _size; }
87 
93  CUDA_HOSTDEV
94  constexpr
95  void resize(int size);
96 
105  CUDA_HOSTDEV
106  constexpr
107  Linspace<T> subinterval(int start, int stop) const;
108 
110  CUDA_HOSTDEV
111  constexpr
112  bool empty() const { return _size == 0; }
113 
118  template<typename U>
119  CUDA_HOSTDEV
120  constexpr
121  int search(U) const;
122 
123 private:
124  T _first = {};
125  T _spacing = {};
126  int _size = 0;
127 };
128 
129 template<typename T, typename U>
130 CUDA_HOSTDEV
131 constexpr
132 bool operator==(const Linspace<T> &, const Linspace<U> &);
133 
134 template<typename T, typename U>
135 CUDA_HOSTDEV
136 constexpr
137 bool operator!=(const Linspace<T> &, const Linspace<U> &);
138 
139 }}
140 
141 #define ISCE_CORE_LINSPACE_ICC
142 #include "Linspace.icc"
143 #undef ISCE_CORE_LINSPACE_ICC
CUDA_HOSTDEV constexpr int size() const
Number of samples.
Definition: Linspace.h:86
CUDA_HOSTDEV constexpr void resize(int size)
Change the number of samples in the sequence.
Definition: Linspace.icc:58
A uniformly-spaced sequence of values over some interval.
Definition: forward.h:28
CUDA_HOSTDEV constexpr T operator[](int pos) const
Return sample at the specified position.
Definition: Linspace.h:56
CUDA_HOSTDEV static constexpr Linspace< T > from_interval(T first, T last, int size)
Construct a Linspace over the closed interval [first, last].
Definition: Linspace.icc:13
CUDA_HOSTDEV constexpr T last() const
Last sample.
Definition: Linspace.h:71
CUDA_HOSTDEV constexpr T spacing() const
Sample spacing.
Definition: Linspace.h:76
CUDA_HOSTDEV constexpr void spacing(T spacing)
Set Sample Spacing.
Definition: Linspace.h:81
CUDA_HOSTDEV constexpr void first(T first)
Set first sample.
Definition: Linspace.h:66
CUDA_HOSTDEV constexpr T first() const
First sample.
Definition: Linspace.h:61
CUDA_HOSTDEV constexpr Linspace< T > subinterval(int start, int stop) const
Return a sub-Linspace over the half-open interval [start, stop).
Definition: Linspace.icc:68
CUDA_HOSTDEV constexpr int search(U) const
Return the position where the specified value would be inserted in the sequence in order to maintain ...
Definition: Linspace.icc:77
CUDA_HOSTDEV constexpr bool empty() const
Check if the sequence contains no samples.
Definition: Linspace.h:112

Generated for ISCE3.0 by doxygen 1.8.5.