25static_assert(
alignof(
RVec<Struct16B>) >=
alignof(Struct16B),
"wrong alignment for 16-byte aligned T");
26static_assert(
alignof(
RVec<Struct32B>) >=
alignof(Struct32B),
"wrong alignment for 32-byte aligned T");
27static_assert(
sizeof(
RVec<Struct16B>) >=
alignof(Struct16B),
"missing padding for 16-byte aligned T");
28static_assert(
sizeof(
RVec<Struct32B>) >=
alignof(Struct32B),
"missing padding for 32-byte aligned T");
29static_assert(
sizeof(
RVecN<void *, 0>) ==
sizeof(int32_t) * 2 +
sizeof(
void *),
"wasted space in RVec");
30static_assert(
sizeof(
RVecN<void *, 1>) ==
sizeof(int32_t) * 2 +
sizeof(
void *) * 2,
31 "wasted space in SmallVector size 1");
35 "wasted space in RVec");
39 std::string Reason =
"RVec unable to grow. Requested capacity (" + std::to_string(MinSize) +
40 ") is larger than maximum value for size type (" + std::to_string(
SizeTypeMax()) +
")";
41 throw std::length_error(Reason);
46 std::string Reason =
"RVec capacity unable to grow. Already at maximum size " + std::to_string(SizeTypeMax());
47 throw std::length_error(Reason);
55 if (MinSize > SizeTypeMax())
56 report_size_overflow(MinSize);
62 if (capacity() == SizeTypeMax())
63 report_at_maximum_capacity();
67 size_t NewCapacity = 2 * capacity() + 1;
68 NewCapacity = std::min(std::max(NewCapacity, MinSize), SizeTypeMax());
71 if (fBeginX == FirstEl || !this->Owns()) {
72 NewElts =
malloc(NewCapacity * TSize);
76 memcpy(NewElts, this->fBeginX,
size() * TSize);
79 NewElts =
realloc(this->fBeginX, NewCapacity * TSize);
83 this->fBeginX = NewElts;
84 this->fCapacity = NewCapacity;
87#if (_VECOPS_USE_EXTERN_TEMPLATES)
92#define RVEC_DECLARE_UNARY_OPERATOR(T, OP) \
93 template RVec<T> operator OP(const RVec<T> &);
95#define RVEC_DECLARE_BINARY_OPERATOR(T, OP) \
96 template auto operator OP(const RVec<T> &v, const T &y) -> RVec<decltype(v[0] OP y)>; \
97 template auto operator OP(const T &x, const RVec<T> &v) -> RVec<decltype(x OP v[0])>; \
98 template auto operator OP(const RVec<T> &v0, const RVec<T> &v1) -> RVec<decltype(v0[0] OP v1[0])>;
100#define RVEC_DECLARE_LOGICAL_OPERATOR(T, OP) \
101 template RVec<int> operator OP(const RVec<T> &, const T &); \
102 template RVec<int> operator OP(const T &, const RVec<T> &); \
103 template RVec<int> operator OP(const RVec<T> &, const RVec<T> &);
105#define RVEC_DECLARE_ASSIGN_OPERATOR(T, OP) \
106 template RVec<T> &operator OP(RVec<T> &, const T &); \
107 template RVec<T> &operator OP(RVec<T> &, const RVec<T> &);
109#define RVEC_DECLARE_FLOAT_TEMPLATE(T) \
110 template class RVec<T>; \
111 RVEC_DECLARE_UNARY_OPERATOR(T, +) \
112 RVEC_DECLARE_UNARY_OPERATOR(T, -) \
113 RVEC_DECLARE_UNARY_OPERATOR(T, !) \
114 RVEC_DECLARE_BINARY_OPERATOR(T, +) \
115 RVEC_DECLARE_BINARY_OPERATOR(T, -) \
116 RVEC_DECLARE_BINARY_OPERATOR(T, *) \
117 RVEC_DECLARE_BINARY_OPERATOR(T, /) \
118 RVEC_DECLARE_ASSIGN_OPERATOR(T, +=) \
119 RVEC_DECLARE_ASSIGN_OPERATOR(T, -=) \
120 RVEC_DECLARE_ASSIGN_OPERATOR(T, *=) \
121 RVEC_DECLARE_ASSIGN_OPERATOR(T, /=) \
122 RVEC_DECLARE_LOGICAL_OPERATOR(T, <) \
123 RVEC_DECLARE_LOGICAL_OPERATOR(T, >) \
124 RVEC_DECLARE_LOGICAL_OPERATOR(T, ==) \
125 RVEC_DECLARE_LOGICAL_OPERATOR(T, !=) \
126 RVEC_DECLARE_LOGICAL_OPERATOR(T, <=) \
127 RVEC_DECLARE_LOGICAL_OPERATOR(T, >=) \
128 RVEC_DECLARE_LOGICAL_OPERATOR(T, &&) \
129 RVEC_DECLARE_LOGICAL_OPERATOR(T, ||)
131#define RVEC_DECLARE_INTEGER_TEMPLATE(T) \
132 template class RVec<T>; \
133 RVEC_DECLARE_UNARY_OPERATOR(T, +) \
134 RVEC_DECLARE_UNARY_OPERATOR(T, -) \
135 RVEC_DECLARE_UNARY_OPERATOR(T, ~) \
136 RVEC_DECLARE_UNARY_OPERATOR(T, !) \
137 RVEC_DECLARE_BINARY_OPERATOR(T, +) \
138 RVEC_DECLARE_BINARY_OPERATOR(T, -) \
139 RVEC_DECLARE_BINARY_OPERATOR(T, *) \
140 RVEC_DECLARE_BINARY_OPERATOR(T, /) \
141 RVEC_DECLARE_BINARY_OPERATOR(T, %) \
142 RVEC_DECLARE_BINARY_OPERATOR(T, &) \
143 RVEC_DECLARE_BINARY_OPERATOR(T, |) \
144 RVEC_DECLARE_BINARY_OPERATOR(T, ^) \
145 RVEC_DECLARE_ASSIGN_OPERATOR(T, +=) \
146 RVEC_DECLARE_ASSIGN_OPERATOR(T, -=) \
147 RVEC_DECLARE_ASSIGN_OPERATOR(T, *=) \
148 RVEC_DECLARE_ASSIGN_OPERATOR(T, /=) \
149 RVEC_DECLARE_ASSIGN_OPERATOR(T, %=) \
150 RVEC_DECLARE_ASSIGN_OPERATOR(T, &=) \
151 RVEC_DECLARE_ASSIGN_OPERATOR(T, |=) \
152 RVEC_DECLARE_ASSIGN_OPERATOR(T, ^=) \
153 RVEC_DECLARE_ASSIGN_OPERATOR(T, >>=) \
154 RVEC_DECLARE_ASSIGN_OPERATOR(T, <<=) \
155 RVEC_DECLARE_LOGICAL_OPERATOR(T, <) \
156 RVEC_DECLARE_LOGICAL_OPERATOR(T, >) \
157 RVEC_DECLARE_LOGICAL_OPERATOR(T, ==) \
158 RVEC_DECLARE_LOGICAL_OPERATOR(T, !=) \
159 RVEC_DECLARE_LOGICAL_OPERATOR(T, <=) \
160 RVEC_DECLARE_LOGICAL_OPERATOR(T, >=) \
161 RVEC_DECLARE_LOGICAL_OPERATOR(T, &&) \
162 RVEC_DECLARE_LOGICAL_OPERATOR(T, ||)
164RVEC_DECLARE_INTEGER_TEMPLATE(
char)
165RVEC_DECLARE_INTEGER_TEMPLATE(
short)
166RVEC_DECLARE_INTEGER_TEMPLATE(
int)
167RVEC_DECLARE_INTEGER_TEMPLATE(
long)
168RVEC_DECLARE_INTEGER_TEMPLATE(
long long)
170RVEC_DECLARE_INTEGER_TEMPLATE(
unsigned char)
171RVEC_DECLARE_INTEGER_TEMPLATE(
unsigned short)
172RVEC_DECLARE_INTEGER_TEMPLATE(
unsigned int)
173RVEC_DECLARE_INTEGER_TEMPLATE(
unsigned long)
174RVEC_DECLARE_INTEGER_TEMPLATE(
unsigned long long)
176RVEC_DECLARE_FLOAT_TEMPLATE(
float)
177RVEC_DECLARE_FLOAT_TEMPLATE(
double)
179#define RVEC_DECLARE_UNARY_FUNCTION(T, NAME, FUNC) \
180 template RVec<PromoteType<T>> NAME(const RVec<T> &);
182#define RVEC_DECLARE_STD_UNARY_FUNCTION(T, F) RVEC_DECLARE_UNARY_FUNCTION(T, F, ::std::F)
184#define RVEC_DECLARE_BINARY_FUNCTION(T0, T1, NAME, FUNC) \
185 template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v, const T1 &y); \
186 template RVec<PromoteTypes<T0, T1>> NAME(const T0 &x, const RVec<T1> &v); \
187 template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v0, const RVec<T1> &v1);
189#define RVEC_DECLARE_STD_BINARY_FUNCTION(T, F) RVEC_DECLARE_BINARY_FUNCTION(T, T, F, ::std::F)
191#define RVEC_DECLARE_STD_FUNCTIONS(T) \
192 RVEC_DECLARE_STD_UNARY_FUNCTION(T, abs) \
193 RVEC_DECLARE_STD_BINARY_FUNCTION(T, fdim) \
194 RVEC_DECLARE_STD_BINARY_FUNCTION(T, fmod) \
195 RVEC_DECLARE_STD_BINARY_FUNCTION(T, remainder) \
196 RVEC_DECLARE_STD_UNARY_FUNCTION(T, exp) \
197 RVEC_DECLARE_STD_UNARY_FUNCTION(T, exp2) \
198 RVEC_DECLARE_STD_UNARY_FUNCTION(T, expm1) \
199 RVEC_DECLARE_STD_UNARY_FUNCTION(T, log) \
200 RVEC_DECLARE_STD_UNARY_FUNCTION(T, log10) \
201 RVEC_DECLARE_STD_UNARY_FUNCTION(T, log2) \
202 RVEC_DECLARE_STD_UNARY_FUNCTION(T, log1p) \
203 RVEC_DECLARE_STD_BINARY_FUNCTION(T, pow) \
204 RVEC_DECLARE_STD_UNARY_FUNCTION(T, sqrt) \
205 RVEC_DECLARE_STD_UNARY_FUNCTION(T, cbrt) \
206 RVEC_DECLARE_STD_BINARY_FUNCTION(T, hypot) \
207 RVEC_DECLARE_STD_UNARY_FUNCTION(T, sin) \
208 RVEC_DECLARE_STD_UNARY_FUNCTION(T, cos) \
209 RVEC_DECLARE_STD_UNARY_FUNCTION(T, tan) \
210 RVEC_DECLARE_STD_UNARY_FUNCTION(T, asin) \
211 RVEC_DECLARE_STD_UNARY_FUNCTION(T, acos) \
212 RVEC_DECLARE_STD_UNARY_FUNCTION(T, atan) \
213 RVEC_DECLARE_STD_BINARY_FUNCTION(T, atan2) \
214 RVEC_DECLARE_STD_UNARY_FUNCTION(T, sinh) \
215 RVEC_DECLARE_STD_UNARY_FUNCTION(T, cosh) \
216 RVEC_DECLARE_STD_UNARY_FUNCTION(T, tanh) \
217 RVEC_DECLARE_STD_UNARY_FUNCTION(T, asinh) \
218 RVEC_DECLARE_STD_UNARY_FUNCTION(T, acosh) \
219 RVEC_DECLARE_STD_UNARY_FUNCTION(T, atanh) \
220 RVEC_DECLARE_STD_UNARY_FUNCTION(T, floor) \
221 RVEC_DECLARE_STD_UNARY_FUNCTION(T, ceil) \
222 RVEC_DECLARE_STD_UNARY_FUNCTION(T, trunc) \
223 RVEC_DECLARE_STD_UNARY_FUNCTION(T, round) \
224 RVEC_DECLARE_STD_UNARY_FUNCTION(T, lround) \
225 RVEC_DECLARE_STD_UNARY_FUNCTION(T, llround) \
226 RVEC_DECLARE_STD_UNARY_FUNCTION(T, erf) \
227 RVEC_DECLARE_STD_UNARY_FUNCTION(T, erfc) \
228 RVEC_DECLARE_STD_UNARY_FUNCTION(T, lgamma) \
229 RVEC_DECLARE_STD_UNARY_FUNCTION(T, tgamma) \
231RVEC_DECLARE_STD_FUNCTIONS(
float)
232RVEC_DECLARE_STD_FUNCTIONS(
double)
233#undef RVEC_DECLARE_STD_UNARY_FUNCTION
234#undef RVEC_DECLARE_STD_BINARY_FUNCTION
235#undef RVEC_DECLARE_STD_UNARY_FUNCTIONS
239#define RVEC_DECLARE_VDT_UNARY_FUNCTION(T, F) \
240 RVEC_DECLARE_UNARY_FUNCTION(T, F, vdt::F)
242RVEC_DECLARE_VDT_UNARY_FUNCTION(
float, fast_expf)
243RVEC_DECLARE_VDT_UNARY_FUNCTION(
float, fast_logf)
244RVEC_DECLARE_VDT_UNARY_FUNCTION(
float, fast_sinf)
245RVEC_DECLARE_VDT_UNARY_FUNCTION(
float, fast_cosf)
246RVEC_DECLARE_VDT_UNARY_FUNCTION(
float, fast_tanf)
247RVEC_DECLARE_VDT_UNARY_FUNCTION(
float, fast_asinf)
248RVEC_DECLARE_VDT_UNARY_FUNCTION(
float, fast_acosf)
249RVEC_DECLARE_VDT_UNARY_FUNCTION(
float, fast_atanf)
251RVEC_DECLARE_VDT_UNARY_FUNCTION(
double, fast_exp)
252RVEC_DECLARE_VDT_UNARY_FUNCTION(
double, fast_log)
253RVEC_DECLARE_VDT_UNARY_FUNCTION(
double, fast_sin)
254RVEC_DECLARE_VDT_UNARY_FUNCTION(
double, fast_cos)
255RVEC_DECLARE_VDT_UNARY_FUNCTION(
double, fast_tan)
256RVEC_DECLARE_VDT_UNARY_FUNCTION(
double, fast_asin)
257RVEC_DECLARE_VDT_UNARY_FUNCTION(
double, fast_acos)
258RVEC_DECLARE_VDT_UNARY_FUNCTION(
double, fast_atan)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
static constexpr size_t SizeTypeMax()
The maximum value of the Size_T used.
static void report_size_overflow(size_t MinSize)
Report that MinSize doesn't fit into this vector's size type.
static void report_at_maximum_capacity()
Report that this vector is already at maximum capacity.
void grow_pod(void *FirstEl, size_t MinSize, size_t TSize)
This is an implementation of the grow() method which only works on POD-like data types and is out of ...
A "std::vector"-like collection of values implementing handy operation to analyse them.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
The size of the inline storage of an RVec.