Chemical Data Processing Library C++ API - Version 1.4.0
Vector.hpp
Go to the documentation of this file.
1 /*
2  * Vector.hpp
3  *
4  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
27 #ifndef CDPL_MATH_VECTOR_HPP
28 #define CDPL_MATH_VECTOR_HPP
29 
30 #include <cstddef>
31 #include <algorithm>
32 #include <vector>
33 #include <limits>
34 #include <utility>
35 #include <unordered_map>
36 #include <type_traits>
37 #include <initializer_list>
38 #include <memory>
39 
40 #include "CDPL/Math/Check.hpp"
44 #include "CDPL/Math/Functional.hpp"
45 #include "CDPL/Math/TypeTraits.hpp"
47 #include "CDPL/Base/Exceptions.hpp"
48 
49 
50 namespace CDPL
51 {
52 
53  namespace Math
54  {
55 
60  template <typename V>
61  class VectorReference : public VectorExpression<VectorReference<V> >
62  {
63 
65 
66  public:
70  typedef V VectorType;
71 
75  typedef typename V::ValueType ValueType;
76 
80  typedef typename std::conditional<std::is_const<V>::value,
81  typename V::ConstReference,
82  typename V::Reference>::type Reference;
83 
87  typedef typename V::ConstReference ConstReference;
88 
92  typedef typename V::SizeType SizeType;
93 
97  typedef typename V::DifferenceType DifferenceType;
98 
103 
107  typedef const SelfType ConstClosureType;
108 
114  data(v) {}
115 
122  {
123  return data[i];
124  }
125 
132  {
133  return data[i];
134  }
135 
142  {
143  return data(i);
144  }
145 
152  {
153  return data(i);
154  }
155 
161  {
162  return data.getSize();
163  }
164 
170  {
171  return data.getMaxSize();
172  }
173 
178  bool isEmpty() const
179  {
180  return data.isEmpty();
181  }
182 
187  const VectorType& getData() const
188  {
189  return data;
190  }
191 
197  {
198  return data;
199  }
200 
207  {
208  data.operator=(r.data);
209  return *this;
210  }
211 
218  template <typename E>
220  {
221  data.operator=(e);
222  return *this;
223  }
224 
231  template <typename E>
233  {
234  data.operator+=(e);
235  return *this;
236  }
237 
244  template <typename E>
246  {
247  data.operator-=(e);
248  return *this;
249  }
250 
257  template <typename T>
258  typename std::enable_if<IsScalar<T>::value, VectorReference>::type& operator*=(const T& t)
259  {
260  data.operator*=(t);
261  return *this;
262  }
263 
270  template <typename T>
271  typename std::enable_if<IsScalar<T>::value, VectorReference>::type& operator/=(const T& t)
272  {
273  data.operator/=(t);
274  return *this;
275  }
276 
283  template <typename E>
285  {
286  data.assign(e);
287  return *this;
288  }
289 
296  template <typename E>
298  {
299  data.plusAssign(e);
300  return *this;
301  }
302 
309  template <typename E>
311  {
312  data.minusAssign(e);
313  return *this;
314  }
315 
321  {
322  data.swap(r.data);
323  }
324 
330  friend void swap(VectorReference& r1, VectorReference& r2)
331  {
332  r1.swap(r2);
333  }
334 
335  private:
336  VectorType& data;
337  };
338 
339  template <typename T, typename A>
340  class Vector;
341 
346  template <typename T>
347  class InitListVector : public VectorContainer<InitListVector<T> >
348  {
349 
350  public:
352 
356  typedef std::initializer_list<T> InitializerListType;
357 
361  typedef typename InitializerListType::value_type ValueType;
362 
366  typedef typename InitializerListType::const_reference ConstReference;
367 
371  typedef typename InitializerListType::reference Reference;
372 
376  typedef typename InitializerListType::size_type SizeType;
377 
381  typedef typename std::ptrdiff_t DifferenceType;
382 
387 
391  typedef const SelfType ConstClosureType;
392 
397 
403  list(l) {}
404 
412  {
413  return this->operator()(i);
414  }
415 
423  {
424  return this->operator()(i);
425  }
426 
434  {
435  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
436  return *(list.begin() + i);
437  }
438 
446  {
447  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
448  return *(list.begin() + i);
449  }
450 
456  {
457  return list.size();
458  }
459 
464  bool isEmpty() const
465  {
466  return (list.size() == 0);
467  }
468 
469  private:
470  InitializerListType list;
471  };
472 
478  template <typename T, typename A = std::vector<T> >
479  class Vector : public VectorContainer<Vector<T, A> >
480  {
481 
482  typedef Vector<T, A> SelfType;
483 
484  public:
488  typedef T ValueType;
489 
493  typedef T& Reference;
494 
498  typedef const T& ConstReference;
499 
503  typedef typename A::size_type SizeType;
504 
508  typedef typename A::difference_type DifferenceType;
509 
513  typedef A ArrayType;
514 
518  typedef T* Pointer;
519 
523  typedef const T* ConstPointer;
524 
529 
534 
539 
543  typedef std::shared_ptr<SelfType> SharedPointer;
544 
548  typedef std::initializer_list<T> InitializerListType;
549 
554  data() {}
555 
560  explicit Vector(SizeType n):
561  data(storageSize(n)) {}
562 
568  Vector(SizeType n, const ValueType& v):
569  data(storageSize(n), v) {}
570 
575  Vector(const ArrayType& data):
576  data(data) {}
577 
582  Vector(const Vector& v):
583  data(v.data) {}
584 
590  data(std::move(v.data)) {}
591 
597  data(l) {}
598 
604  template <typename E>
606  data(storageSize(e().getSize()))
607  {
608  vectorAssignVector<ScalarAssignment>(*this, e);
609  }
610 
618  {
619  return this->operator()(i);
620  }
621 
629  {
630  return this->operator()(i);
631  }
632 
640  {
641  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
642  return data[i];
643  }
644 
652  {
653  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
654  return data[i];
655  }
656 
661  bool isEmpty() const
662  {
663  return data.empty();
664  }
665 
671  {
672  return data.size();
673  }
674 
680  {
681  return data.max_size();
682  }
683 
689  {
690  return data;
691  }
692 
697  const ArrayType& getData() const
698  {
699  return data;
700  }
701 
708  {
709  data = v.data;
710  return *this;
711  }
712 
719  {
720  data = std::move(v.data);
721  return *this;
722  }
723 
730  {
731  return assign(l);
732  }
733 
740  template <typename C>
742  {
743  return assign(c);
744  }
745 
752  template <typename E>
754  {
755  Vector tmp(e);
756  swap(tmp);
757  return *this;
758  }
759 
766  template <typename C>
768  {
769  return plusAssign(c);
770  }
771 
778  {
779  return plusAssign(l);
780  }
781 
788  template <typename E>
790  {
791  Vector tmp(*this + e);
792  swap(tmp);
793  return *this;
794  }
795 
802  template <typename C>
804  {
805  return minusAssign(c);
806  }
807 
814  {
815  return minusAssign(l);
816  }
817 
824  template <typename E>
826  {
827  Vector tmp(*this - e);
828  swap(tmp);
829  return *this;
830  }
831 
838  template <typename T1>
839  typename std::enable_if<IsScalar<T1>::value, Vector>::type& operator*=(const T1& t)
840  {
841  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
842  return *this;
843  }
844 
851  template <typename T1>
852  typename std::enable_if<IsScalar<T1>::value, Vector>::type& operator/=(const T1& t)
853  {
854  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
855  return *this;
856  }
857 
864  template <typename E>
866  {
867  resize(e().getSize());
868  vectorAssignVector<ScalarAssignment>(*this, e);
869  return *this;
870  }
871 
878  {
879  data = l;
880  return *this;
881  }
882 
889  template <typename E>
891  {
892  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
893  return *this;
894  }
895 
902  {
903  vectorAssignVector<ScalarAdditionAssignment>(*this, InitListVector<ValueType>(l));
904  return *this;
905  }
906 
913  template <typename E>
915  {
916  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
917  return *this;
918  }
919 
926  {
927  vectorAssignVector<ScalarSubtractionAssignment>(*this, InitListVector<ValueType>(l));
928  return *this;
929  }
930 
935  void swap(Vector& v)
936  {
937  if (this != &v)
938  std::swap(data, v.data);
939  }
940 
946  friend void swap(Vector& v1, Vector& v2)
947  {
948  v1.swap(v2);
949  }
950 
955  void clear(const ValueType& v = ValueType())
956  {
957  std::fill(data.begin(), data.end(), v);
958  }
959 
965  void resize(SizeType n, const ValueType& v = ValueType())
966  {
967  data.resize(storageSize(n), v);
968  }
969 
970  private:
971  SizeType storageSize(SizeType n)
972  {
973  return CDPL_MATH_CHECK_MAX_SIZE(n, data.max_size(), Base::SizeError);
974  }
975 
976  ArrayType data;
977  };
978 
984  template <typename T, typename A = std::unordered_map<std::size_t, T> >
985  class SparseVector : public VectorContainer<SparseVector<T, A> >
986  {
987 
988  typedef SparseVector<T> SelfType;
989 
990  public:
994  typedef T ValueType;
995 
999  typedef std::size_t SizeType;
1000 
1004  typedef std::ptrdiff_t DifferenceType;
1005 
1009  typedef typename A::key_type KeyType;
1010 
1014  typedef const T& ConstReference;
1015 
1020 
1024  typedef A ArrayType;
1025 
1029  typedef T* Pointer;
1030 
1034  typedef const T* ConstPointer;
1035 
1040 
1045 
1050 
1054  typedef std::shared_ptr<SelfType> SharedPointer;
1055 
1059  typedef std::initializer_list<T> InitializerListType;
1060 
1065  data(), size(0) {}
1066 
1071  explicit SparseVector(SizeType n):
1072  data(), size(storageSize(n)) {}
1073 
1079  data(v.data), size(v.size) {}
1080 
1086  data(), size(0)
1087  {
1088  swap(v);
1089  }
1090 
1096  {
1097  assign(l);
1098  }
1099 
1105  template <typename E>
1107  data(), size(0)
1108  {
1109  assign(e);
1110  }
1111 
1119  {
1120  return this->operator()(i);
1121  }
1122 
1130  {
1131  return this->operator()(i);
1132  }
1133 
1141  {
1142  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
1143  return Reference(*this, i);
1144  }
1145 
1153  {
1154  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
1155 
1156  typename ArrayType::const_iterator it = data.find(i);
1157 
1158  if (it == data.end())
1159  return zero;
1160 
1161  return it->second;
1162  }
1163 
1169  {
1170  return data.size();
1171  }
1172 
1177  bool isEmpty() const
1178  {
1179  return (size == 0);
1180  }
1181 
1187  {
1188  return size;
1189  }
1190 
1196  {
1197  return std::min(SizeType(data.max_size()), std::numeric_limits<SizeType>::max());
1198  }
1199 
1205  {
1206  return data;
1207  }
1208 
1213  const ArrayType& getData() const
1214  {
1215  return data;
1216  }
1217 
1224  {
1225  data = v.data;
1226  size = v.size;
1227  return *this;
1228  }
1229 
1236  {
1237  swap(v);
1238  return *this;
1239  }
1240 
1247  {
1248  return assign(l);
1249  }
1250 
1257  template <typename C>
1259  {
1260  return assign(c);
1261  }
1262 
1269  template <typename E>
1271  {
1272  SparseVector tmp(e);
1273  swap(tmp);
1274  return *this;
1275  }
1276 
1283  template <typename C>
1285  {
1286  return plusAssign(c);
1287  }
1288 
1295  {
1296  return plusAssign(l);
1297  }
1298 
1305  template <typename E>
1307  {
1308  SparseVector tmp(*this + e);
1309  swap(tmp);
1310  return *this;
1311  }
1312 
1319  template <typename C>
1321  {
1322  return minusAssign(c);
1323  }
1324 
1331  {
1332  return minusAssign(l);
1333  }
1334 
1341  template <typename E>
1343  {
1344  SparseVector tmp(*this - e);
1345  swap(tmp);
1346  return *this;
1347  }
1348 
1355  template <typename T1>
1356  typename std::enable_if<IsScalar<T1>::value, SparseVector>::type& operator*=(const T1& t)
1357  {
1358  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
1359  return *this;
1360  }
1361 
1368  template <typename T1>
1369  typename std::enable_if<IsScalar<T1>::value, SparseVector>::type& operator/=(const T1& t)
1370  {
1371  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
1372  return *this;
1373  }
1374 
1381  template <typename E>
1383  {
1384  resize(e().getSize());
1385  vectorAssignVector<ScalarAssignment>(*this, e);
1386  return *this;
1387  }
1388 
1395  {
1396  resize(l.size());
1397  vectorAssignVector<ScalarAssignment>(*this, InitListVector<ValueType>(l));
1398  return *this;
1399  }
1400 
1407  template <typename E>
1409  {
1410  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
1411  return *this;
1412  }
1413 
1420  {
1421  vectorAssignVector<ScalarAdditionAssignment>(*this, InitListVector<ValueType>(l));
1422  return *this;
1423  }
1424 
1431  template <typename E>
1433  {
1434  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
1435  return *this;
1436  }
1437 
1444  {
1445  vectorAssignVector<ScalarSubtractionAssignment>(*this, InitListVector<ValueType>(l));
1446  return *this;
1447  }
1448 
1454  {
1455  if (this != &v) {
1456  std::swap(data, v.data);
1457  std::swap(size, v.size);
1458  }
1459  }
1460 
1466  friend void swap(SparseVector& v1, SparseVector& v2)
1467  {
1468  v1.swap(v2);
1469  }
1470 
1474  void clear()
1475  {
1476  data.clear();
1477  }
1478 
1484  {
1485  n = storageSize(n);
1486 
1487  for (typename ArrayType::iterator it = data.begin(); it != data.end();) {
1488  if (it->first >= n)
1489  it = data.erase(it);
1490  else
1491  ++it;
1492  }
1493 
1494  size = n;
1495  }
1496 
1497  private:
1498  SizeType storageSize(SizeType n)
1499  {
1501  }
1502 
1503  ArrayType data;
1504  SizeType size;
1505  static const ValueType zero;
1506  };
1507 
1508  template <typename T, typename A>
1509  const typename SparseVector<T, A>::ValueType SparseVector<T, A>::zero = SparseVector<T, A>::ValueType();
1510 
1516  template <typename T, std::size_t N>
1517  class BoundedVector : public VectorContainer<BoundedVector<T, N> >
1518  {
1519 
1520  typedef BoundedVector<T, N> SelfType;
1521 
1522  public:
1526  typedef T ValueType;
1527 
1531  typedef T& Reference;
1532 
1536  typedef const T& ConstReference;
1537 
1541  typedef std::size_t SizeType;
1542 
1546  typedef std::ptrdiff_t DifferenceType;
1547 
1552 
1556  typedef T* Pointer;
1557 
1561  typedef const T* ConstPointer;
1562 
1567 
1572 
1577 
1581  typedef std::shared_ptr<SelfType> SharedPointer;
1582 
1586  typedef std::initializer_list<T> InitializerListType;
1587 
1588 
1592  static const SizeType MaxSize = N;
1593 
1598  size(0) {}
1599 
1606  size(0)
1607  {
1608  resize(n);
1609  }
1610 
1618  size(0)
1619  {
1620  resize(n, v);
1621  }
1622 
1628  size(v.size)
1629  {
1630  std::copy(v.data, v.data + v.size, data);
1631  }
1632 
1639  {
1640  assign(l);
1641  }
1642 
1649  template <typename E>
1651  size(0)
1652  {
1653  assign(e);
1654  }
1655 
1663  {
1664  return this->operator()(i);
1665  }
1666 
1674  {
1675  return this->operator()(i);
1676  }
1677 
1685  {
1686  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
1687  return data[i];
1688  }
1689 
1697  {
1698  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
1699  return data[i];
1700  }
1701 
1706  bool isEmpty() const
1707  {
1708  return (size == 0);
1709  }
1710 
1716  {
1717  return size;
1718  }
1719 
1725  {
1726  return N;
1727  }
1728 
1734  {
1735  return data;
1736  }
1737 
1743  {
1744  return data;
1745  }
1746 
1753  {
1754  if (this != &v) {
1755  std::copy(v.data, v.data + v.size, data);
1756  size = v.size;
1757  }
1758 
1759  return *this;
1760  }
1761 
1769  {
1770  return assign(l);
1771  }
1772 
1779  template <typename C>
1781  {
1782  return assign(c);
1783  }
1784 
1791  template <typename E>
1793  {
1794  BoundedVector tmp(e);
1795  return this-> operator=(tmp);
1796  }
1797 
1804  template <typename C>
1806  {
1807  return plusAssign(c);
1808  }
1809 
1816  {
1817  return plusAssign(l);
1818  }
1819 
1826  template <typename E>
1828  {
1829  BoundedVector tmp(*this + e);
1830  return this-> operator=(tmp);
1831  }
1832 
1839  template <typename C>
1841  {
1842  return minusAssign(c);
1843  }
1844 
1851  {
1852  return minusAssign(l);
1853  }
1854 
1861  template <typename E>
1863  {
1864  BoundedVector tmp(*this - e);
1865  return this-> operator=(tmp);
1866  }
1867 
1874  template <typename T1>
1875  typename std::enable_if<IsScalar<T1>::value, BoundedVector>::type& operator*=(const T1& t)
1876  {
1877  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
1878  return *this;
1879  }
1880 
1887  template <typename T1>
1888  typename std::enable_if<IsScalar<T1>::value, BoundedVector>::type& operator/=(const T1& t)
1889  {
1890  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
1891  return *this;
1892  }
1893 
1901  template <typename E>
1903  {
1904  resize(e().getSize());
1905  vectorAssignVector<ScalarAssignment>(*this, e);
1906  return *this;
1907  }
1908 
1916  {
1917  resize(l.size());
1918  std::copy(l.begin(), l.begin() + size, data);
1919  return *this;
1920  }
1921 
1928  template <typename E>
1930  {
1931  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
1932  return *this;
1933  }
1934 
1941  {
1942  vectorAssignVector<ScalarAdditionAssignment>(*this, InitListVector<ValueType>(l));
1943  return *this;
1944  }
1945 
1952  template <typename E>
1954  {
1955  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
1956  return *this;
1957  }
1958 
1965  {
1966  vectorAssignVector<ScalarSubtractionAssignment>(*this, InitListVector<ValueType>(l));
1967  return *this;
1968  }
1969 
1975  {
1976  if (this != &v) {
1977  std::swap_ranges(data, data + std::max(size, v.size), v.data);
1978  std::swap(size, v.size);
1979  }
1980  }
1981 
1987  friend void swap(BoundedVector& v1, BoundedVector& v2)
1988  {
1989  v1.swap(v2);
1990  }
1991 
1996  void clear(const ValueType& v = ValueType())
1997  {
1998  std::fill(data, data + size, v);
1999  }
2000 
2007  {
2008  size = storageSize(n);
2009  }
2010 
2017  void resize(SizeType n, const ValueType& v)
2018  {
2019  n = storageSize(n);
2020 
2021  if (n > size)
2022  std::fill(data + size, data + n, v);
2023 
2024  size = n;
2025  }
2026 
2027  private:
2028  SizeType storageSize(SizeType n)
2029  {
2031  }
2032 
2033  ArrayType data;
2034  SizeType size;
2035  };
2036 
2037  template <typename T, std::size_t N>
2039 
2045  template <typename T, std::size_t N>
2046  class CVector : public VectorContainer<CVector<T, N> >
2047  {
2048 
2049  typedef CVector<T, N> SelfType;
2050 
2051  public:
2055  typedef T ValueType;
2056 
2060  typedef T& Reference;
2061 
2065  typedef const T& ConstReference;
2066 
2070  typedef std::size_t SizeType;
2071 
2075  typedef std::ptrdiff_t DifferenceType;
2076 
2081 
2085  typedef T* Pointer;
2086 
2090  typedef const T* ConstPointer;
2091 
2096 
2101 
2106 
2110  typedef std::shared_ptr<SelfType> SharedPointer;
2111 
2115  typedef std::initializer_list<T> InitializerListType;
2116 
2117 
2121  static const SizeType Size = N;
2122 
2127  {
2128  clear();
2129  }
2130 
2135  explicit CVector(const ValueType& v)
2136  {
2137  clear(v);
2138  }
2139 
2144  CVector(const CVector& v)
2145  {
2146  std::copy(v.data, v.data + N, data);
2147  }
2148 
2154  {
2155  assign(l);
2156  }
2157 
2163  template <typename E>
2165  {
2166  vectorAssignVector<ScalarAssignment>(*this, e);
2167  }
2168 
2176  {
2177  return this->operator()(i);
2178  }
2179 
2187  {
2188  return this->operator()(i);
2189  }
2190 
2198  {
2199  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
2200  return data[i];
2201  }
2202 
2210  {
2211  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
2212  return data[i];
2213  }
2214 
2219  bool isEmpty() const
2220  {
2221  return (N == 0);
2222  }
2223 
2229  {
2230  return N;
2231  }
2232 
2238  {
2239  return N;
2240  }
2241 
2247  {
2248  return data;
2249  }
2250 
2256  {
2257  return data;
2258  }
2259 
2266  {
2267  if (this != &v)
2268  std::copy(v.data, v.data + N, data);
2269 
2270  return *this;
2271  }
2272 
2279  {
2280  return assign(l);
2281  }
2282 
2289  template <typename C>
2291  {
2292  return assign(c);
2293  }
2294 
2301  template <typename E>
2303  {
2304  CVector tmp(e);
2305  return this->operator=(tmp);
2306  }
2307 
2314  template <typename C>
2316  {
2317  return plusAssign(c);
2318  }
2319 
2326  {
2327  return plusAssign(l);
2328  }
2329 
2336  template <typename E>
2338  {
2339  CVector tmp(*this + e);
2340  return this->operator=(tmp);
2341  }
2342 
2349  template <typename C>
2351  {
2352  return minusAssign(c);
2353  }
2354 
2361  {
2362  return minusAssign(l);
2363  }
2364 
2371  template <typename E>
2373  {
2374  CVector tmp(*this - e);
2375  return this->operator=(tmp);
2376  }
2377 
2384  template <typename T1>
2385  typename std::enable_if<IsScalar<T1>::value, CVector>::type& operator*=(const T1& t)
2386  {
2387  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
2388  return *this;
2389  }
2390 
2397  template <typename T1>
2398  typename std::enable_if<IsScalar<T1>::value, CVector>::type& operator/=(const T1& t)
2399  {
2400  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
2401  return *this;
2402  }
2403 
2410  template <typename E>
2412  {
2413  vectorAssignVector<ScalarAssignment>(*this, e);
2414  return *this;
2415  }
2416 
2424  {
2426  std::copy(l.begin(), l.begin() + n, data);
2427 
2428  if (n < N)
2429  std::fill(data + n, data + N, ValueType());
2430 
2431  return *this;
2432  }
2433 
2440  template <typename E>
2442  {
2443  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
2444  return *this;
2445  }
2446 
2453  {
2454  vectorAssignVector<ScalarAdditionAssignment>(*this, InitListVector<ValueType>(l));
2455  return *this;
2456  }
2457 
2464  template <typename E>
2466  {
2467  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
2468  return *this;
2469  }
2470 
2477  {
2478  vectorAssignVector<ScalarSubtractionAssignment>(*this, InitListVector<ValueType>(l));
2479  return *this;
2480  }
2481 
2486  void swap(CVector& v)
2487  {
2488  if (this != &v)
2489  std::swap_ranges(data, data + N, v.data);
2490  }
2491 
2497  friend void swap(CVector& v1, CVector& v2)
2498  {
2499  v1.swap(v2);
2500  }
2501 
2506  void clear(const ValueType& v = ValueType())
2507  {
2508  std::fill(data, data + N, v);
2509  }
2510 
2511  private:
2512  ArrayType data;
2513  };
2514 
2515  template <typename T, std::size_t N>
2517 
2522  template <typename T>
2523  class ZeroVector : public VectorContainer<ZeroVector<T> >
2524  {
2525 
2526  typedef ZeroVector<T> SelfType;
2527 
2528  public:
2532  typedef T ValueType;
2533 
2537  typedef const T& Reference;
2538 
2542  typedef const T& ConstReference;
2543 
2547  typedef std::size_t SizeType;
2548 
2552  typedef std::ptrdiff_t DifferenceType;
2553 
2558 
2563 
2568 
2573  size(0) {}
2574 
2579  explicit ZeroVector(SizeType n):
2580  size(n) {}
2581 
2587  size(v.size) {}
2588 
2596  {
2597  return this->operator()(i);
2598  }
2599 
2607  {
2608  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
2609  return zero;
2610  }
2611 
2616  bool isEmpty() const
2617  {
2618  return (size == 0);
2619  }
2620 
2626  {
2627  return size;
2628  }
2629 
2635  {
2636  return std::numeric_limits<SizeType>::max();
2637  }
2638 
2645  {
2646  size = v.size;
2647  return *this;
2648  }
2649 
2655  {
2656  size = n;
2657  }
2658 
2663  void swap(ZeroVector& v)
2664  {
2665  if (this != &v)
2666  std::swap(size, v.size);
2667  }
2668 
2674  friend void swap(ZeroVector& v1, ZeroVector& v2)
2675  {
2676  v1.swap(v2);
2677  }
2678 
2679  private:
2680  SizeType size;
2681  static const ValueType zero;
2682  };
2683 
2684  template <typename T>
2685  const typename ZeroVector<T>::ValueType ZeroVector<T>::zero = ZeroVector<T>::ValueType();
2686 
2691  template <typename T>
2692  class UnitVector : public VectorContainer<UnitVector<T> >
2693  {
2694 
2695  typedef UnitVector<T> SelfType;
2696 
2697  public:
2701  typedef T ValueType;
2702 
2706  typedef const T& Reference;
2707 
2711  typedef const T& ConstReference;
2712 
2716  typedef std::size_t SizeType;
2717 
2721  typedef std::ptrdiff_t DifferenceType;
2722 
2727 
2732 
2737 
2742  size(0), index(0) {}
2743 
2750  size(n), index(i) {}
2751 
2757  size(v.size), index(v.index) {}
2758 
2766  {
2767  return this->operator()(i);
2768  }
2769 
2777  {
2778  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
2779 
2780  return (i == index ? one : zero);
2781  }
2782 
2787  bool isEmpty() const
2788  {
2789  return (size == 0);
2790  }
2791 
2797  {
2798  return size;
2799  }
2800 
2806  {
2807  return index;
2808  }
2809 
2815  {
2816  return std::numeric_limits<SizeType>::max();
2817  }
2818 
2825  {
2826  if (this != &v) {
2827  size = v.size;
2828  index = v.index;
2829  }
2830 
2831  return *this;
2832  }
2833 
2839  {
2840  size = n;
2841  }
2842 
2847  void swap(UnitVector& v)
2848  {
2849  if (this != &v) {
2850  std::swap(size, v.size);
2851  std::swap(index, v.index);
2852  }
2853  }
2854 
2860  friend void swap(UnitVector& v1, UnitVector& v2)
2861  {
2862  v1.swap(v2);
2863  }
2864 
2865  private:
2866  SizeType size;
2867  SizeType index;
2868  static const ValueType zero;
2869  static const ValueType one;
2870  };
2871 
2872  template <typename T>
2873  const typename UnitVector<T>::ValueType UnitVector<T>::zero = UnitVector<T>::ValueType();
2874  template <typename T>
2875  const typename UnitVector<T>::ValueType UnitVector<T>::one = UnitVector<T>::ValueType(1);
2876 
2881  template <typename T>
2882  class ScalarVector : public VectorContainer<ScalarVector<T> >
2883  {
2884 
2885  typedef ScalarVector<T> SelfType;
2886 
2887  public:
2891  typedef T ValueType;
2892 
2896  typedef const T& Reference;
2897 
2901  typedef const T& ConstReference;
2902 
2906  typedef std::size_t SizeType;
2907 
2911  typedef std::ptrdiff_t DifferenceType;
2912 
2917 
2922 
2927 
2932  size(0) {}
2933 
2940  size(n), value(v) {}
2941 
2947  size(v.size), value(v.value) {}
2948 
2956  {
2957  return this->operator()(i);
2958  }
2959 
2967  {
2968  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
2969  return value;
2970  }
2971 
2976  bool isEmpty() const
2977  {
2978  return (size == 0);
2979  }
2980 
2986  {
2987  return size;
2988  }
2989 
2995  {
2996  return std::numeric_limits<SizeType>::max();
2997  }
2998 
3005  {
3006  if (this != &v) {
3007  size = v.size;
3008  value = v.value;
3009  }
3010 
3011  return *this;
3012  }
3013 
3019  {
3020  size = n;
3021  }
3022 
3028  {
3029  if (this != &v) {
3030  std::swap(size, v.size);
3031  std::swap(value, v.value);
3032  }
3033  }
3034 
3040  friend void swap(ScalarVector& v1, ScalarVector& v2)
3041  {
3042  v1.swap(v2);
3043  }
3044 
3045  private:
3046  SizeType size;
3047  ValueType value;
3048  };
3049 
3054  template <typename V>
3056  {};
3057 
3062  template <typename V>
3064  {};
3065 
3074  template <typename T1, typename T2>
3076  vec(const T1& t1, const T2& t2)
3077  {
3079 
3080  v(0) = t1;
3081  v(1) = t2;
3082 
3083  return v;
3084  }
3085 
3096  template <typename T1, typename T2, typename T3>
3097  CVector<typename CommonType<typename CommonType<T1, T2>::Type, T3>::Type, 3>
3098  vec(const T1& t1, const T2& t2, const T3& t3)
3099  {
3101 
3102  v(0) = t1;
3103  v(1) = t2;
3104  v(2) = t3;
3105 
3106  return v;
3107  }
3108 
3121  template <typename T1, typename T2, typename T3, typename T4>
3122  CVector<typename CommonType<typename CommonType<typename CommonType<T1, T2>::Type, T3>::Type, T4>::Type, 4>
3123  vec(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
3124  {
3126 
3127  v(0) = t1;
3128  v(1) = t2;
3129  v(2) = t3;
3130  v(3) = t4;
3131 
3132  return v;
3133  }
3134 
3139 
3144 
3149 
3154 
3159 
3164 
3169 
3174 
3179 
3184 
3189 
3194 
3199 
3204 
3209 
3214 
3219 
3224 
3229 
3234 
3239 
3244 
3249 
3254 
3259 
3264 
3269 
3274 
3279 
3284 
3289 
3294 
3299  } // namespace Math
3300 } // namespace CDPL
3301 
3302 #endif // CDPL_MATH_VECTOR_HPP
Definition of exception classes.
Definition of various preprocessor macros for error checking.
#define CDPL_MATH_CHECK_MAX_SIZE(size, max_size, e)
Throws the exception e if size exceeds max_size, otherwise returns std::min(size, max_size).
Definition: Check.hpp:96
#define CDPL_MATH_CHECK(expr, msg, e)
Throws the exception e with message msg when the boolean expression expr evaluates to false.
Definition: Check.hpp:47
Definition of a proxy type for direct assignment of vector and matrix expressions.
Definition of various functors.
Definition of an element proxy for sparse data types.
Definition of type traits.
Implementation of vector assignment routines.
Definition of various vector expression types and operations.
Thrown to indicate that an index is out of range.
Definition: Base/Exceptions.hpp:152
Thrown to indicate that the size of a (multidimensional) array is not correct.
Definition: Base/Exceptions.hpp:133
Variable-size vector with a fixed upper capacity N stored in a stack-allocated array.
Definition: Vector.hpp:1518
static const SizeType MaxSize
The compile-time maximum capacity N.
Definition: Vector.hpp:1592
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated BoundedVector instances.
Definition: Vector.hpp:1581
BoundedVector & operator=(const BoundedVector &v)
Copy-assigns the elements of v to this bounded vector.
Definition: Vector.hpp:1752
BoundedVector & operator+=(const VectorContainer< C > &c)
Adds the contents of the vector container c element-wise to this bounded vector (no alias check neede...
Definition: Vector.hpp:1805
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:1673
T & Reference
Mutable element reference type.
Definition: Vector.hpp:1531
void resize(SizeType n, const ValueType &v)
Resizes the vector to n elements; newly added elements are set to v.
Definition: Vector.hpp:2017
void swap(BoundedVector &v)
Swaps the contents of this bounded vector with those of v.
Definition: Vector.hpp:1974
BoundedVector & operator+=(const VectorExpression< E > &e)
Adds the vector expression e element-wise to this bounded vector (via a temporary to handle aliasing)...
Definition: Vector.hpp:1827
void clear(const ValueType &v=ValueType())
Sets every element of the vector to the value v (size is unchanged).
Definition: Vector.hpp:1996
Pointer getData()
Returns a mutable pointer to the contiguous element array.
Definition: Vector.hpp:1733
BoundedVector(const VectorExpression< E > &e)
Constructs a bounded vector from the vector expression e.
Definition: Vector.hpp:1650
BoundedVector & assign(InitializerListType l)
Resizes this vector to match l and copies the elements of l in.
Definition: Vector.hpp:1915
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:1684
std::enable_if< IsScalar< T1 >::value, BoundedVector >::type & operator*=(const T1 &t)
Multiplies every element by the scalar t.
Definition: Vector.hpp:1875
void resize(SizeType n)
Resizes the vector to n elements (new elements are left value-uninitialized).
Definition: Vector.hpp:2006
BoundedVector & assign(const VectorExpression< E > &e)
Resizes this vector to match e and assigns the elements of e without intermediate temporary.
Definition: Vector.hpp:1902
std::initializer_list< T > InitializerListType
The initializer list type accepted by constructors and assignment.
Definition: Vector.hpp:1586
BoundedVector & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this vector without intermediate temporary.
Definition: Vector.hpp:1953
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:1696
ConstPointer getData() const
Returns a const pointer to the contiguous element array.
Definition: Vector.hpp:1742
SizeType getMaxSize() const
Returns the compile-time maximum capacity N.
Definition: Vector.hpp:1724
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:1571
BoundedVector(InitializerListType l)
Constructs a bounded vector with the contents of the initializer list l.
Definition: Vector.hpp:1638
BoundedVector & operator=(const VectorContainer< C > &c)
Assigns the contents of the vector container c to this bounded vector (no alias check needed).
Definition: Vector.hpp:1780
BoundedVector & plusAssign(InitializerListType l)
Adds the contents of the initializer list l element-wise to this vector without intermediate temporar...
Definition: Vector.hpp:1940
const T * ConstPointer
Constant pointer type for raw access to the element array.
Definition: Vector.hpp:1561
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:1662
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:1546
BoundedVector()
Constructs an empty bounded vector (size zero, capacity N).
Definition: Vector.hpp:1597
BoundedVector & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this vector without intermediate temporary.
Definition: Vector.hpp:1929
SizeType getSize() const
Returns the current element count.
Definition: Vector.hpp:1715
BoundedVector(SizeType n)
Constructs a bounded vector of size n with value-initialized elements.
Definition: Vector.hpp:1605
BoundedVector & minusAssign(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this vector without intermediate t...
Definition: Vector.hpp:1964
BoundedVector & operator-=(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this bounded vector.
Definition: Vector.hpp:1850
T ValueType
The scalar value type.
Definition: Vector.hpp:1526
bool isEmpty() const
Tells whether the vector is empty.
Definition: Vector.hpp:1706
ValueType ArrayType[N]
The fixed-capacity C-array type used for in-memory storage.
Definition: Vector.hpp:1551
BoundedVector & operator=(InitializerListType l)
Assigns the contents of the initializer list l to this bounded vector.
Definition: Vector.hpp:1768
T * Pointer
Pointer type for raw access to the element array.
Definition: Vector.hpp:1556
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:1541
BoundedVector & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e element-wise from this bounded vector (via a temporary to handle al...
Definition: Vector.hpp:1862
BoundedVector & operator-=(const VectorContainer< C > &c)
Subtracts the contents of the vector container c element-wise from this bounded vector (no alias chec...
Definition: Vector.hpp:1840
BoundedVector(SizeType n, const ValueType &v)
Constructs a bounded vector of size n with every element initialized to v.
Definition: Vector.hpp:1617
friend void swap(BoundedVector &v1, BoundedVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:1987
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:1566
const T & ConstReference
Constant element reference type.
Definition: Vector.hpp:1536
BoundedVector< T, N+1 > VectorTemporaryType
Concrete temporary vector type used by expression template machinery (one element larger than the bou...
Definition: Vector.hpp:1576
BoundedVector & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this bounded vector (via a temporary to handle aliasing).
Definition: Vector.hpp:1792
BoundedVector(const BoundedVector &v)
Constructs a copy of the bounded vector v.
Definition: Vector.hpp:1627
std::enable_if< IsScalar< T1 >::value, BoundedVector >::type & operator/=(const T1 &t)
Divides every element by the scalar t.
Definition: Vector.hpp:1888
BoundedVector & operator+=(InitializerListType l)
Adds the contents of the initializer list l element-wise to this bounded vector.
Definition: Vector.hpp:1815
Fixed-size vector of dimension N backed by a C-array (no dynamic allocation).
Definition: Vector.hpp:2047
std::enable_if< IsScalar< T1 >::value, CVector >::type & operator/=(const T1 &t)
Divides every element by the scalar t.
Definition: Vector.hpp:2398
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:2209
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:2070
CVector & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this fixed-size vector (via a temporary to handle aliasing).
Definition: Vector.hpp:2302
Pointer getData()
Returns a mutable pointer to the contiguous element array.
Definition: Vector.hpp:2246
static const SizeType Size
The compile-time fixed size N.
Definition: Vector.hpp:2121
T ValueType
The scalar value type.
Definition: Vector.hpp:2055
void clear(const ValueType &v=ValueType())
Sets every element of the vector to the value v.
Definition: Vector.hpp:2506
SizeType getMaxSize() const
Returns the fixed element count N (capacity equals size for Math::CVector).
Definition: Vector.hpp:2237
CVector & operator=(InitializerListType l)
Assigns the contents of the initializer list l to this fixed-size vector.
Definition: Vector.hpp:2278
const T & ConstReference
Constant element reference type.
Definition: Vector.hpp:2065
ConstPointer getData() const
Returns a const pointer to the contiguous element array.
Definition: Vector.hpp:2255
ValueType ArrayType[N]
The fixed-size C-array type used for in-memory storage of N elements.
Definition: Vector.hpp:2080
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:2186
bool isEmpty() const
Tells whether the vector is empty (N is zero).
Definition: Vector.hpp:2219
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:2197
CVector & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this vector without intermediate temporary.
Definition: Vector.hpp:2441
CVector & operator-=(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this fixed-size vector.
Definition: Vector.hpp:2360
CVector & plusAssign(InitializerListType l)
Adds the contents of the initializer list l element-wise to this vector without intermediate temporar...
Definition: Vector.hpp:2452
CVector & operator+=(const VectorExpression< E > &e)
Adds the vector expression e element-wise to this fixed-size vector (via a temporary to handle aliasi...
Definition: Vector.hpp:2337
SizeType getSize() const
Returns the fixed element count N.
Definition: Vector.hpp:2228
CVector & operator=(const VectorContainer< C > &c)
Assigns the contents of the vector container c to this fixed-size vector (no alias check needed).
Definition: Vector.hpp:2290
T * Pointer
Pointer type for raw access to the element array.
Definition: Vector.hpp:2085
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2095
CVector & operator+=(InitializerListType l)
Adds the contents of the initializer list l element-wise to this fixed-size vector.
Definition: Vector.hpp:2325
CVector(InitializerListType l)
Constructs a fixed-size vector with the contents of the initializer list l.
Definition: Vector.hpp:2153
void swap(CVector &v)
Swaps the contents of this fixed-size vector with those of v.
Definition: Vector.hpp:2486
BoundedVector< T, N+1 > VectorTemporaryType
Concrete temporary vector type used by expression template machinery (a Math::BoundedVector of N + 1 ...
Definition: Vector.hpp:2105
CVector & assign(const VectorExpression< E > &e)
Assigns the elements of the vector expression e to this fixed-size vector without intermediate tempor...
Definition: Vector.hpp:2411
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:2175
const T * ConstPointer
Constant pointer type for raw access to the element array.
Definition: Vector.hpp:2090
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated CVector instances.
Definition: Vector.hpp:2110
CVector & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e element-wise from this fixed-size vector (via a temporary to handle...
Definition: Vector.hpp:2372
CVector & minusAssign(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this vector without intermediate t...
Definition: Vector.hpp:2476
CVector & operator+=(const VectorContainer< C > &c)
Adds the contents of the vector container c element-wise to this fixed-size vector (no alias check ne...
Definition: Vector.hpp:2315
T & Reference
Mutable element reference type.
Definition: Vector.hpp:2060
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2100
CVector & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this vector without intermediate temporary.
Definition: Vector.hpp:2465
CVector & operator=(const CVector &v)
Copy-assigns the elements of v to this fixed-size vector.
Definition: Vector.hpp:2265
CVector(const ValueType &v)
Constructs an N-element vector with every element initialized to v.
Definition: Vector.hpp:2135
std::initializer_list< T > InitializerListType
The initializer list type accepted by constructors and assignment.
Definition: Vector.hpp:2115
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:2075
CVector & assign(InitializerListType l)
Assigns the contents of the initializer list l to this fixed-size vector (truncated to N if longer; z...
Definition: Vector.hpp:2423
CVector()
Constructs a zero-initialized N element vector.
Definition: Vector.hpp:2126
CVector(const VectorExpression< E > &e)
Constructs a fixed-size vector from the vector expression e.
Definition: Vector.hpp:2164
CVector & operator-=(const VectorContainer< C > &c)
Subtracts the contents of the vector container c element-wise from this fixed-size vector (no alias c...
Definition: Vector.hpp:2350
CVector(const CVector &v)
Constructs a copy of the fixed-size vector v.
Definition: Vector.hpp:2144
friend void swap(CVector &v1, CVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:2497
std::enable_if< IsScalar< T1 >::value, CVector >::type & operator*=(const T1 &t)
Multiplies every element by the scalar t.
Definition: Vector.hpp:2385
Lightweight vector container that wraps a std::initializer_list for construction-style initialization...
Definition: Vector.hpp:348
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:445
InitializerListType::const_reference ConstReference
Constant element reference type.
Definition: Vector.hpp:366
const SelfType ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:391
Reference operator[](SizeType i)
Returns a reference to the element at index i.
Definition: Vector.hpp:411
Reference operator()(SizeType i)
Returns a reference to the element at index i.
Definition: Vector.hpp:433
std::initializer_list< T > InitializerListType
The wrapped std::initializer_list type.
Definition: Vector.hpp:356
SizeType getSize() const
Returns the size of the wrapped initializer list.
Definition: Vector.hpp:455
InitListVector(InitializerListType l)
Constructs the vector by wrapping the initializer list l (no copy).
Definition: Vector.hpp:402
bool isEmpty() const
Tells whether the wrapped initializer list is empty.
Definition: Vector.hpp:464
InitializerListType::value_type ValueType
The scalar value type.
Definition: Vector.hpp:361
InitializerListType::reference Reference
Mutable element reference type (degrades to ConstReference for the immutable initializer list).
Definition: Vector.hpp:371
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:381
InitializerListType::size_type SizeType
The unsigned size type.
Definition: Vector.hpp:376
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:422
SelfType ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:386
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used by expression template machinery.
Definition: Vector.hpp:396
InitListVector SelfType
Definition: Vector.hpp:351
Constant vector expression in which every element equals the same scalar value.
Definition: Vector.hpp:2883
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:2906
ConstReference operator()(SizeType i) const
Returns a const reference to the common element value.
Definition: Vector.hpp:2966
SizeType getMaxSize() const
Returns the maximum representable element count.
Definition: Vector.hpp:2994
const T & ConstReference
Constant element reference type.
Definition: Vector.hpp:2901
ConstReference operator[](SizeType i) const
Returns a const reference to the common element value.
Definition: Vector.hpp:2955
const T & Reference
Reference type (always a const reference — elements are immutable).
Definition: Vector.hpp:2896
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2916
ScalarVector()
Constructs an empty scalar vector.
Definition: Vector.hpp:2931
friend void swap(ScalarVector &v1, ScalarVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:3040
ScalarVector & operator=(const ScalarVector &v)
Copy-assigns the size and common value from v.
Definition: Vector.hpp:3004
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2921
Vector< T > VectorTemporaryType
Concrete temporary vector type used by expression template machinery.
Definition: Vector.hpp:2926
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:2911
T ValueType
The scalar value type.
Definition: Vector.hpp:2891
SizeType getSize() const
Returns the logical element count.
Definition: Vector.hpp:2985
void resize(SizeType n)
Resizes the logical element count to n.
Definition: Vector.hpp:3018
void swap(ScalarVector &v)
Swaps the size and common value with v.
Definition: Vector.hpp:3027
bool isEmpty() const
Tells whether the vector has zero logical size.
Definition: Vector.hpp:2976
ScalarVector(SizeType n, const ValueType &v=ValueType())
Constructs a scalar vector of size n in which every element equals v.
Definition: Vector.hpp:2939
ScalarVector(const ScalarVector &v)
Constructs a copy of the scalar vector v.
Definition: Vector.hpp:2946
Proxy that exposes a single (key, value) entry of a sparse container as a writable reference.
Definition: SparseContainerElement.hpp:52
Sparse vector that stores only non-default entries in an associative key-to-value container.
Definition: Vector.hpp:986
SparseVector & operator=(InitializerListType l)
Assigns the contents of the initializer list l to this sparse vector.
Definition: Vector.hpp:1246
SparseVector & operator=(SparseVector &&v)
Move-assigns the contents of v to this sparse vector.
Definition: Vector.hpp:1235
SparseVector & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e element-wise from this sparse vector (via a temporary to handle ali...
Definition: Vector.hpp:1342
SparseVector & operator+=(InitializerListType l)
Adds the contents of the initializer list l element-wise to this sparse vector.
Definition: Vector.hpp:1294
SparseVector & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this sparse vector (via a temporary to handle aliasing).
Definition: Vector.hpp:1270
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:1152
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:1044
SparseVector(const VectorExpression< E > &e)
Constructs a sparse vector from the vector expression e.
Definition: Vector.hpp:1106
SizeType getMaxSize() const
Returns the maximum number of stored entries the underlying associative container can hold.
Definition: Vector.hpp:1195
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:1004
SparseVector & operator+=(const VectorContainer< C > &c)
Adds the contents of the vector container c element-wise to this sparse vector (no alias check needed...
Definition: Vector.hpp:1284
void resize(SizeType n)
Resizes the logical element count to n, dropping any stored entries at indices beyond n.
Definition: Vector.hpp:1483
SparseVector(SparseVector &&v)
Move-constructs from v (v is left in a valid empty state).
Definition: Vector.hpp:1085
SizeType getSize() const
Returns the logical element count.
Definition: Vector.hpp:1186
A::key_type KeyType
The key type used by the underlying associative container.
Definition: Vector.hpp:1009
std::initializer_list< T > InitializerListType
The initializer list type accepted by constructors and assignment.
Definition: Vector.hpp:1059
SparseVector(const SparseVector &v)
Constructs a copy of the sparse vector v.
Definition: Vector.hpp:1078
void swap(SparseVector &v)
Swaps the contents of this sparse vector with those of v.
Definition: Vector.hpp:1453
SizeType getNumElements() const
Returns the number of explicitly stored (non-default) entries.
Definition: Vector.hpp:1168
T * Pointer
Pointer type for raw access to stored entries.
Definition: Vector.hpp:1029
SparseVector(SizeType n)
Constructs a sparse vector of size n with no stored entries (every position reads as the default valu...
Definition: Vector.hpp:1071
SparseVector & operator-=(const VectorContainer< C > &c)
Subtracts the contents of the vector container c element-wise from this sparse vector (no alias check...
Definition: Vector.hpp:1320
SparseVector(InitializerListType l)
Constructs a sparse vector with the contents of the initializer list l.
Definition: Vector.hpp:1095
SparseVector()
Constructs an empty sparse vector (size zero, no stored entries).
Definition: Vector.hpp:1064
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SparseVector instances.
Definition: Vector.hpp:1054
A ArrayType
The underlying associative container type.
Definition: Vector.hpp:1024
SparseVector & operator=(const VectorContainer< C > &c)
Assigns the contents of the vector container c to this sparse vector (no alias check needed).
Definition: Vector.hpp:1258
SparseVector & minusAssign(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this vector without intermediate t...
Definition: Vector.hpp:1443
SparseContainerElement< SelfType, KeyType > Reference
Mutable element reference type (a proxy object that inserts on assignment to a previously-absent key)...
Definition: Vector.hpp:1019
ArrayType & getData()
Returns a mutable reference to the underlying associative container of stored entries.
Definition: Vector.hpp:1204
SparseVector & operator-=(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this sparse vector.
Definition: Vector.hpp:1330
SparseVector & assign(const VectorExpression< E > &e)
Resizes this vector to match e and assigns the elements of e without intermediate temporary.
Definition: Vector.hpp:1382
const T * ConstPointer
Constant pointer type for raw access to stored entries.
Definition: Vector.hpp:1034
std::enable_if< IsScalar< T1 >::value, SparseVector >::type & operator*=(const T1 &t)
Multiplies every stored entry by the scalar t.
Definition: Vector.hpp:1356
Reference operator()(SizeType i)
Returns a mutable proxy reference to the element at index i.
Definition: Vector.hpp:1140
const ArrayType & getData() const
Returns a const reference to the underlying associative container of stored entries.
Definition: Vector.hpp:1213
SparseVector & assign(InitializerListType l)
Resizes this vector to match l and assigns the elements of l.
Definition: Vector.hpp:1394
SelfType VectorTemporaryType
Concrete temporary vector type used by expression template machinery.
Definition: Vector.hpp:1049
Reference operator[](SizeType i)
Returns a mutable proxy reference to the element at index i.
Definition: Vector.hpp:1118
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:1129
bool isEmpty() const
Tells whether the vector's logical size is zero.
Definition: Vector.hpp:1177
void clear()
Removes all explicitly stored entries (the logical size remains unchanged).
Definition: Vector.hpp:1474
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:1039
SparseVector & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this vector without intermediate temporary.
Definition: Vector.hpp:1408
std::enable_if< IsScalar< T1 >::value, SparseVector >::type & operator/=(const T1 &t)
Divides every stored entry by the scalar t.
Definition: Vector.hpp:1369
SparseVector & plusAssign(InitializerListType l)
Adds the contents of the initializer list l element-wise to this vector without intermediate temporar...
Definition: Vector.hpp:1419
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:999
const T & ConstReference
Constant reference type to a stored element value.
Definition: Vector.hpp:1014
T ValueType
The scalar value type stored in the vector.
Definition: Vector.hpp:994
friend void swap(SparseVector &v1, SparseVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:1466
SparseVector & operator+=(const VectorExpression< E > &e)
Adds the vector expression e element-wise to this sparse vector (via a temporary to handle aliasing).
Definition: Vector.hpp:1306
SparseVector & operator=(const SparseVector &v)
Copy-assigns the contents of v to this sparse vector.
Definition: Vector.hpp:1223
SparseVector & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this vector without intermediate temporary.
Definition: Vector.hpp:1432
Constant vector expression that contains 1 at a single specified index and 0 elsewhere.
Definition: Vector.hpp:2693
T ValueType
The scalar value type.
Definition: Vector.hpp:2701
void swap(UnitVector &v)
Swaps the size and unit index with v.
Definition: Vector.hpp:2847
const T & Reference
Reference type (always a const reference — elements are immutable).
Definition: Vector.hpp:2706
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:2716
UnitVector & operator=(const UnitVector &v)
Copy-assigns the size and unit index from v.
Definition: Vector.hpp:2824
friend void swap(UnitVector &v1, UnitVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:2860
const T & ConstReference
Constant element reference type.
Definition: Vector.hpp:2711
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:2776
void resize(SizeType n)
Resizes the logical element count to n.
Definition: Vector.hpp:2838
SizeType getSize() const
Returns the logical element count.
Definition: Vector.hpp:2796
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2731
Vector< T > VectorTemporaryType
Concrete temporary vector type used by expression template machinery.
Definition: Vector.hpp:2736
UnitVector()
Constructs an empty unit vector (size zero, index zero).
Definition: Vector.hpp:2741
UnitVector(SizeType n, SizeType i)
Constructs a unit vector of size n with the 1 element at index i.
Definition: Vector.hpp:2749
bool isEmpty() const
Tells whether the vector has zero logical size.
Definition: Vector.hpp:2787
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:2721
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:2765
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2726
UnitVector(const UnitVector &v)
Constructs a copy of the unit vector v.
Definition: Vector.hpp:2756
SizeType getMaxSize() const
Returns the maximum representable element count.
Definition: Vector.hpp:2814
SizeType getIndex() const
Returns the index of the non-zero (unit) element.
Definition: Vector.hpp:2805
Refinement of Math::VectorExpression marking the derived type as a concrete (writable) vector contain...
Definition: Expression.hpp:225
const ContainerType & operator()() const
Returns a const reference to the derived vector container class instance.
Definition: Expression.hpp:237
CRTP base class of all vector expression types.
Definition: Expression.hpp:68
Lightweight vector expression that proxies a reference to an underlying vector container.
Definition: Vector.hpp:62
SizeType getMaxSize() const
Returns the wrapped vector's capacity (maximum element count without reallocation).
Definition: Vector.hpp:169
V::DifferenceType DifferenceType
The signed difference type of the wrapped vector.
Definition: Vector.hpp:97
V::ConstReference ConstReference
Constant element reference type.
Definition: Vector.hpp:87
V VectorType
The wrapped vector type.
Definition: Vector.hpp:70
VectorReference & assign(const VectorExpression< E > &e)
Assigns the vector expression e to the wrapped vector without intermediate temporary.
Definition: Vector.hpp:284
VectorReference & operator=(const VectorReference &r)
Copy-assigns the wrapped vector from the vector referenced by r.
Definition: Vector.hpp:206
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:131
VectorReference & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to the wrapped vector.
Definition: Vector.hpp:219
VectorReference & operator+=(const VectorExpression< E > &e)
Adds the vector expression e element-wise to the wrapped vector.
Definition: Vector.hpp:232
V::ValueType ValueType
The element value type of the wrapped vector.
Definition: Vector.hpp:75
const VectorType & getData() const
Returns a const reference to the wrapped vector.
Definition: Vector.hpp:187
SizeType getSize() const
Returns the wrapped vector's element count.
Definition: Vector.hpp:160
VectorReference & minusAssign(const VectorExpression< E > &e)
Subtracts the vector expression e from the wrapped vector without intermediate temporary.
Definition: Vector.hpp:310
V::SizeType SizeType
The unsigned size type of the wrapped vector.
Definition: Vector.hpp:92
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:151
std::enable_if< IsScalar< T >::value, VectorReference >::type & operator*=(const T &t)
Multiplies every element of the wrapped vector by the scalar t.
Definition: Vector.hpp:258
VectorType & getData()
Returns a reference to the wrapped vector.
Definition: Vector.hpp:196
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: Vector.hpp:102
std::conditional< std::is_const< V >::value, typename V::ConstReference, typename V::Reference >::type Reference
Mutable element reference type (degrades to ConstReference when the wrapped vector is const).
Definition: Vector.hpp:82
std::enable_if< IsScalar< T >::value, VectorReference >::type & operator/=(const T &t)
Divides every element of the wrapped vector by the scalar t.
Definition: Vector.hpp:271
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:121
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:141
friend void swap(VectorReference &r1, VectorReference &r2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:330
VectorReference & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e element-wise from the wrapped vector.
Definition: Vector.hpp:245
bool isEmpty() const
Tells whether the wrapped vector is empty.
Definition: Vector.hpp:178
VectorReference(VectorType &v)
Constructs the reference proxy referring to v.
Definition: Vector.hpp:113
VectorReference & plusAssign(const VectorExpression< E > &e)
Adds the vector expression e to the wrapped vector without intermediate temporary.
Definition: Vector.hpp:297
void swap(VectorReference &r)
Swaps the contents of the two wrapped vectors.
Definition: Vector.hpp:320
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: Vector.hpp:107
Dynamically-sized dense vector with configurable underlying storage.
Definition: Vector.hpp:480
Vector & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this vector without intermediate temporary.
Definition: Vector.hpp:914
Vector & minusAssign(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this vector without intermediate t...
Definition: Vector.hpp:925
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:628
void clear(const ValueType &v=ValueType())
Sets every element of the vector to the value v.
Definition: Vector.hpp:955
Vector & plusAssign(InitializerListType l)
Adds the contents of the initializer list l element-wise to this vector without intermediate temporar...
Definition: Vector.hpp:901
Vector(Vector &&v)
Move-constructs a vector from v (v is left in a valid empty state).
Definition: Vector.hpp:589
Vector & operator-=(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this vector.
Definition: Vector.hpp:813
Vector(InitializerListType l)
Constructs the vector from a brace-initializer list l.
Definition: Vector.hpp:596
Vector & operator=(const Vector &v)
Copy-assigns the elements of v to this vector.
Definition: Vector.hpp:707
ArrayType & getData()
Returns a mutable reference to the underlying storage container.
Definition: Vector.hpp:688
Vector & operator=(Vector &&v)
Move-assigns the elements of v to this vector.
Definition: Vector.hpp:718
Vector(const ArrayType &data)
Constructs a vector that copies its data directly from the underlying-array container data.
Definition: Vector.hpp:575
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:617
const T * ConstPointer
Constant pointer type for raw element access.
Definition: Vector.hpp:523
std::enable_if< IsScalar< T1 >::value, Vector >::type & operator*=(const T1 &t)
Multiplies every element by the scalar t.
Definition: Vector.hpp:839
SizeType getSize() const
Returns the current element count.
Definition: Vector.hpp:670
const ArrayType & getData() const
Returns a const reference to the underlying storage container.
Definition: Vector.hpp:697
Vector(SizeType n)
Constructs a vector of size n with default-initialized elements.
Definition: Vector.hpp:560
std::enable_if< IsScalar< T1 >::value, Vector >::type & operator/=(const T1 &t)
Divides every element by the scalar t.
Definition: Vector.hpp:852
Vector & operator=(InitializerListType l)
Assigns the contents of the initializer list l to this vector (resizes to fit).
Definition: Vector.hpp:729
A::size_type SizeType
The unsigned size type used by the underlying storage container.
Definition: Vector.hpp:503
T ValueType
The scalar value type stored in the vector.
Definition: Vector.hpp:488
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:639
SelfType VectorTemporaryType
Concrete temporary vector type used by expression template machinery.
Definition: Vector.hpp:538
Vector & assign(const VectorExpression< E > &e)
Resizes this vector to match e and assigns the elements of e without intermediate temporary.
Definition: Vector.hpp:865
Vector(const VectorExpression< E > &e)
Constructs the vector from the vector expression e (materializing the expression result).
Definition: Vector.hpp:605
Vector & operator+=(InitializerListType l)
Adds the contents of the initializer list l element-wise to this vector.
Definition: Vector.hpp:777
Vector & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e element-wise from this vector (via a temporary to handle aliasing).
Definition: Vector.hpp:825
T & Reference
Mutable element reference type.
Definition: Vector.hpp:493
void swap(Vector &v)
Swaps the contents of this vector with those of v.
Definition: Vector.hpp:935
Vector & operator+=(const VectorContainer< C > &c)
Adds the contents of the vector container c element-wise to this vector (no alias check needed).
Definition: Vector.hpp:767
Vector & operator=(const VectorContainer< C > &c)
Assigns the contents of the vector container c to this vector (no alias check needed).
Definition: Vector.hpp:741
Vector & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this vector (via a temporary to handle aliasing).
Definition: Vector.hpp:753
Vector(SizeType n, const ValueType &v)
Constructs a vector of size n with every element initialized to v.
Definition: Vector.hpp:568
bool isEmpty() const
Tells whether the vector is empty.
Definition: Vector.hpp:661
Vector & assign(InitializerListType l)
Assigns the contents of the initializer list l to this vector.
Definition: Vector.hpp:877
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:651
Vector(const Vector &v)
Constructs a copy of the vector v.
Definition: Vector.hpp:582
std::initializer_list< T > InitializerListType
Type of the brace-initializer list accepted by the corresponding constructor.
Definition: Vector.hpp:548
Vector & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this vector without intermediate temporary.
Definition: Vector.hpp:890
friend void swap(Vector &v1, Vector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:946
Vector & operator-=(const VectorContainer< C > &c)
Subtracts the contents of the vector container c element-wise from this vector (no alias check needed...
Definition: Vector.hpp:803
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated Vector instances.
Definition: Vector.hpp:543
Vector & operator+=(const VectorExpression< E > &e)
Adds the vector expression e element-wise to this vector (via a temporary to handle aliasing).
Definition: Vector.hpp:789
A::difference_type DifferenceType
The signed difference type used by the underlying storage container.
Definition: Vector.hpp:508
const T & ConstReference
Constant element reference type.
Definition: Vector.hpp:498
A ArrayType
The underlying storage container type.
Definition: Vector.hpp:513
T * Pointer
Pointer type for raw element access.
Definition: Vector.hpp:518
void resize(SizeType n, const ValueType &v=ValueType())
Resizes the vector to n elements.
Definition: Vector.hpp:965
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:533
SizeType getMaxSize() const
Returns the maximum number of elements the underlying storage container can hold.
Definition: Vector.hpp:679
Vector()
Constructs an empty vector (size zero).
Definition: Vector.hpp:553
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:528
Constant vector expression whose elements are all zero.
Definition: Vector.hpp:2524
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:2547
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:2552
ZeroVector(SizeType n)
Constructs a zero vector of size n.
Definition: Vector.hpp:2579
Vector< T > VectorTemporaryType
Concrete temporary vector type used by expression template machinery.
Definition: Vector.hpp:2567
const T & ConstReference
Constant reference type to the zero element.
Definition: Vector.hpp:2542
bool isEmpty() const
Tells whether the vector has zero logical size.
Definition: Vector.hpp:2616
const T & Reference
Reference type (always a const reference — all elements are zero).
Definition: Vector.hpp:2537
ZeroVector(const ZeroVector &v)
Constructs a copy of the zero vector v.
Definition: Vector.hpp:2586
ZeroVector & operator=(const ZeroVector &v)
Copy-assigns the logical size from v.
Definition: Vector.hpp:2644
ZeroVector()
Constructs an empty zero vector.
Definition: Vector.hpp:2572
friend void swap(ZeroVector &v1, ZeroVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:2674
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2562
T ValueType
The scalar value type.
Definition: Vector.hpp:2532
ConstReference operator()(SizeType i) const
Returns a const reference to the zero element.
Definition: Vector.hpp:2606
SizeType getMaxSize() const
Returns the maximum representable element count.
Definition: Vector.hpp:2634
ConstReference operator[](SizeType i) const
Returns a const reference to the zero element.
Definition: Vector.hpp:2595
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2557
void swap(ZeroVector &v)
Swaps the logical sizes with v.
Definition: Vector.hpp:2663
SizeType getSize() const
Returns the logical element count.
Definition: Vector.hpp:2625
void resize(SizeType n)
Resizes the logical element count to n.
Definition: Vector.hpp:2654
constexpr unsigned int A
Generic type that covers any element except hydrogen.
Definition: AtomType.hpp:637
constexpr unsigned int N
Specifies Nitrogen.
Definition: AtomType.hpp:97
constexpr unsigned int V
Specifies Vanadium.
Definition: AtomType.hpp:177
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
constexpr unsigned int r
Specifies that the stereocenter has r configuration.
Definition: CIPDescriptor.hpp:76
CVector< unsigned long, 4 > Vector4UL
Bounded 4 element vector holding unsigned integers of type unsigned long.
Definition: Vector.hpp:3258
CVector< float, 2 > Vector2F
Bounded 2 element vector holding floating-point values of type float.
Definition: Vector.hpp:3198
QuaternionVectorAdapter< E > vec(QuaternionExpression< E > &e)
Creates a mutable Math::QuaternionVectorAdapter view of the quaternion expression e.
Definition: QuaternionAdapter.hpp:404
SparseVector< unsigned long > SparseULVector
Unbounded sparse vector holding unsigned integers of type unsigned long.
Definition: Vector.hpp:3298
CVector< double, 7 > Vector7D
Bounded 7 element vector holding floating-point values of type double.
Definition: Vector.hpp:3228
SparseVector< float > SparseFVector
Unbounded sparse vector holding floating-point values of type float.
Definition: Vector.hpp:3283
UnitVector< unsigned long > ULUnitVector
Memory-efficient immutable unit vector with element values of type unsigned long.
Definition: Vector.hpp:3193
UnitVector< float > FUnitVector
Memory-efficient immutable unit vector with element values of type float.
Definition: Vector.hpp:3178
CVector< double, 4 > Vector4D
Bounded 4 element vector holding floating-point values of type double.
Definition: Vector.hpp:3223
SparseVector< long > SparseLVector
Unbounded sparse vector holding signed integers of type long.
Definition: Vector.hpp:3293
ScalarVector< double > DScalarVector
Memory-efficient immutable vector where all elements have the same value of type double.
Definition: Vector.hpp:3143
CVector< float, 4 > Vector4F
Bounded 4 element vector holding floating-point values of type float.
Definition: Vector.hpp:3208
CVector< double, 2 > Vector2D
Bounded 2 element vector holding floating-point values of type double.
Definition: Vector.hpp:3213
Vector< float > FVector
Unbounded dense vector holding floating-point values of type float.
Definition: Vector.hpp:3263
Vector< double > DVector
Unbounded dense vector holding floating-point values of type double.
Definition: Vector.hpp:3268
CVector< double, 3 > Vector3D
Bounded 3 element vector holding floating-point values of type double.
Definition: Vector.hpp:3218
UnitVector< double > DUnitVector
Memory-efficient immutable unit vector with element values of type double.
Definition: Vector.hpp:3183
UnitVector< long > LUnitVector
Memory-efficient immutable unit vector with element values of type long.
Definition: Vector.hpp:3188
ZeroVector< long > LZeroVector
Memory-efficient immutable vector where all elements have the value zero of type long.
Definition: Vector.hpp:3168
ScalarVector< long > LScalarVector
Memory-efficient immutable vector where all elements have the same value of type long.
Definition: Vector.hpp:3148
ScalarVector< unsigned long > ULScalarVector
Memory-efficient immutable vector where all elements have the same value of type unsigned long.
Definition: Vector.hpp:3153
ZeroVector< unsigned long > ULZeroVector
Memory-efficient immutable vector where all elements have the value zero of type unsigned long.
Definition: Vector.hpp:3173
CVector< float, 3 > Vector3F
Bounded 3 element vector holding floating-point values of type float.
Definition: Vector.hpp:3203
Vector< unsigned long > ULVector
Unbounded dense vector holding unsigned integers of type unsigned long.
Definition: Vector.hpp:3278
CVector< long, 4 > Vector4L
Bounded 4 element vector holding signed integers of type long.
Definition: Vector.hpp:3243
ZeroVector< double > DZeroVector
Memory-efficient immutable vector where all elements have the value zero of type double.
Definition: Vector.hpp:3163
CVector< unsigned long, 2 > Vector2UL
Bounded 2 element vector holding unsigned integers of type unsigned long.
Definition: Vector.hpp:3248
CVector< long, 3 > Vector3L
Bounded 3 element vector holding signed integers of type long.
Definition: Vector.hpp:3238
CVector< long, 2 > Vector2L
Bounded 2 element vector holding signed integers of type long.
Definition: Vector.hpp:3233
ZeroVector< float > FZeroVector
Memory-efficient immutable vector where all elements have the value zero of type float.
Definition: Vector.hpp:3158
SparseVector< double > SparseDVector
Unbounded sparse vector holding floating-point values of type double.
Definition: Vector.hpp:3288
ScalarVector< float > FScalarVector
Memory-efficient immutable vector where all elements have the same value of type float.
Definition: Vector.hpp:3138
Vector< long > LVector
Unbounded dense vector holding signed integers of type long.
Definition: Vector.hpp:3273
CVector< unsigned long, 3 > Vector3UL
Bounded 3 element vector holding unsigned integers of type unsigned long.
Definition: Vector.hpp:3253
The namespace of the Chemical Data Processing Library.
Selects a concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:323