trase
Vector.hpp
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of trase.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
37 
38 #ifndef VECTOR_H_
39 #define VECTOR_H_
40 
41 #include <algorithm>
42 #include <array>
43 #include <cmath>
44 #include <functional>
45 #include <iostream>
46 #include <iterator>
47 #include <numeric>
48 
49 namespace trase {
50 
59 template <typename T, int N> class Vector {
60 public:
61  using value_type = T;
62 
63  using iter = typename std::array<T, N>::iterator;
64  using const_iter = typename std::array<T, N>::const_iterator;
65  using reverse_iter = typename std::array<T, N>::reverse_iterator;
66  using const_reverse_iter = typename std::array<T, N>::const_reverse_iterator;
67 
68  const static int size = N;
69 
71  Vector() = default;
72 
77  explicit Vector(T arg1) { std::fill(begin(), end(), arg1); }
78 
83  Vector(T arg1, T arg2) {
84  static_assert(N == 2, "Vector must have 2 elements");
85  mem[0] = arg1;
86  mem[1] = arg2;
87  }
88 
94  Vector(T arg1, T arg2, T arg3) {
95  static_assert(N == 3, "Vector must have 3 elements");
96  mem[0] = arg1;
97  mem[1] = arg2;
98  mem[2] = arg3;
99  }
100 
107  Vector(T arg1, T arg2, T arg3, T arg4) {
108  static_assert(N == 4, "Vector must have 4 elements");
109  mem[0] = arg1;
110  mem[1] = arg2;
111  mem[2] = arg3;
112  mem[3] = arg4;
113  }
114 
122  Vector(T arg1, T arg2, T arg3, T arg4, T arg5) {
123  static_assert(N == 5, "Vector must have 5 elements");
124  mem[0] = arg1;
125  mem[1] = arg2;
126  mem[2] = arg3;
127  mem[3] = arg4;
128  mem[4] = arg5;
129  }
130 
136  template <typename T2> explicit Vector(const Vector<T2, N> &arg) {
137  std::copy(arg.begin(), arg.end(), begin());
138  }
139 
140  // Iterators
141  iter begin() noexcept { return iter(mem.begin()); }
142  const_iter begin() const noexcept { return const_iter(mem.begin()); }
143  iter end() noexcept { return iter(mem.end()); }
144  const_iter end() const noexcept { return const_iter(mem.end()); }
145  reverse_iter rbegin() noexcept { return reverse_iter(end()); }
146  const_reverse_iter rbegin() const noexcept {
147  return const_reverse_iter(end());
148  }
149  reverse_iter rend() noexcept { return reverse_iter(begin()); }
150  const_reverse_iter rend() const noexcept {
151  return const_reverse_iter(begin());
152  }
153  const_iter cbegin() const noexcept { return const_iter(mem.begin()); }
154  const_iter cend() const noexcept { return const_iter(mem.end()); }
155  const_reverse_iter crbegin() const noexcept {
156  return const_reverse_iter(end());
157  }
158  const_reverse_iter crend() const noexcept {
159  return const_reverse_iter(begin());
160  }
161 
165  static Vector Zero() {
166  Vector ret;
167  std::fill(ret.mem.begin(), ret.mem.end(), 0);
168  return ret;
169  }
170 
174  static Vector Constant(const T &c) {
175  Vector ret;
176  std::fill(ret.mem.begin(), ret.mem.end(), c);
177  return ret;
178  }
179 
185  const T &operator[](const int n) const noexcept { return mem[n]; }
186 
192  T &operator[](const int n) noexcept { return mem[n]; }
193 
197  T inner_product(const Vector<T, N> &arg) const noexcept {
198  return std::inner_product(begin(), end(), arg.begin(), static_cast<T>(0));
199  }
200 
206  T dot(const Vector<T, N> &arg) const noexcept { return inner_product(arg); }
207 
212  template <typename T2> Vector<T2, N> cast() const noexcept {
213  Vector<T2, N> ret;
214  std::transform(begin(), end(), ret.begin(),
215  [](const T &a) { return static_cast<T2>(a); });
216  return ret;
217  }
218 
221  T squaredNorm() const noexcept { return (*this).inner_product(*this); }
222 
225  double norm() const noexcept { return std::sqrt(squaredNorm()); }
226 
229  T inf_norm() const noexcept {
230  T max = *std::max_element(begin(), end(), [](const T &a, const T &b) {
231  return std::fabs(a) < std::fabs(b);
232  });
233  return max >= static_cast<T>(0) ? max : -max;
234  }
235 
239  template <typename EXP_T>
240  Vector<T, N> pow(const EXP_T exponent) const noexcept {
241  Vector<T, N> ret;
242  std::transform(begin(), end(), ret.begin(), [&exponent](const T &a) {
243  return static_cast<T>(std::pow(a, exponent));
244  });
245  return ret;
246  }
247 
250  void normalize() noexcept {
251  const double n = norm();
252  std::transform(begin(), end(), begin(),
253  [&n](const T &a) { return static_cast<T>(a / n); });
254  }
255 
258  bool all() const noexcept {
259  return std::all_of(begin(), end(),
260  [](const T &a) { return static_cast<bool>(a); });
261  }
262 
265  bool any() const noexcept {
266  return std::any_of(begin(), end(),
267  [](const T &a) { return static_cast<bool>(a); });
268  }
269 
272  bool none() const noexcept {
273  return std::none_of(begin(), end(),
274  [](const T &a) { return static_cast<bool>(a); });
275  }
276 
279  T minCoeff() const noexcept { return *std::min_element(begin(), end()); }
280 
283  T maxCoeff() const noexcept { return *std::max_element(begin(), end()); }
284 
286  T prod() const noexcept {
287  return std::accumulate(begin(), end(), static_cast<T>(1),
288  std::multiplies<T>());
289  }
290 
292  T sum() const noexcept {
293  return std::accumulate(begin(), end(), static_cast<T>(0));
294  }
295 
297  T *data() noexcept { return mem.data(); }
298  const T *data() const noexcept { return mem.data(); }
299 
300  /*
301  * Compound assignment operators += -= *= /=
302  *
303  * First four are this-Vector elementwise operations (this[i] op other[i] for
304  * all i). Second four are this-scalar elementwise operations (this[i] op k
305  * for all i).
306  */
307 
310  std::transform(begin(), end(), a.begin(), begin(), std::plus<T>());
311  return *this;
312  }
313 
316  std::transform(begin(), end(), a.begin(), begin(), std::minus<T>());
317  return *this;
318  }
319 
322  std::transform(begin(), end(), a.begin(), begin(), std::multiplies<T>());
323  return *this;
324  }
325 
328  std::transform(begin(), end(), a.begin(), begin(), std::divides<T>());
329  return *this;
330  }
331 
333  Vector<T, N> &operator+=(const T &k) {
334  std::transform(begin(), end(), begin(),
335  std::bind(std::plus<T>(), std::placeholders::_1, k));
336  return *this;
337  }
338 
340  Vector<T, N> &operator-=(const T &k) {
341  std::transform(begin(), end(), begin(),
342  std::bind(std::minus<T>(), std::placeholders::_1, k));
343  return *this;
344  }
345 
347  Vector<T, N> &operator*=(const T &k) {
348  std::transform(begin(), end(), begin(),
349  std::bind(std::multiplies<T>(), std::placeholders::_1, k));
350  return *this;
351  }
352 
354  Vector<T, N> &operator/=(const T &k) {
355  std::transform(begin(), end(), begin(),
356  std::bind(std::divides<T>(), std::placeholders::_1, k));
357  return *this;
358  }
359 
360 private:
361  std::array<T, N> mem;
362 };
363 
365 template <typename T, int N, typename EXP_T>
366 Vector<T, N> pow(const Vector<T, N> &arg, EXP_T exponent) noexcept {
367  return arg.pow(exponent);
368 }
369 
371 template <typename T, int N>
372 Vector<T, N> operator-(const Vector<T, N> &a) noexcept {
373  Vector<T, N> ret;
374  std::transform(a.begin(), a.end(), ret.begin(), std::negate<T>());
375  return ret;
376 }
377 
378 /*
379  * Binary operations.
380  *
381  * First four are Vector-Vector elementwise operations (V[i] op U[i] for all i).
382  * Second four are scalar-Vector elementwise operations (k op V[i] for all i).
383  * Third four are Vector-scalar elementwise operations (V[i] op k for all i).
384  */
385 
387 template <typename T, int N>
388 Vector<T, N> operator+(const Vector<T, N> &a, const Vector<T, N> &b) noexcept {
389  Vector<T, N> ret;
390  std::transform(a.begin(), a.end(), b.begin(), ret.begin(), std::plus<T>());
391  return ret;
392 }
393 
395 template <typename T, int N>
396 Vector<T, N> operator-(const Vector<T, N> &a, const Vector<T, N> &b) noexcept {
397  Vector<T, N> ret;
398  std::transform(a.begin(), a.end(), b.begin(), ret.begin(), std::minus<T>());
399  return ret;
400 }
401 
403 template <typename T, int N>
404 Vector<T, N> operator*(const Vector<T, N> &a, const Vector<T, N> &b) noexcept {
405  Vector<T, N> ret;
406  std::transform(a.begin(), a.end(), b.begin(), ret.begin(),
407  std::multiplies<T>());
408  return ret;
409 }
410 
412 template <typename T, int N>
413 Vector<T, N> operator/(const Vector<T, N> &a, const Vector<T, N> &b) noexcept {
414  Vector<T, N> ret;
415  std::transform(a.begin(), a.end(), b.begin(), ret.begin(), std::divides<T>());
416  return ret;
417 }
418 
420 template <typename T, int N>
421 Vector<T, N> operator+(const T &a, const Vector<T, N> &b) noexcept {
422  Vector<T, N> ret;
423  std::transform(b.begin(), b.end(), ret.begin(),
424  std::bind(std::plus<T>(), a, std::placeholders::_1));
425  return ret;
426 }
427 
429 template <typename T, int N>
430 Vector<T, N> operator-(const T &a, const Vector<T, N> &b) noexcept {
431  Vector<T, N> ret;
432  std::transform(b.begin(), b.end(), ret.begin(),
433  std::bind(std::minus<T>(), a, std::placeholders::_1));
434  return ret;
435 }
436 
438 template <typename T, int N>
439 Vector<T, N> operator*(const T &a, const Vector<T, N> &b) noexcept {
440  Vector<T, N> ret;
441  std::transform(b.begin(), b.end(), ret.begin(),
442  std::bind(std::multiplies<T>(), a, std::placeholders::_1));
443  return ret;
444 }
445 
447 template <typename T, int N>
448 Vector<T, N> operator/(const T &a, const Vector<T, N> &b) noexcept {
449  Vector<T, N> ret;
450  std::transform(b.begin(), b.end(), ret.begin(),
451  std::bind(std::divides<T>(), a, std::placeholders::_1));
452  return ret;
453 }
454 
456 template <typename T, int N>
457 Vector<T, N> operator+(const Vector<T, N> &b, const T &a) noexcept {
458  Vector<T, N> ret;
459  std::transform(b.begin(), b.end(), ret.begin(),
460  std::bind(std::plus<T>(), std::placeholders::_1, a));
461  return ret;
462 }
463 
465 template <typename T, int N>
466 Vector<T, N> operator-(const Vector<T, N> &b, const T &a) noexcept {
467  Vector<T, N> ret;
468  std::transform(b.begin(), b.end(), ret.begin(),
469  std::bind(std::minus<T>(), std::placeholders::_1, a));
470  return ret;
471 }
472 
474 template <typename T, int N>
475 Vector<T, N> operator*(const Vector<T, N> &b, const T &a) noexcept {
476  Vector<T, N> ret;
477  std::transform(b.begin(), b.end(), ret.begin(),
478  std::bind(std::multiplies<T>(), std::placeholders::_1, a));
479  return ret;
480 }
481 
483 template <typename T, int N>
484 Vector<T, N> operator/(const Vector<T, N> &b, const T &a) noexcept {
485  Vector<T, N> ret;
486  std::transform(b.begin(), b.end(), ret.begin(),
487  std::bind(std::divides<T>(), std::placeholders::_1, a));
488  return ret;
489 }
490 
491 // Comparison operators: == != < > <= >=
492 
493 template <typename T, int N>
494 Vector<bool, N> operator==(const Vector<T, N> &a,
495  const Vector<T, N> &b) noexcept {
496  Vector<bool, N> ret;
497  std::transform(a.begin(), a.end(), b.begin(), ret.begin(),
498  std::equal_to<T>());
499  return ret;
500 }
501 
502 template <typename T, int N>
503 Vector<bool, N> operator!=(const Vector<T, N> &a,
504  const Vector<T, N> &b) noexcept {
505  Vector<bool, N> ret;
506  std::transform(a.begin(), a.end(), b.begin(), ret.begin(),
507  std::not_equal_to<T>());
508  return ret;
509 }
510 
511 template <typename T, int N>
512 Vector<bool, N> operator<(const Vector<T, N> &a,
513  const Vector<T, N> &b) noexcept {
514  Vector<bool, N> ret;
515  std::transform(a.begin(), a.end(), b.begin(), ret.begin(), std::less<T>());
516  return ret;
517 }
518 
519 template <typename T, int N>
520 Vector<bool, N> operator>(const Vector<T, N> &a,
521  const Vector<T, N> &b) noexcept {
522  Vector<bool, N> ret;
523  std::transform(a.begin(), a.end(), b.begin(), ret.begin(), std::greater<T>());
524  return ret;
525 }
526 
527 template <typename T, int N>
528 Vector<bool, N> operator<=(const Vector<T, N> &a,
529  const Vector<T, N> &b) noexcept {
530  Vector<bool, N> ret;
531  std::transform(a.begin(), a.end(), b.begin(), ret.begin(),
532  std::less_equal<T>());
533  return ret;
534 }
535 
536 template <typename T, int N>
537 Vector<bool, N> operator>=(const Vector<T, N> &a,
538  const Vector<T, N> &b) noexcept {
539  Vector<bool, N> ret;
540  std::transform(a.begin(), a.end(), b.begin(), ret.begin(),
541  std::greater_equal<T>());
542  return ret;
543 }
544 
546 template <typename T, int N>
547 Vector<T, N> floor(const Vector<T, N> &a) noexcept {
548  Vector<T, N> ret;
549  std::transform(a.begin(), a.end(), ret.begin(),
550  [](const T &a) { return static_cast<T>(std::floor(a)); });
551  return ret;
552 }
553 
555 template <typename T, int N> Vector<T, N> ceil(const Vector<T, N> &a) noexcept {
556  Vector<T, N> ret;
557  std::transform(a.begin(), a.end(), ret.begin(),
558  [](const T &a) { return static_cast<T>(std::ceil(a)); });
559  return ret;
560 }
561 
563 template <typename T, int N>
564 Vector<T, N> round(const Vector<T, N> &a) noexcept {
565  Vector<T, N> ret;
566  std::transform(a.begin(), a.end(), ret.begin(),
567  [](const T &a) { return static_cast<T>(std::round(a)); });
568  return ret;
569 }
570 
572 template <typename T, int N> Vector<T, N> abs(const Vector<T, N> &a) noexcept {
573  Vector<T, N> ret;
574  std::transform(a.begin(), a.end(), ret.begin(),
575  [](const T &a) { return static_cast<T>(std::fabs(a)); });
576  return ret;
577 }
578 
580 template <typename T, int N> Vector<T, N> abs2(const Vector<T, N> &a) noexcept {
581  Vector<T, N> ret;
582  std::transform(a.begin(), a.end(), ret.begin(),
583  [](const T &a) { return a * a; });
584  return ret;
585 }
586 
588 template <typename T>
589 Vector<T, 3> cross(const Vector<T, 3> &arg1, const Vector<T, 3> &arg2) {
590  Vector<T, 3> ret;
591  ret[0] = arg1[1] * arg2[2] - arg1[2] * arg2[1];
592  ret[1] = -arg1[0] * arg2[2] + arg1[2] * arg2[0];
593  ret[2] = arg1[0] * arg2[1] - arg1[1] * arg2[0];
594  return ret;
595 }
596 
598 template <typename T, int N>
599 Vector<T, N> round_off(const Vector<T, N> &arg, int n) {
600  Vector<T, N> ret;
601  std::transform(arg.begin(), arg.end(), ret.begin(), [&n](const T &a) {
602  // Number of digits to the left of the decimal point
603  const int num_digits = 1 + static_cast<int>(std::log10(a));
604  //\todo: this does not work for all but small integers!
605  const auto d = static_cast<T>(std::pow(10.0, n - num_digits));
606  return static_cast<T>(std::floor(a * d + static_cast<T>(0.5)) / d);
607  });
608  return ret;
609 }
610 
611 template <typename T, int N>
612 Vector<bool, N> approx_equal(const Vector<T, N> &a, const Vector<T, N> &b,
613  const T epsilon) {
614  return abs(b - a) <= Vector<T, N>::Constant(epsilon);
615 }
616 
618 template <typename T, int N>
619 std::ostream &operator<<(std::ostream &out, const Vector<T, N> &v) {
620  out << '(' << v[0];
621  for (auto it = std::next(v.cbegin()); it != v.cend(); ++it) {
622  out << ',' << *it;
623  }
624  return out << ')';
625 }
626 
628 template <typename T, int N>
629 std::istream &operator>>(std::istream &out, Vector<T, N> &v) {
630  out.get();
631  for (T &x : v) {
632  out >> x;
633  out.get();
634  }
635  return out;
636 }
637 
639 using vint2_t = Vector<int, 2>;
640 
642 struct vint2_hash {
643  std::size_t operator()(const vint2_t &s) const noexcept {
644  // Cantor's enumeration of pairs
645  return ((s[0] + s[1]) * (s[0] + s[1] + 1) / 2) + s[1];
646  }
647 };
648 
650 struct vint2_equal {
651  bool operator()(const vint2_t &a, const vint2_t &b) const noexcept {
652  return a[0] == b[0] && a[1] == b[1];
653  }
654 };
655 
656 } // namespace trase
657 
658 #endif /* VECTOR_H_ */
bool any() const noexcept
collapse vector to bool using std::any_of
Definition: Vector.hpp:265
T prod() const noexcept
returns the product of every element in the vector
Definition: Vector.hpp:286
Vector< T, N > & operator/=(const Vector< T, N > &a)
this-Vector compound divides operator
Definition: Vector.hpp:327
T maxCoeff() const noexcept
find the maximum element of the vector
Definition: Vector.hpp:283
static Vector Zero()
Zero Vector.
Definition: Vector.hpp:165
const T & operator[](const int n) const noexcept
const Index operator
Definition: Vector.hpp:185
Vector(const Vector< T2, N > &arg)
Constructs a vector with another vector of different type.
Definition: Vector.hpp:136
Vector(T arg1, T arg2, T arg3)
Constructs an vector with initial values.
Definition: Vector.hpp:94
T * data() noexcept
returns the raw memory array containing the data for the vector
Definition: Vector.hpp:297
Vector< T, N > & operator-=(const T &k)
this-scalar compound minus operator
Definition: Vector.hpp:340
Vector< T, N > round(const Vector< T, N > &a) noexcept
element-wise round rounding function for Vector class
Definition: Vector.hpp:564
Vector< T, N > operator-(const Vector< T, N > &a) noexcept
unary - (minus) operator for Vector class
Definition: Vector.hpp:372
Vector< T, N > operator*(const Vector< T, N > &a, const Vector< T, N > &b) noexcept
binary * (multiples) operator for two Vectors
Definition: Vector.hpp:404
Vector< T, N > & operator*=(const Vector< T, N > &a)
this-Vector compound multiples operator
Definition: Vector.hpp:321
bool all() const noexcept
collapse vector to bool using std::all_of
Definition: Vector.hpp:258
Vector< T, N > round_off(const Vector< T, N > &arg, int n)
round off to n significant digits
Definition: Vector.hpp:599
Vector< T, N > & operator/=(const T &k)
this-scalar compound divides operator
Definition: Vector.hpp:354
An N-dimensional vector class.
Definition: Vector.hpp:59
static Vector Constant(const T &c)
Constant Vector.
Definition: Vector.hpp:174
Vector< T, N > & operator+=(const Vector< T, N > &a)
this-Vector compound plus operator
Definition: Vector.hpp:309
Vector< T, N > & operator-=(const Vector< T, N > &a)
this-Vector compound minus operator
Definition: Vector.hpp:315
T squaredNorm() const noexcept
squared norm
Definition: Vector.hpp:221
Vector< T, N > ceil(const Vector< T, N > &a) noexcept
element-wise ceil rounding function for Vector class
Definition: Vector.hpp:555
double norm() const noexcept
2-norm
Definition: Vector.hpp:225
T minCoeff() const noexcept
find the minimum element of the vector
Definition: Vector.hpp:279
T & operator[](const int n) noexcept
Index operator.
Definition: Vector.hpp:192
Vector< T, N > abs2(const Vector< T, N > &a) noexcept
element-wise e_i*e_i function for Vector class
Definition: Vector.hpp:580
Vector(T arg1)
Constructs an vector with initial values.
Definition: Vector.hpp:77
bool none() const noexcept
collapse vector to bool using std::none_of
Definition: Vector.hpp:272
Vector< T, N > abs(const Vector< T, N > &a) noexcept
element-wise absolute value function for Vector class
Definition: Vector.hpp:572
void normalize() noexcept
normalise vector so that its length (2-norm) equals one.
Definition: Vector.hpp:250
T inf_norm() const noexcept
inf-norm
Definition: Vector.hpp:229
Vector< T, N > pow(const EXP_T exponent) const noexcept
element-wise pow function
Definition: Vector.hpp:240
std::istream & operator>>(std::istream &out, Vector< T, N > &v)
stream input operator for Vector class
Definition: Vector.hpp:629
Vector< T, N > & operator+=(const T &k)
this-scalar compound plus operator
Definition: Vector.hpp:333
Vector< T, N > operator+(const Vector< T, N > &a, const Vector< T, N > &b) noexcept
binary + (plus) operator for two Vectors
Definition: Vector.hpp:388
Vector< T, 3 > cross(const Vector< T, 3 > &arg1, const Vector< T, 3 > &arg2)
cross-product function for 3D vectors
Definition: Vector.hpp:589
T dot(const Vector< T, N > &arg) const noexcept
dot product
Definition: Vector.hpp:206
Vector< T2, N > cast() const noexcept
change vector type
Definition: Vector.hpp:212
T sum() const noexcept
returns the sum of every element in the vector
Definition: Vector.hpp:292
T inner_product(const Vector< T, N > &arg) const noexcept
inner product
Definition: Vector.hpp:197
Vector< T, N > & operator*=(const T &k)
this-scalar compound multiples operator
Definition: Vector.hpp:347
Vector< T, N > floor(const Vector< T, N > &a) noexcept
element-wise floor rounding function for Vector class
Definition: Vector.hpp:547
Vector< T, N > operator/(const Vector< T, N > &a, const Vector< T, N > &b) noexcept
binary / (divides) operator for two Vectors
Definition: Vector.hpp:413
hash function for an STL map of 2d int vectors
Definition: Vector.hpp:642
Definition: Backend.cpp:39
Vector(T arg1, T arg2)
Constructs a vector with initial values.
Definition: Vector.hpp:83
Vector(T arg1, T arg2, T arg3, T arg4, T arg5)
Constructs an vector with initial values.
Definition: Vector.hpp:122
equality function for an STL map of 2d int vectors
Definition: Vector.hpp:650
Vector(T arg1, T arg2, T arg3, T arg4)
Constructs an vector with initial values.
Definition: Vector.hpp:107
Vector()=default
Constructs an vector and allocates memory.