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:
68  typedef V VectorType;
70  typedef typename V::ValueType ValueType;
72  typedef typename std::conditional<std::is_const<V>::value,
73  typename V::ConstReference,
74  typename V::Reference>::type Reference;
76  typedef typename V::ConstReference ConstReference;
78  typedef typename V::SizeType SizeType;
80  typedef typename V::DifferenceType DifferenceType;
84  typedef const SelfType ConstClosureType;
85 
91  data(v) {}
92 
99  {
100  return data[i];
101  }
102 
109  {
110  return data[i];
111  }
112 
119  {
120  return data(i);
121  }
122 
129  {
130  return data(i);
131  }
132 
138  {
139  return data.getSize();
140  }
141 
147  {
148  return data.getMaxSize();
149  }
150 
155  bool isEmpty() const
156  {
157  return data.isEmpty();
158  }
159 
164  const VectorType& getData() const
165  {
166  return data;
167  }
168 
174  {
175  return data;
176  }
177 
184  {
185  data.operator=(r.data);
186  return *this;
187  }
188 
195  template <typename E>
197  {
198  data.operator=(e);
199  return *this;
200  }
201 
208  template <typename E>
210  {
211  data.operator+=(e);
212  return *this;
213  }
214 
221  template <typename E>
223  {
224  data.operator-=(e);
225  return *this;
226  }
227 
234  template <typename T>
235  typename std::enable_if<IsScalar<T>::value, VectorReference>::type& operator*=(const T& t)
236  {
237  data.operator*=(t);
238  return *this;
239  }
240 
247  template <typename T>
248  typename std::enable_if<IsScalar<T>::value, VectorReference>::type& operator/=(const T& t)
249  {
250  data.operator/=(t);
251  return *this;
252  }
253 
260  template <typename E>
262  {
263  data.assign(e);
264  return *this;
265  }
266 
273  template <typename E>
275  {
276  data.plusAssign(e);
277  return *this;
278  }
279 
286  template <typename E>
288  {
289  data.minusAssign(e);
290  return *this;
291  }
292 
298  {
299  data.swap(r.data);
300  }
301 
307  friend void swap(VectorReference& r1, VectorReference& r2)
308  {
309  r1.swap(r2);
310  }
311 
312  private:
313  VectorType& data;
314  };
315 
316  template <typename T, typename A>
317  class Vector;
318 
323  template <typename T>
324  class InitListVector : public VectorContainer<InitListVector<T> >
325  {
326 
327  public:
330  typedef std::initializer_list<T> InitializerListType;
332  typedef typename InitializerListType::value_type ValueType;
334  typedef typename InitializerListType::const_reference ConstReference;
336  typedef typename InitializerListType::reference Reference;
338  typedef typename InitializerListType::size_type SizeType;
340  typedef typename std::ptrdiff_t DifferenceType;
344  typedef const SelfType ConstClosureType;
347 
353  list(l) {}
354 
362  {
363  return this->operator()(i);
364  }
365 
373  {
374  return this->operator()(i);
375  }
376 
384  {
385  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
386  return *(list.begin() + i);
387  }
388 
396  {
397  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
398  return *(list.begin() + i);
399  }
400 
406  {
407  return list.size();
408  }
409 
414  bool isEmpty() const
415  {
416  return (list.size() == 0);
417  }
418 
419  private:
420  InitializerListType list;
421  };
422 
428  template <typename T, typename A = std::vector<T> >
429  class Vector : public VectorContainer<Vector<T, A> >
430  {
431 
432  typedef Vector<T, A> SelfType;
433 
434  public:
436  typedef T ValueType;
438  typedef T& Reference;
440  typedef const T& ConstReference;
442  typedef typename A::size_type SizeType;
444  typedef typename A::difference_type DifferenceType;
446  typedef A ArrayType;
448  typedef T* Pointer;
450  typedef const T* ConstPointer;
458  typedef std::shared_ptr<SelfType> SharedPointer;
460  typedef std::initializer_list<T> InitializerListType;
461 
466  data() {}
467 
472  explicit Vector(SizeType n):
473  data(storageSize(n)) {}
474 
480  Vector(SizeType n, const ValueType& v):
481  data(storageSize(n), v) {}
482 
487  Vector(const ArrayType& data):
488  data(data) {}
489 
494  Vector(const Vector& v):
495  data(v.data) {}
496 
502  data(std::move(v.data)) {}
503 
509  data(l) {}
510 
516  template <typename E>
518  data(storageSize(e().getSize()))
519  {
520  vectorAssignVector<ScalarAssignment>(*this, e);
521  }
522 
530  {
531  return this->operator()(i);
532  }
533 
541  {
542  return this->operator()(i);
543  }
544 
552  {
553  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
554  return data[i];
555  }
556 
564  {
565  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
566  return data[i];
567  }
568 
573  bool isEmpty() const
574  {
575  return data.empty();
576  }
577 
583  {
584  return data.size();
585  }
586 
592  {
593  return data.max_size();
594  }
595 
601  {
602  return data;
603  }
604 
609  const ArrayType& getData() const
610  {
611  return data;
612  }
613 
620  {
621  data = v.data;
622  return *this;
623  }
624 
631  {
632  data = std::move(v.data);
633  return *this;
634  }
635 
642  {
643  return assign(l);
644  }
645 
652  template <typename C>
654  {
655  return assign(c);
656  }
657 
664  template <typename E>
666  {
667  Vector tmp(e);
668  swap(tmp);
669  return *this;
670  }
671 
678  template <typename C>
680  {
681  return plusAssign(c);
682  }
683 
690  {
691  return plusAssign(l);
692  }
693 
700  template <typename E>
702  {
703  Vector tmp(*this + e);
704  swap(tmp);
705  return *this;
706  }
707 
714  template <typename C>
716  {
717  return minusAssign(c);
718  }
719 
726  {
727  return minusAssign(l);
728  }
729 
736  template <typename E>
738  {
739  Vector tmp(*this - e);
740  swap(tmp);
741  return *this;
742  }
743 
750  template <typename T1>
751  typename std::enable_if<IsScalar<T1>::value, Vector>::type& operator*=(const T1& t)
752  {
753  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
754  return *this;
755  }
756 
763  template <typename T1>
764  typename std::enable_if<IsScalar<T1>::value, Vector>::type& operator/=(const T1& t)
765  {
766  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
767  return *this;
768  }
769 
776  template <typename E>
778  {
779  resize(e().getSize());
780  vectorAssignVector<ScalarAssignment>(*this, e);
781  return *this;
782  }
783 
790  {
791  data = l;
792  return *this;
793  }
794 
801  template <typename E>
803  {
804  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
805  return *this;
806  }
807 
814  {
815  vectorAssignVector<ScalarAdditionAssignment>(*this, InitListVector<ValueType>(l));
816  return *this;
817  }
818 
825  template <typename E>
827  {
828  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
829  return *this;
830  }
831 
838  {
839  vectorAssignVector<ScalarSubtractionAssignment>(*this, InitListVector<ValueType>(l));
840  return *this;
841  }
842 
847  void swap(Vector& v)
848  {
849  if (this != &v)
850  std::swap(data, v.data);
851  }
852 
858  friend void swap(Vector& v1, Vector& v2)
859  {
860  v1.swap(v2);
861  }
862 
867  void clear(const ValueType& v = ValueType())
868  {
869  std::fill(data.begin(), data.end(), v);
870  }
871 
877  void resize(SizeType n, const ValueType& v = ValueType())
878  {
879  data.resize(storageSize(n), v);
880  }
881 
882  private:
883  SizeType storageSize(SizeType n)
884  {
885  return CDPL_MATH_CHECK_MAX_SIZE(n, data.max_size(), Base::SizeError);
886  }
887 
888  ArrayType data;
889  };
890 
896  template <typename T, typename A = std::unordered_map<std::size_t, T> >
897  class SparseVector : public VectorContainer<SparseVector<T, A> >
898  {
899 
900  typedef SparseVector<T> SelfType;
901 
902  public:
903  typedef T ValueType;
905  typedef std::size_t SizeType;
907  typedef std::ptrdiff_t DifferenceType;
909  typedef typename A::key_type KeyType;
911  typedef const T& ConstReference;
915  typedef A ArrayType;
917  typedef T* Pointer;
919  typedef const T* ConstPointer;
927  typedef std::shared_ptr<SelfType> SharedPointer;
929  typedef std::initializer_list<T> InitializerListType;
930 
935  data(), size(0) {}
936 
941  explicit SparseVector(SizeType n):
942  data(), size(storageSize(n)) {}
943 
949  data(v.data), size(v.size) {}
950 
956  data(), size(0)
957  {
958  swap(v);
959  }
960 
966  {
967  assign(l);
968  }
969 
975  template <typename E>
977  data(), size(0)
978  {
979  assign(e);
980  }
981 
989  {
990  return this->operator()(i);
991  }
992 
1000  {
1001  return this->operator()(i);
1002  }
1003 
1011  {
1012  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
1013  return Reference(*this, i);
1014  }
1015 
1023  {
1024  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
1025 
1026  typename ArrayType::const_iterator it = data.find(i);
1027 
1028  if (it == data.end())
1029  return zero;
1030 
1031  return it->second;
1032  }
1033 
1039  {
1040  return data.size();
1041  }
1042 
1047  bool isEmpty() const
1048  {
1049  return (size == 0);
1050  }
1051 
1057  {
1058  return size;
1059  }
1060 
1066  {
1067  return std::min(SizeType(data.max_size()), std::numeric_limits<SizeType>::max());
1068  }
1069 
1075  {
1076  return data;
1077  }
1078 
1083  const ArrayType& getData() const
1084  {
1085  return data;
1086  }
1087 
1094  {
1095  data = v.data;
1096  size = v.size;
1097  return *this;
1098  }
1099 
1106  {
1107  swap(v);
1108  return *this;
1109  }
1110 
1117  {
1118  return assign(l);
1119  }
1120 
1127  template <typename C>
1129  {
1130  return assign(c);
1131  }
1132 
1139  template <typename E>
1141  {
1142  SparseVector tmp(e);
1143  swap(tmp);
1144  return *this;
1145  }
1146 
1153  template <typename C>
1155  {
1156  return plusAssign(c);
1157  }
1158 
1165  {
1166  return plusAssign(l);
1167  }
1168 
1175  template <typename E>
1177  {
1178  SparseVector tmp(*this + e);
1179  swap(tmp);
1180  return *this;
1181  }
1182 
1189  template <typename C>
1191  {
1192  return minusAssign(c);
1193  }
1194 
1201  {
1202  return minusAssign(l);
1203  }
1204 
1211  template <typename E>
1213  {
1214  SparseVector tmp(*this - e);
1215  swap(tmp);
1216  return *this;
1217  }
1218 
1225  template <typename T1>
1226  typename std::enable_if<IsScalar<T1>::value, SparseVector>::type& operator*=(const T1& t)
1227  {
1228  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
1229  return *this;
1230  }
1231 
1238  template <typename T1>
1239  typename std::enable_if<IsScalar<T1>::value, SparseVector>::type& operator/=(const T1& t)
1240  {
1241  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
1242  return *this;
1243  }
1244 
1251  template <typename E>
1253  {
1254  resize(e().getSize());
1255  vectorAssignVector<ScalarAssignment>(*this, e);
1256  return *this;
1257  }
1258 
1265  {
1266  resize(l.size());
1267  vectorAssignVector<ScalarAssignment>(*this, InitListVector<ValueType>(l));
1268  return *this;
1269  }
1270 
1277  template <typename E>
1279  {
1280  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
1281  return *this;
1282  }
1283 
1290  {
1291  vectorAssignVector<ScalarAdditionAssignment>(*this, InitListVector<ValueType>(l));
1292  return *this;
1293  }
1294 
1301  template <typename E>
1303  {
1304  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
1305  return *this;
1306  }
1307 
1314  {
1315  vectorAssignVector<ScalarSubtractionAssignment>(*this, InitListVector<ValueType>(l));
1316  return *this;
1317  }
1318 
1324  {
1325  if (this != &v) {
1326  std::swap(data, v.data);
1327  std::swap(size, v.size);
1328  }
1329  }
1330 
1336  friend void swap(SparseVector& v1, SparseVector& v2)
1337  {
1338  v1.swap(v2);
1339  }
1340 
1344  void clear()
1345  {
1346  data.clear();
1347  }
1348 
1354  {
1355  n = storageSize(n);
1356 
1357  for (typename ArrayType::iterator it = data.begin(); it != data.end();) {
1358  if (it->first >= n)
1359  it = data.erase(it);
1360  else
1361  ++it;
1362  }
1363 
1364  size = n;
1365  }
1366 
1367  private:
1368  SizeType storageSize(SizeType n)
1369  {
1371  }
1372 
1373  ArrayType data;
1374  SizeType size;
1375  static const ValueType zero;
1376  };
1377 
1378  template <typename T, typename A>
1379  const typename SparseVector<T, A>::ValueType SparseVector<T, A>::zero = SparseVector<T, A>::ValueType();
1380 
1386  template <typename T, std::size_t N>
1387  class BoundedVector : public VectorContainer<BoundedVector<T, N> >
1388  {
1389 
1390  typedef BoundedVector<T, N> SelfType;
1391 
1392  public:
1394  typedef T ValueType;
1396  typedef T& Reference;
1398  typedef const T& ConstReference;
1400  typedef std::size_t SizeType;
1402  typedef std::ptrdiff_t DifferenceType;
1406  typedef T* Pointer;
1408  typedef const T* ConstPointer;
1416  typedef std::shared_ptr<SelfType> SharedPointer;
1418  typedef std::initializer_list<T> InitializerListType;
1419 
1421  static const SizeType MaxSize = N;
1422 
1427  size(0) {}
1428 
1435  size(0)
1436  {
1437  resize(n);
1438  }
1439 
1447  size(0)
1448  {
1449  resize(n, v);
1450  }
1451 
1457  size(v.size)
1458  {
1459  std::copy(v.data, v.data + v.size, data);
1460  }
1461 
1468  {
1469  assign(l);
1470  }
1471 
1478  template <typename E>
1480  size(0)
1481  {
1482  assign(e);
1483  }
1484 
1492  {
1493  return this->operator()(i);
1494  }
1495 
1503  {
1504  return this->operator()(i);
1505  }
1506 
1514  {
1515  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
1516  return data[i];
1517  }
1518 
1526  {
1527  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
1528  return data[i];
1529  }
1530 
1535  bool isEmpty() const
1536  {
1537  return (size == 0);
1538  }
1539 
1545  {
1546  return size;
1547  }
1548 
1554  {
1555  return N;
1556  }
1557 
1563  {
1564  return data;
1565  }
1566 
1572  {
1573  return data;
1574  }
1575 
1582  {
1583  if (this != &v) {
1584  std::copy(v.data, v.data + v.size, data);
1585  size = v.size;
1586  }
1587 
1588  return *this;
1589  }
1590 
1598  {
1599  return assign(l);
1600  }
1601 
1608  template <typename C>
1610  {
1611  return assign(c);
1612  }
1613 
1620  template <typename E>
1622  {
1623  BoundedVector tmp(e);
1624  return this-> operator=(tmp);
1625  }
1626 
1633  template <typename C>
1635  {
1636  return plusAssign(c);
1637  }
1638 
1645  {
1646  return plusAssign(l);
1647  }
1648 
1655  template <typename E>
1657  {
1658  BoundedVector tmp(*this + e);
1659  return this-> operator=(tmp);
1660  }
1661 
1668  template <typename C>
1670  {
1671  return minusAssign(c);
1672  }
1673 
1680  {
1681  return minusAssign(l);
1682  }
1683 
1690  template <typename E>
1692  {
1693  BoundedVector tmp(*this - e);
1694  return this-> operator=(tmp);
1695  }
1696 
1703  template <typename T1>
1704  typename std::enable_if<IsScalar<T1>::value, BoundedVector>::type& operator*=(const T1& t)
1705  {
1706  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
1707  return *this;
1708  }
1709 
1716  template <typename T1>
1717  typename std::enable_if<IsScalar<T1>::value, BoundedVector>::type& operator/=(const T1& t)
1718  {
1719  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
1720  return *this;
1721  }
1722 
1730  template <typename E>
1732  {
1733  resize(e().getSize());
1734  vectorAssignVector<ScalarAssignment>(*this, e);
1735  return *this;
1736  }
1737 
1745  {
1746  resize(l.size());
1747  std::copy(l.begin(), l.begin() + size, data);
1748  return *this;
1749  }
1750 
1757  template <typename E>
1759  {
1760  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
1761  return *this;
1762  }
1763 
1770  {
1771  vectorAssignVector<ScalarAdditionAssignment>(*this, InitListVector<ValueType>(l));
1772  return *this;
1773  }
1774 
1781  template <typename E>
1783  {
1784  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
1785  return *this;
1786  }
1787 
1794  {
1795  vectorAssignVector<ScalarSubtractionAssignment>(*this, InitListVector<ValueType>(l));
1796  return *this;
1797  }
1798 
1804  {
1805  if (this != &v) {
1806  std::swap_ranges(data, data + std::max(size, v.size), v.data);
1807  std::swap(size, v.size);
1808  }
1809  }
1810 
1816  friend void swap(BoundedVector& v1, BoundedVector& v2)
1817  {
1818  v1.swap(v2);
1819  }
1820 
1825  void clear(const ValueType& v = ValueType())
1826  {
1827  std::fill(data, data + size, v);
1828  }
1829 
1836  {
1837  size = storageSize(n);
1838  }
1839 
1846  void resize(SizeType n, const ValueType& v)
1847  {
1848  n = storageSize(n);
1849 
1850  if (n > size)
1851  std::fill(data + size, data + n, v);
1852 
1853  size = n;
1854  }
1855 
1856  private:
1857  SizeType storageSize(SizeType n)
1858  {
1860  }
1861 
1862  ArrayType data;
1863  SizeType size;
1864  };
1865 
1866  template <typename T, std::size_t N>
1868 
1874  template <typename T, std::size_t N>
1875  class CVector : public VectorContainer<CVector<T, N> >
1876  {
1877 
1878  typedef CVector<T, N> SelfType;
1879 
1880  public:
1882  typedef T ValueType;
1884  typedef T& Reference;
1886  typedef const T& ConstReference;
1888  typedef std::size_t SizeType;
1890  typedef std::ptrdiff_t DifferenceType;
1894  typedef T* Pointer;
1896  typedef const T* ConstPointer;
1904  typedef std::shared_ptr<SelfType> SharedPointer;
1906  typedef std::initializer_list<T> InitializerListType;
1907 
1909  static const SizeType Size = N;
1910 
1915  {
1916  clear();
1917  }
1918 
1923  explicit CVector(const ValueType& v)
1924  {
1925  clear(v);
1926  }
1927 
1932  CVector(const CVector& v)
1933  {
1934  std::copy(v.data, v.data + N, data);
1935  }
1936 
1942  {
1943  assign(l);
1944  }
1945 
1951  template <typename E>
1953  {
1954  vectorAssignVector<ScalarAssignment>(*this, e);
1955  }
1956 
1964  {
1965  return this->operator()(i);
1966  }
1967 
1975  {
1976  return this->operator()(i);
1977  }
1978 
1986  {
1987  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
1988  return data[i];
1989  }
1990 
1998  {
1999  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
2000  return data[i];
2001  }
2002 
2007  bool isEmpty() const
2008  {
2009  return (N == 0);
2010  }
2011 
2017  {
2018  return N;
2019  }
2020 
2026  {
2027  return N;
2028  }
2029 
2035  {
2036  return data;
2037  }
2038 
2044  {
2045  return data;
2046  }
2047 
2054  {
2055  if (this != &v)
2056  std::copy(v.data, v.data + N, data);
2057 
2058  return *this;
2059  }
2060 
2067  {
2068  return assign(l);
2069  }
2070 
2077  template <typename C>
2079  {
2080  return assign(c);
2081  }
2082 
2089  template <typename E>
2091  {
2092  CVector tmp(e);
2093  return this->operator=(tmp);
2094  }
2095 
2102  template <typename C>
2104  {
2105  return plusAssign(c);
2106  }
2107 
2114  {
2115  return plusAssign(l);
2116  }
2117 
2124  template <typename E>
2126  {
2127  CVector tmp(*this + e);
2128  return this->operator=(tmp);
2129  }
2130 
2137  template <typename C>
2139  {
2140  return minusAssign(c);
2141  }
2142 
2149  {
2150  return minusAssign(l);
2151  }
2152 
2159  template <typename E>
2161  {
2162  CVector tmp(*this - e);
2163  return this->operator=(tmp);
2164  }
2165 
2172  template <typename T1>
2173  typename std::enable_if<IsScalar<T1>::value, CVector>::type& operator*=(const T1& t)
2174  {
2175  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
2176  return *this;
2177  }
2178 
2185  template <typename T1>
2186  typename std::enable_if<IsScalar<T1>::value, CVector>::type& operator/=(const T1& t)
2187  {
2188  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
2189  return *this;
2190  }
2191 
2198  template <typename E>
2200  {
2201  vectorAssignVector<ScalarAssignment>(*this, e);
2202  return *this;
2203  }
2204 
2212  {
2214  std::copy(l.begin(), l.begin() + n, data);
2215 
2216  if (n < N)
2217  std::fill(data + n, data + N, ValueType());
2218 
2219  return *this;
2220  }
2221 
2228  template <typename E>
2230  {
2231  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
2232  return *this;
2233  }
2234 
2241  {
2242  vectorAssignVector<ScalarAdditionAssignment>(*this, InitListVector<ValueType>(l));
2243  return *this;
2244  }
2245 
2252  template <typename E>
2254  {
2255  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
2256  return *this;
2257  }
2258 
2265  {
2266  vectorAssignVector<ScalarSubtractionAssignment>(*this, InitListVector<ValueType>(l));
2267  return *this;
2268  }
2269 
2274  void swap(CVector& v)
2275  {
2276  if (this != &v)
2277  std::swap_ranges(data, data + N, v.data);
2278  }
2279 
2285  friend void swap(CVector& v1, CVector& v2)
2286  {
2287  v1.swap(v2);
2288  }
2289 
2294  void clear(const ValueType& v = ValueType())
2295  {
2296  std::fill(data, data + N, v);
2297  }
2298 
2299  private:
2300  ArrayType data;
2301  };
2302 
2303  template <typename T, std::size_t N>
2305 
2310  template <typename T>
2311  class ZeroVector : public VectorContainer<ZeroVector<T> >
2312  {
2313 
2314  typedef ZeroVector<T> SelfType;
2315 
2316  public:
2318  typedef T ValueType;
2320  typedef const T& Reference;
2322  typedef const T& ConstReference;
2324  typedef std::size_t SizeType;
2326  typedef std::ptrdiff_t DifferenceType;
2333 
2338  size(0) {}
2339 
2344  explicit ZeroVector(SizeType n):
2345  size(n) {}
2346 
2352  size(v.size) {}
2353 
2361  {
2362  return this->operator()(i);
2363  }
2364 
2372  {
2373  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
2374  return zero;
2375  }
2376 
2381  bool isEmpty() const
2382  {
2383  return (size == 0);
2384  }
2385 
2391  {
2392  return size;
2393  }
2394 
2400  {
2401  return std::numeric_limits<SizeType>::max();
2402  }
2403 
2410  {
2411  size = v.size;
2412  return *this;
2413  }
2414 
2420  {
2421  size = n;
2422  }
2423 
2428  void swap(ZeroVector& v)
2429  {
2430  if (this != &v)
2431  std::swap(size, v.size);
2432  }
2433 
2439  friend void swap(ZeroVector& v1, ZeroVector& v2)
2440  {
2441  v1.swap(v2);
2442  }
2443 
2444  private:
2445  SizeType size;
2446  static const ValueType zero;
2447  };
2448 
2449  template <typename T>
2450  const typename ZeroVector<T>::ValueType ZeroVector<T>::zero = ZeroVector<T>::ValueType();
2451 
2456  template <typename T>
2457  class UnitVector : public VectorContainer<UnitVector<T> >
2458  {
2459 
2460  typedef UnitVector<T> SelfType;
2461 
2462  public:
2464  typedef T ValueType;
2466  typedef const T& Reference;
2468  typedef const T& ConstReference;
2470  typedef std::size_t SizeType;
2472  typedef std::ptrdiff_t DifferenceType;
2479 
2484  size(0), index(0) {}
2485 
2492  size(n), index(i) {}
2493 
2499  size(v.size), index(v.index) {}
2500 
2508  {
2509  return this->operator()(i);
2510  }
2511 
2519  {
2520  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
2521 
2522  return (i == index ? one : zero);
2523  }
2524 
2529  bool isEmpty() const
2530  {
2531  return (size == 0);
2532  }
2533 
2539  {
2540  return size;
2541  }
2542 
2548  {
2549  return index;
2550  }
2551 
2557  {
2558  return std::numeric_limits<SizeType>::max();
2559  }
2560 
2567  {
2568  if (this != &v) {
2569  size = v.size;
2570  index = v.index;
2571  }
2572 
2573  return *this;
2574  }
2575 
2581  {
2582  size = n;
2583  }
2584 
2589  void swap(UnitVector& v)
2590  {
2591  if (this != &v) {
2592  std::swap(size, v.size);
2593  std::swap(index, v.index);
2594  }
2595  }
2596 
2602  friend void swap(UnitVector& v1, UnitVector& v2)
2603  {
2604  v1.swap(v2);
2605  }
2606 
2607  private:
2608  SizeType size;
2609  SizeType index;
2610  static const ValueType zero;
2611  static const ValueType one;
2612  };
2613 
2614  template <typename T>
2615  const typename UnitVector<T>::ValueType UnitVector<T>::zero = UnitVector<T>::ValueType();
2616  template <typename T>
2617  const typename UnitVector<T>::ValueType UnitVector<T>::one = UnitVector<T>::ValueType(1);
2618 
2623  template <typename T>
2624  class ScalarVector : public VectorContainer<ScalarVector<T> >
2625  {
2626 
2627  typedef ScalarVector<T> SelfType;
2628 
2629  public:
2631  typedef T ValueType;
2633  typedef const T& Reference;
2635  typedef const T& ConstReference;
2637  typedef std::size_t SizeType;
2639  typedef std::ptrdiff_t DifferenceType;
2646 
2651  size(0) {}
2652 
2659  size(n), value(v) {}
2660 
2666  size(v.size), value(v.value) {}
2667 
2675  {
2676  return this->operator()(i);
2677  }
2678 
2686  {
2687  CDPL_MATH_CHECK(i < getSize(), "Index out of range", Base::IndexError);
2688  return value;
2689  }
2690 
2695  bool isEmpty() const
2696  {
2697  return (size == 0);
2698  }
2699 
2705  {
2706  return size;
2707  }
2708 
2714  {
2715  return std::numeric_limits<SizeType>::max();
2716  }
2717 
2724  {
2725  if (this != &v) {
2726  size = v.size;
2727  value = v.value;
2728  }
2729 
2730  return *this;
2731  }
2732 
2738  {
2739  size = n;
2740  }
2741 
2747  {
2748  if (this != &v) {
2749  std::swap(size, v.size);
2750  std::swap(value, v.value);
2751  }
2752  }
2753 
2759  friend void swap(ScalarVector& v1, ScalarVector& v2)
2760  {
2761  v1.swap(v2);
2762  }
2763 
2764  private:
2765  SizeType size;
2766  ValueType value;
2767  };
2768 
2773  template <typename V>
2775  {};
2776 
2781  template <typename V>
2783  {};
2784 
2793  template <typename T1, typename T2>
2795  vec(const T1& t1, const T2& t2)
2796  {
2798 
2799  v(0) = t1;
2800  v(1) = t2;
2801 
2802  return v;
2803  }
2804 
2815  template <typename T1, typename T2, typename T3>
2816  CVector<typename CommonType<typename CommonType<T1, T2>::Type, T3>::Type, 3>
2817  vec(const T1& t1, const T2& t2, const T3& t3)
2818  {
2820 
2821  v(0) = t1;
2822  v(1) = t2;
2823  v(2) = t3;
2824 
2825  return v;
2826  }
2827 
2840  template <typename T1, typename T2, typename T3, typename T4>
2841  CVector<typename CommonType<typename CommonType<typename CommonType<T1, T2>::Type, T3>::Type, T4>::Type, 4>
2842  vec(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
2843  {
2845 
2846  v(0) = t1;
2847  v(1) = t2;
2848  v(2) = t3;
2849  v(3) = t4;
2850 
2851  return v;
2852  }
2853 
2858 
2863 
2868 
2873 
2878 
2883 
2888 
2893 
2898 
2903 
2908 
2913 
2918 
2923 
2928 
2933 
2938 
2943 
2948 
2953 
2958 
2963 
2968 
2973 
2978 
2983 
2988 
2993 
2998 
3003 
3008 
3013 
3018  } // namespace Math
3019 } // namespace CDPL
3020 
3021 #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:1388
static const SizeType MaxSize
The compile-time maximum capacity N.
Definition: Vector.hpp:1421
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated BoundedVector instances.
Definition: Vector.hpp:1416
BoundedVector & operator=(const BoundedVector &v)
Copy-assigns the elements of v to this bounded vector.
Definition: Vector.hpp:1581
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:1634
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i (alias for operator()).
Definition: Vector.hpp:1502
T & Reference
Mutable reference type to an element.
Definition: Vector.hpp:1396
void resize(SizeType n, const ValueType &v)
Resizes the vector to n elements; newly added elements are set to v.
Definition: Vector.hpp:1846
void swap(BoundedVector &v)
Swaps the contents of this bounded vector with those of v.
Definition: Vector.hpp:1803
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:1656
void clear(const ValueType &v=ValueType())
Sets every element of the vector to the value v (size is unchanged).
Definition: Vector.hpp:1825
Pointer getData()
Returns a mutable pointer to the contiguous element array.
Definition: Vector.hpp:1562
BoundedVector(const VectorExpression< E > &e)
Constructs a bounded vector from the vector expression e.
Definition: Vector.hpp:1479
BoundedVector & assign(InitializerListType l)
Resizes this vector to match l and copies the elements of l in.
Definition: Vector.hpp:1744
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:1513
std::enable_if< IsScalar< T1 >::value, BoundedVector >::type & operator*=(const T1 &t)
Multiplies every element by the scalar t.
Definition: Vector.hpp:1704
void resize(SizeType n)
Resizes the vector to n elements (new elements are left value-uninitialized).
Definition: Vector.hpp:1835
BoundedVector & assign(const VectorExpression< E > &e)
Resizes this vector to match e and assigns the elements of e without intermediate temporary.
Definition: Vector.hpp:1731
std::initializer_list< T > InitializerListType
The initializer-list type accepted by constructors and assignment.
Definition: Vector.hpp:1418
BoundedVector & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this vector without intermediate temporary.
Definition: Vector.hpp:1782
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:1525
ConstPointer getData() const
Returns a const pointer to the contiguous element array.
Definition: Vector.hpp:1571
SizeType getMaxSize() const
Returns the compile-time maximum capacity N.
Definition: Vector.hpp:1553
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:1412
BoundedVector(InitializerListType l)
Constructs a bounded vector with the contents of the initializer list l.
Definition: Vector.hpp:1467
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:1609
BoundedVector & plusAssign(InitializerListType l)
Adds the contents of the initializer list l element-wise to this vector without intermediate temporar...
Definition: Vector.hpp:1769
const T * ConstPointer
Constant pointer type for raw access to the element array.
Definition: Vector.hpp:1408
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i (alias for operator()).
Definition: Vector.hpp:1491
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:1402
BoundedVector()
Constructs an empty bounded vector (size zero, capacity N).
Definition: Vector.hpp:1426
BoundedVector & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this vector without intermediate temporary.
Definition: Vector.hpp:1758
SizeType getSize() const
Returns the current element count.
Definition: Vector.hpp:1544
BoundedVector(SizeType n)
Constructs a bounded vector of size n with value-initialized elements.
Definition: Vector.hpp:1434
BoundedVector & minusAssign(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this vector without intermediate t...
Definition: Vector.hpp:1793
BoundedVector & operator-=(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this bounded vector.
Definition: Vector.hpp:1679
T ValueType
The scalar value type.
Definition: Vector.hpp:1394
bool isEmpty() const
Tells whether the vector is empty.
Definition: Vector.hpp:1535
ValueType ArrayType[N]
The fixed-capacity C-array type used for in-memory storage.
Definition: Vector.hpp:1404
BoundedVector & operator=(InitializerListType l)
Assigns the contents of the initializer list l to this bounded vector.
Definition: Vector.hpp:1597
T * Pointer
Pointer type for raw access to the element array.
Definition: Vector.hpp:1406
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:1400
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:1691
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:1669
BoundedVector(SizeType n, const ValueType &v)
Constructs a bounded vector of size n with every element initialized to v.
Definition: Vector.hpp:1446
friend void swap(BoundedVector &v1, BoundedVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:1816
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:1410
const T & ConstReference
Constant reference type to an element.
Definition: Vector.hpp:1398
BoundedVector< T, N+1 > VectorTemporaryType
Concrete temporary vector type used by expression-template machinery (one element larger than the bou...
Definition: Vector.hpp:1414
BoundedVector & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this bounded vector (via a temporary to handle aliasing).
Definition: Vector.hpp:1621
BoundedVector(const BoundedVector &v)
Constructs a copy of the bounded vector v.
Definition: Vector.hpp:1456
std::enable_if< IsScalar< T1 >::value, BoundedVector >::type & operator/=(const T1 &t)
Divides every element by the scalar t.
Definition: Vector.hpp:1717
BoundedVector & operator+=(InitializerListType l)
Adds the contents of the initializer list l element-wise to this bounded vector.
Definition: Vector.hpp:1644
Fixed-size vector of dimension N backed by a C-array (no dynamic allocation).
Definition: Vector.hpp:1876
std::enable_if< IsScalar< T1 >::value, CVector >::type & operator/=(const T1 &t)
Divides every element by the scalar t.
Definition: Vector.hpp:2186
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:1997
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:1888
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:2090
Pointer getData()
Returns a mutable pointer to the contiguous element array.
Definition: Vector.hpp:2034
static const SizeType Size
The compile-time fixed size N.
Definition: Vector.hpp:1909
T ValueType
The scalar value type.
Definition: Vector.hpp:1882
void clear(const ValueType &v=ValueType())
Sets every element of the vector to the value v.
Definition: Vector.hpp:2294
SizeType getMaxSize() const
Returns the fixed element count N (capacity equals size for Math::CVector).
Definition: Vector.hpp:2025
CVector & operator=(InitializerListType l)
Assigns the contents of the initializer list l to this fixed-size vector.
Definition: Vector.hpp:2066
const T & ConstReference
Constant reference type to an element.
Definition: Vector.hpp:1886
ConstPointer getData() const
Returns a const pointer to the contiguous element array.
Definition: Vector.hpp:2043
ValueType ArrayType[N]
The fixed-size C-array type used for in-memory storage of N elements.
Definition: Vector.hpp:1892
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i (alias for operator()).
Definition: Vector.hpp:1974
bool isEmpty() const
Tells whether the vector is empty (N is zero).
Definition: Vector.hpp:2007
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:1985
CVector & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this vector without intermediate temporary.
Definition: Vector.hpp:2229
CVector & operator-=(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this fixed-size vector.
Definition: Vector.hpp:2148
CVector & plusAssign(InitializerListType l)
Adds the contents of the initializer list l element-wise to this vector without intermediate temporar...
Definition: Vector.hpp:2240
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:2125
SizeType getSize() const
Returns the fixed element count N.
Definition: Vector.hpp:2016
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:2078
T * Pointer
Pointer type for raw access to the element array.
Definition: Vector.hpp:1894
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:1898
CVector & operator+=(InitializerListType l)
Adds the contents of the initializer list l element-wise to this fixed-size vector.
Definition: Vector.hpp:2113
CVector(InitializerListType l)
Constructs a fixed-size vector with the contents of the initializer list l.
Definition: Vector.hpp:1941
void swap(CVector &v)
Swaps the contents of this fixed-size vector with those of v.
Definition: Vector.hpp:2274
BoundedVector< T, N+1 > VectorTemporaryType
Concrete temporary vector type used by expression-template machinery (a Math::BoundedVector of N + 1 ...
Definition: Vector.hpp:1902
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:2199
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i (alias for operator()).
Definition: Vector.hpp:1963
const T * ConstPointer
Constant pointer type for raw access to the element array.
Definition: Vector.hpp:1896
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated CVector instances.
Definition: Vector.hpp:1904
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:2160
CVector & minusAssign(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this vector without intermediate t...
Definition: Vector.hpp:2264
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:2103
T & Reference
Mutable reference type to an element.
Definition: Vector.hpp:1884
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:1900
CVector & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this vector without intermediate temporary.
Definition: Vector.hpp:2253
CVector & operator=(const CVector &v)
Copy-assigns the elements of v to this fixed-size vector.
Definition: Vector.hpp:2053
CVector(const ValueType &v)
Constructs an N-element vector with every element initialized to v.
Definition: Vector.hpp:1923
std::initializer_list< T > InitializerListType
The initializer-list type accepted by constructors and assignment.
Definition: Vector.hpp:1906
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:1890
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:2211
CVector()
Constructs a zero-initialized N-element vector.
Definition: Vector.hpp:1914
CVector(const VectorExpression< E > &e)
Constructs a fixed-size vector from the vector expression e.
Definition: Vector.hpp:1952
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:2138
CVector(const CVector &v)
Constructs a copy of the fixed-size vector v.
Definition: Vector.hpp:1932
friend void swap(CVector &v1, CVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:2285
std::enable_if< IsScalar< T1 >::value, CVector >::type & operator*=(const T1 &t)
Multiplies every element by the scalar t.
Definition: Vector.hpp:2173
Lightweight vector container that wraps a std::initializer_list for construction-style initialization...
Definition: Vector.hpp:325
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:395
InitializerListType::const_reference ConstReference
Constant reference type to an element.
Definition: Vector.hpp:334
const SelfType ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:344
Reference operator[](SizeType i)
Returns a reference to the element at index i (alias for operator()).
Definition: Vector.hpp:361
Reference operator()(SizeType i)
Returns a reference to the element at index i.
Definition: Vector.hpp:383
std::initializer_list< T > InitializerListType
The wrapped std::initializer_list type.
Definition: Vector.hpp:330
SizeType getSize() const
Returns the size of the wrapped initializer list.
Definition: Vector.hpp:405
InitListVector(InitializerListType l)
Constructs the vector by wrapping the initializer list l (no copy).
Definition: Vector.hpp:352
bool isEmpty() const
Tells whether the wrapped initializer list is empty.
Definition: Vector.hpp:414
InitializerListType::value_type ValueType
The scalar value type.
Definition: Vector.hpp:332
InitializerListType::reference Reference
Mutable reference type (degrades to ConstReference for the immutable initializer list).
Definition: Vector.hpp:336
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:340
InitializerListType::size_type SizeType
The unsigned size type.
Definition: Vector.hpp:338
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i (alias for operator()).
Definition: Vector.hpp:372
SelfType ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:342
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used by expression-template machinery.
Definition: Vector.hpp:346
InitListVector SelfType
Definition: Vector.hpp:328
Constant vector expression in which every element equals the same scalar value.
Definition: Vector.hpp:2625
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:2637
ConstReference operator()(SizeType i) const
Returns a const reference to the common element value.
Definition: Vector.hpp:2685
SizeType getMaxSize() const
Returns the maximum representable element count.
Definition: Vector.hpp:2713
const T & ConstReference
Constant reference type to an element.
Definition: Vector.hpp:2635
ConstReference operator[](SizeType i) const
Returns a const reference to the common element value (alias for operator()).
Definition: Vector.hpp:2674
const T & Reference
Reference type (always a const reference — elements are immutable).
Definition: Vector.hpp:2633
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2641
ScalarVector()
Constructs an empty scalar vector.
Definition: Vector.hpp:2650
friend void swap(ScalarVector &v1, ScalarVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:2759
ScalarVector & operator=(const ScalarVector &v)
Copy-assigns the size and common value from v.
Definition: Vector.hpp:2723
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2643
Vector< T > VectorTemporaryType
Concrete temporary vector type used by expression-template machinery.
Definition: Vector.hpp:2645
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:2639
T ValueType
The scalar value type.
Definition: Vector.hpp:2631
SizeType getSize() const
Returns the logical element count.
Definition: Vector.hpp:2704
void resize(SizeType n)
Resizes the logical element count to n.
Definition: Vector.hpp:2737
void swap(ScalarVector &v)
Swaps the size and common value with v.
Definition: Vector.hpp:2746
bool isEmpty() const
Tells whether the vector has zero logical size.
Definition: Vector.hpp:2695
ScalarVector(SizeType n, const ValueType &v=ValueType())
Constructs a scalar vector of size n in which every element equals v.
Definition: Vector.hpp:2658
ScalarVector(const ScalarVector &v)
Constructs a copy of the scalar vector v.
Definition: Vector.hpp:2665
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:898
SparseVector & operator=(InitializerListType l)
Assigns the contents of the initializer list l to this sparse vector.
Definition: Vector.hpp:1116
SparseVector & operator=(SparseVector &&v)
Move-assigns the contents of v to this sparse vector.
Definition: Vector.hpp:1105
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:1212
SparseVector & operator+=(InitializerListType l)
Adds the contents of the initializer list l element-wise to this sparse vector.
Definition: Vector.hpp:1164
SparseVector & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this sparse vector (via a temporary to handle aliasing).
Definition: Vector.hpp:1140
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:1022
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:923
SparseVector(const VectorExpression< E > &e)
Constructs a sparse vector from the vector expression e.
Definition: Vector.hpp:976
SizeType getMaxSize() const
Returns the maximum number of stored entries the underlying associative container can hold.
Definition: Vector.hpp:1065
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:907
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:1154
void resize(SizeType n)
Resizes the logical element count to n, dropping any stored entries at indices beyond n.
Definition: Vector.hpp:1353
SparseVector(SparseVector &&v)
Move-constructs from v (v is left in a valid empty state).
Definition: Vector.hpp:955
SizeType getSize() const
Returns the logical element count.
Definition: Vector.hpp:1056
A::key_type KeyType
The key type used by the underlying associative container.
Definition: Vector.hpp:909
std::initializer_list< T > InitializerListType
The initializer-list type accepted by constructors and assignment.
Definition: Vector.hpp:929
SparseVector(const SparseVector &v)
Constructs a copy of the sparse vector v.
Definition: Vector.hpp:948
void swap(SparseVector &v)
Swaps the contents of this sparse vector with those of v.
Definition: Vector.hpp:1323
SizeType getNumElements() const
Returns the number of explicitly stored (non-default) entries.
Definition: Vector.hpp:1038
T * Pointer
Pointer type for raw access to stored entries.
Definition: Vector.hpp:917
SparseVector(SizeType n)
Constructs a sparse vector of size n with no stored entries (every position reads as the default valu...
Definition: Vector.hpp:941
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:1190
SparseVector(InitializerListType l)
Constructs a sparse vector with the contents of the initializer list l.
Definition: Vector.hpp:965
SparseVector()
Constructs an empty sparse vector (size zero, no stored entries).
Definition: Vector.hpp:934
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SparseVector instances.
Definition: Vector.hpp:927
A ArrayType
The underlying associative container type.
Definition: Vector.hpp:915
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:1128
SparseVector & minusAssign(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this vector without intermediate t...
Definition: Vector.hpp:1313
SparseContainerElement< SelfType, KeyType > Reference
Mutable reference type (a proxy object that inserts on assignment to a previously-absent key).
Definition: Vector.hpp:913
ArrayType & getData()
Returns a mutable reference to the underlying associative container of stored entries.
Definition: Vector.hpp:1074
SparseVector & operator-=(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this sparse vector.
Definition: Vector.hpp:1200
SparseVector & assign(const VectorExpression< E > &e)
Resizes this vector to match e and assigns the elements of e without intermediate temporary.
Definition: Vector.hpp:1252
const T * ConstPointer
Constant pointer type for raw access to stored entries.
Definition: Vector.hpp:919
std::enable_if< IsScalar< T1 >::value, SparseVector >::type & operator*=(const T1 &t)
Multiplies every stored entry by the scalar t.
Definition: Vector.hpp:1226
Reference operator()(SizeType i)
Returns a mutable proxy reference to the element at index i.
Definition: Vector.hpp:1010
const ArrayType & getData() const
Returns a const reference to the underlying associative container of stored entries.
Definition: Vector.hpp:1083
SparseVector & assign(InitializerListType l)
Resizes this vector to match l and assigns the elements of l.
Definition: Vector.hpp:1264
SelfType VectorTemporaryType
Concrete temporary vector type used by expression-template machinery.
Definition: Vector.hpp:925
Reference operator[](SizeType i)
Returns a mutable proxy reference to the element at index i (alias for operator()).
Definition: Vector.hpp:988
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i (alias for operator()).
Definition: Vector.hpp:999
bool isEmpty() const
Tells whether the vector's logical size is zero.
Definition: Vector.hpp:1047
void clear()
Removes all explicitly stored entries (the logical size remains unchanged).
Definition: Vector.hpp:1344
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:921
SparseVector & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this vector without intermediate temporary.
Definition: Vector.hpp:1278
std::enable_if< IsScalar< T1 >::value, SparseVector >::type & operator/=(const T1 &t)
Divides every stored entry by the scalar t.
Definition: Vector.hpp:1239
SparseVector & plusAssign(InitializerListType l)
Adds the contents of the initializer list l element-wise to this vector without intermediate temporar...
Definition: Vector.hpp:1289
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:905
const T & ConstReference
Constant reference type to a stored element value.
Definition: Vector.hpp:911
T ValueType
Definition: Vector.hpp:903
friend void swap(SparseVector &v1, SparseVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:1336
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:1176
SparseVector & operator=(const SparseVector &v)
Copy-assigns the contents of v to this sparse vector.
Definition: Vector.hpp:1093
SparseVector & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this vector without intermediate temporary.
Definition: Vector.hpp:1302
Constant vector expression that contains 1 at a single specified index and 0 elsewhere.
Definition: Vector.hpp:2458
T ValueType
The scalar value type.
Definition: Vector.hpp:2464
void swap(UnitVector &v)
Swaps the size and unit index with v.
Definition: Vector.hpp:2589
const T & Reference
Reference type (always a const reference — elements are immutable).
Definition: Vector.hpp:2466
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:2470
UnitVector & operator=(const UnitVector &v)
Copy-assigns the size and unit index from v.
Definition: Vector.hpp:2566
friend void swap(UnitVector &v1, UnitVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:2602
const T & ConstReference
Constant reference type to an element.
Definition: Vector.hpp:2468
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:2518
void resize(SizeType n)
Resizes the logical element count to n.
Definition: Vector.hpp:2580
SizeType getSize() const
Returns the logical element count.
Definition: Vector.hpp:2538
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2476
Vector< T > VectorTemporaryType
Concrete temporary vector type used by expression-template machinery.
Definition: Vector.hpp:2478
UnitVector()
Constructs an empty unit vector (size zero, index zero).
Definition: Vector.hpp:2483
UnitVector(SizeType n, SizeType i)
Constructs a unit vector of size n with the 1 entry at index i.
Definition: Vector.hpp:2491
bool isEmpty() const
Tells whether the vector has zero logical size.
Definition: Vector.hpp:2529
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:2472
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i (alias for operator()).
Definition: Vector.hpp:2507
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2474
UnitVector(const UnitVector &v)
Constructs a copy of the unit vector v.
Definition: Vector.hpp:2498
SizeType getMaxSize() const
Returns the maximum representable element count.
Definition: Vector.hpp:2556
SizeType getIndex() const
Returns the index of the non-zero (unit) entry.
Definition: Vector.hpp:2547
Refinement of Math::VectorExpression marking the derived type as a concrete (writable) vector contain...
Definition: Expression.hpp:215
const ContainerType & operator()() const
Returns a const reference to the derived vector container.
Definition: Expression.hpp:225
CRTP base class for all vector expression types.
Definition: Expression.hpp:66
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:146
V::DifferenceType DifferenceType
The signed difference type of the wrapped vector.
Definition: Vector.hpp:80
V::ConstReference ConstReference
Constant reference type to an element.
Definition: Vector.hpp:76
V VectorType
The wrapped vector type.
Definition: Vector.hpp:68
VectorReference & assign(const VectorExpression< E > &e)
Assigns the vector expression e to the wrapped vector without intermediate temporary.
Definition: Vector.hpp:261
VectorReference & operator=(const VectorReference &r)
Copy-assigns the wrapped vector from the vector referenced by r.
Definition: Vector.hpp:183
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i (alias for operator()).
Definition: Vector.hpp:108
VectorReference & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to the wrapped vector.
Definition: Vector.hpp:196
VectorReference & operator+=(const VectorExpression< E > &e)
Adds the vector expression e element-wise to the wrapped vector.
Definition: Vector.hpp:209
V::ValueType ValueType
The element value type of the wrapped vector.
Definition: Vector.hpp:70
const VectorType & getData() const
Returns a const reference to the wrapped vector.
Definition: Vector.hpp:164
SizeType getSize() const
Returns the wrapped vector's element count.
Definition: Vector.hpp:137
VectorReference & minusAssign(const VectorExpression< E > &e)
Subtracts the vector expression e from the wrapped vector without intermediate temporary.
Definition: Vector.hpp:287
V::SizeType SizeType
The unsigned size type of the wrapped vector.
Definition: Vector.hpp:78
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:128
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:235
VectorType & getData()
Returns a reference to the wrapped vector.
Definition: Vector.hpp:173
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: Vector.hpp:82
std::conditional< std::is_const< V >::value, typename V::ConstReference, typename V::Reference >::type Reference
Mutable reference type (degrades to ConstReference when the wrapped vector is const).
Definition: Vector.hpp:74
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:248
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i (alias for operator()).
Definition: Vector.hpp:98
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:118
friend void swap(VectorReference &r1, VectorReference &r2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:307
VectorReference & operator-=(const VectorExpression< E > &e)
Subtracts the vector expression e element-wise from the wrapped vector.
Definition: Vector.hpp:222
bool isEmpty() const
Tells whether the wrapped vector is empty.
Definition: Vector.hpp:155
VectorReference(VectorType &v)
Constructs the reference proxy referring to v.
Definition: Vector.hpp:90
VectorReference & plusAssign(const VectorExpression< E > &e)
Adds the vector expression e to the wrapped vector without intermediate temporary.
Definition: Vector.hpp:274
void swap(VectorReference &r)
Swaps the contents of the two wrapped vectors.
Definition: Vector.hpp:297
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: Vector.hpp:84
Dynamically-sized dense vector with configurable underlying storage.
Definition: Vector.hpp:430
Vector & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this vector without intermediate temporary.
Definition: Vector.hpp:826
Vector & minusAssign(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this vector without intermediate t...
Definition: Vector.hpp:837
ConstReference operator[](SizeType i) const
Returns a const reference to the element at index i (alias for operator()).
Definition: Vector.hpp:540
void clear(const ValueType &v=ValueType())
Sets every element of the vector to the value v.
Definition: Vector.hpp:867
Vector & plusAssign(InitializerListType l)
Adds the contents of the initializer list l element-wise to this vector without intermediate temporar...
Definition: Vector.hpp:813
Vector(Vector &&v)
Move-constructs a vector from v (v is left in a valid empty state).
Definition: Vector.hpp:501
Vector & operator-=(InitializerListType l)
Subtracts the contents of the initializer list l element-wise from this vector.
Definition: Vector.hpp:725
Vector(InitializerListType l)
Constructs the vector from a brace-initializer list l.
Definition: Vector.hpp:508
Vector & operator=(const Vector &v)
Copy-assigns the elements of v to this vector.
Definition: Vector.hpp:619
ArrayType & getData()
Returns a mutable reference to the underlying storage container.
Definition: Vector.hpp:600
Vector & operator=(Vector &&v)
Move-assigns the elements of v to this vector.
Definition: Vector.hpp:630
Vector(const ArrayType &data)
Constructs a vector that copies its data directly from the underlying-array container data.
Definition: Vector.hpp:487
Reference operator[](SizeType i)
Returns a mutable reference to the element at index i (alias for operator()).
Definition: Vector.hpp:529
const T * ConstPointer
Constant pointer type for raw element access.
Definition: Vector.hpp:450
std::enable_if< IsScalar< T1 >::value, Vector >::type & operator*=(const T1 &t)
Multiplies every element by the scalar t.
Definition: Vector.hpp:751
SizeType getSize() const
Returns the current element count.
Definition: Vector.hpp:582
const ArrayType & getData() const
Returns a const reference to the underlying storage container.
Definition: Vector.hpp:609
Vector(SizeType n)
Constructs a vector of size n with default-initialized elements.
Definition: Vector.hpp:472
std::enable_if< IsScalar< T1 >::value, Vector >::type & operator/=(const T1 &t)
Divides every element by the scalar t.
Definition: Vector.hpp:764
Vector & operator=(InitializerListType l)
Assigns the contents of the initializer list l to this vector (resizes to fit).
Definition: Vector.hpp:641
A::size_type SizeType
The unsigned size type used by the underlying storage container.
Definition: Vector.hpp:442
T ValueType
The scalar value type stored in the vector.
Definition: Vector.hpp:436
Reference operator()(SizeType i)
Returns a mutable reference to the element at index i.
Definition: Vector.hpp:551
SelfType VectorTemporaryType
Concrete temporary vector type used by expression-template machinery.
Definition: Vector.hpp:456
Vector & assign(const VectorExpression< E > &e)
Resizes this vector to match e and assigns the elements of e without intermediate temporary.
Definition: Vector.hpp:777
Vector(const VectorExpression< E > &e)
Constructs the vector from the vector expression e (materializing the expression result).
Definition: Vector.hpp:517
Vector & operator+=(InitializerListType l)
Adds the contents of the initializer list l element-wise to this vector.
Definition: Vector.hpp:689
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:737
T & Reference
Mutable reference type to an element.
Definition: Vector.hpp:438
void swap(Vector &v)
Swaps the contents of this vector with those of v.
Definition: Vector.hpp:847
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:679
Vector & operator=(const VectorContainer< C > &c)
Assigns the contents of the vector container c to this vector (no alias check needed).
Definition: Vector.hpp:653
Vector & operator=(const VectorExpression< E > &e)
Assigns the vector expression e to this vector (via a temporary to handle aliasing).
Definition: Vector.hpp:665
Vector(SizeType n, const ValueType &v)
Constructs a vector of size n with every element initialized to v.
Definition: Vector.hpp:480
bool isEmpty() const
Tells whether the vector is empty.
Definition: Vector.hpp:573
Vector & assign(InitializerListType l)
Assigns the contents of the initializer list l to this vector.
Definition: Vector.hpp:789
ConstReference operator()(SizeType i) const
Returns a const reference to the element at index i.
Definition: Vector.hpp:563
Vector(const Vector &v)
Constructs a copy of the vector v.
Definition: Vector.hpp:494
std::initializer_list< T > InitializerListType
Type of the brace-initializer list accepted by the corresponding constructor.
Definition: Vector.hpp:460
Vector & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this vector without intermediate temporary.
Definition: Vector.hpp:802
friend void swap(Vector &v1, Vector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:858
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:715
std::shared_ptr< SelfType > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated Vector instances.
Definition: Vector.hpp:458
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:701
A::difference_type DifferenceType
The signed difference type used by the underlying storage container.
Definition: Vector.hpp:444
const T & ConstReference
Constant reference type to an element.
Definition: Vector.hpp:440
A ArrayType
The underlying storage container type.
Definition: Vector.hpp:446
T * Pointer
Pointer type for raw element access.
Definition: Vector.hpp:448
void resize(SizeType n, const ValueType &v=ValueType())
Resizes the vector to n elements.
Definition: Vector.hpp:877
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:454
SizeType getMaxSize() const
Returns the maximum number of elements the underlying storage container can hold.
Definition: Vector.hpp:591
Vector()
Constructs an empty vector (size zero).
Definition: Vector.hpp:465
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:452
Constant vector expression whose elements are all zero.
Definition: Vector.hpp:2312
std::size_t SizeType
The unsigned size type.
Definition: Vector.hpp:2324
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: Vector.hpp:2326
ZeroVector(SizeType n)
Constructs a zero vector of size n.
Definition: Vector.hpp:2344
Vector< T > VectorTemporaryType
Concrete temporary vector type used by expression-template machinery.
Definition: Vector.hpp:2332
const T & ConstReference
Constant reference type to the zero element.
Definition: Vector.hpp:2322
bool isEmpty() const
Tells whether the vector has zero logical size.
Definition: Vector.hpp:2381
const T & Reference
Reference type (always a const reference — all elements are zero).
Definition: Vector.hpp:2320
ZeroVector(const ZeroVector &v)
Constructs a copy of the zero vector v.
Definition: Vector.hpp:2351
ZeroVector & operator=(const ZeroVector &v)
Copy-assigns the logical size from v.
Definition: Vector.hpp:2409
ZeroVector()
Constructs an empty zero vector.
Definition: Vector.hpp:2337
friend void swap(ZeroVector &v1, ZeroVector &v2)
ADL-enabled free-function form of swap().
Definition: Vector.hpp:2439
const VectorReference< const SelfType > ConstClosureType
Constant closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2330
T ValueType
The scalar value type.
Definition: Vector.hpp:2318
ConstReference operator()(SizeType i) const
Returns a const reference to the zero element.
Definition: Vector.hpp:2371
SizeType getMaxSize() const
Returns the maximum representable element count.
Definition: Vector.hpp:2399
ConstReference operator[](SizeType i) const
Returns a const reference to the zero element (alias for operator()).
Definition: Vector.hpp:2360
VectorReference< SelfType > ClosureType
Closure type used when this vector appears inside another expression.
Definition: Vector.hpp:2328
void swap(ZeroVector &v)
Swaps the logical sizes with v.
Definition: Vector.hpp:2428
SizeType getSize() const
Returns the logical element count.
Definition: Vector.hpp:2390
void resize(SizeType n)
Resizes the logical element count to n.
Definition: Vector.hpp:2419
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:2977
CVector< float, 2 > Vector2F
Bounded 2 element vector holding floating point values of type float.
Definition: Vector.hpp:2917
QuaternionVectorAdapter< E > vec(QuaternionExpression< E > &e)
Creates a mutable Math::QuaternionVectorAdapter view of the quaternion expression e.
Definition: QuaternionAdapter.hpp:372
SparseVector< unsigned long > SparseULVector
Unbounded sparse vector holding unsigned integers of type unsigned long.
Definition: Vector.hpp:3017
CVector< double, 7 > Vector7D
Bounded 7 element vector holding floating point values of type double.
Definition: Vector.hpp:2947
SparseVector< float > SparseFVector
Unbounded sparse vector holding floating point values of type float.
Definition: Vector.hpp:3002
UnitVector< unsigned long > ULUnitVector
Memory-efficient immutable unit vector with element values of type unsigned long.
Definition: Vector.hpp:2912
UnitVector< float > FUnitVector
Memory-efficient immutable unit vector with element values of type float.
Definition: Vector.hpp:2897
CVector< double, 4 > Vector4D
Bounded 4 element vector holding floating point values of type double.
Definition: Vector.hpp:2942
SparseVector< long > SparseLVector
Unbounded sparse vector holding signed integers of type long.
Definition: Vector.hpp:3012
ScalarVector< double > DScalarVector
Memory-efficient immutable vector where all elements have the same value of type double.
Definition: Vector.hpp:2862
CVector< float, 4 > Vector4F
Bounded 4 element vector holding floating point values of type float.
Definition: Vector.hpp:2927
CVector< double, 2 > Vector2D
Bounded 2 element vector holding floating point values of type double.
Definition: Vector.hpp:2932
Vector< float > FVector
Unbounded dense vector holding floating point values of type float.
Definition: Vector.hpp:2982
Vector< double > DVector
Unbounded dense vector holding floating point values of type double.
Definition: Vector.hpp:2987
CVector< double, 3 > Vector3D
Bounded 3 element vector holding floating point values of type double.
Definition: Vector.hpp:2937
UnitVector< double > DUnitVector
Memory-efficient immutable unit vector with element values of type double.
Definition: Vector.hpp:2902
UnitVector< long > LUnitVector
Memory-efficient immutable unit vector with element values of type long.
Definition: Vector.hpp:2907
ZeroVector< long > LZeroVector
Memory-efficient immutable vector where all elements have the value zero of type long.
Definition: Vector.hpp:2887
ScalarVector< long > LScalarVector
Memory-efficient immutable vector where all elements have the same value of type long.
Definition: Vector.hpp:2867
ScalarVector< unsigned long > ULScalarVector
Memory-efficient immutable vector where all elements have the same value of type unsigned long.
Definition: Vector.hpp:2872
ZeroVector< unsigned long > ULZeroVector
Memory-efficient immutable vector where all elements have the value zero of type unsigned long.
Definition: Vector.hpp:2892
CVector< float, 3 > Vector3F
Bounded 3 element vector holding floating point values of type float.
Definition: Vector.hpp:2922
Vector< unsigned long > ULVector
Unbounded dense vector holding unsigned integers of type unsigned long.
Definition: Vector.hpp:2997
CVector< long, 4 > Vector4L
Bounded 4 element vector holding signed integers of type long.
Definition: Vector.hpp:2962
ZeroVector< double > DZeroVector
Memory-efficient immutable vector where all elements have the value zero of type double.
Definition: Vector.hpp:2882
CVector< unsigned long, 2 > Vector2UL
Bounded 2 element vector holding unsigned integers of type unsigned long.
Definition: Vector.hpp:2967
CVector< long, 3 > Vector3L
Bounded 3 element vector holding signed integers of type long.
Definition: Vector.hpp:2957
CVector< long, 2 > Vector2L
Bounded 2 element vector holding signed integers of type long.
Definition: Vector.hpp:2952
ZeroVector< float > FZeroVector
Memory-efficient immutable vector where all elements have the value zero of type float.
Definition: Vector.hpp:2877
SparseVector< double > SparseDVector
Unbounded sparse vector holding floating point values of type double.
Definition: Vector.hpp:3007
ScalarVector< float > FScalarVector
Memory-efficient immutable vector where all elements have the same value of type float.
Definition: Vector.hpp:2857
Vector< long > LVector
Unbounded dense vector holding signed integers of type long.
Definition: Vector.hpp:2992
CVector< unsigned long, 3 > Vector3UL
Bounded 3 element vector holding unsigned integers of type unsigned long.
Definition: Vector.hpp:2972
The namespace of the Chemical Data Processing Library.
Selects a concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:301