Chemical Data Processing Library C++ API - Version 1.4.0
Functional.hpp
Go to the documentation of this file.
1 /*
2  * Functional.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_FUNCTIONAL_HPP
28 #define CDPL_MATH_FUNCTIONAL_HPP
29 
30 #include <boost/algorithm/clamp.hpp>
31 
32 #include "CDPL/Math/Check.hpp"
33 #include "CDPL/Math/CommonType.hpp"
34 #include "CDPL/Math/TypeTraits.hpp"
35 #include "CDPL/Base/Exceptions.hpp"
36 
37 
38 namespace CDPL
39 {
40 
41  namespace Math
42  {
43 
44  template <typename E>
45  class VectorExpression;
46  template <typename E>
47  class MatrixExpression;
48  template <typename E>
49  class QuaternionExpression;
50  template <typename E>
51  class GridExpression;
52 
63  template <typename T1, typename T2>
65  {
66 
70  typedef T1 Argument1Type;
71 
75  typedef const T2& Argument2Type;
76  };
77 
83  template <typename T1, typename T2>
85  {
86 
89 
95  static void apply(Argument1Type t1, Argument2Type t2)
96  {
97  t1 = t2;
98  }
99  };
100 
106  template <typename T1, typename T2>
108  {
109 
112 
118  static void apply(Argument1Type t1, Argument2Type t2)
119  {
120  t1 += t2;
121  }
122  };
123 
129  template <typename T1, typename T2>
131  {
132 
135 
141  static void apply(Argument1Type t1, Argument2Type t2)
142  {
143  t1 -= t2;
144  }
145  };
146 
152  template <typename T1, typename T2>
154  {
155 
158 
164  static void apply(Argument1Type t1, Argument2Type t2)
165  {
166  t1 *= t2;
167  }
168  };
169 
175  template <typename T1, typename T2>
177  {
178 
181 
187  static void apply(Argument1Type t1, Argument2Type t2)
188  {
189  t1 /= t2;
190  }
191  };
192 
201  template <typename T>
203  {
204 
208  typedef T ValueType;
209 
213  typedef const T& ArgumentType;
214 
219  };
220 
225  template <typename T>
227  {
228 
232 
239  {
240  return -v;
241  }
242  };
243 
248  template <typename T>
250  {
251 
255 
262  {
263  return TypeTraits<ValueType>::conj(v);
264  }
265  };
266 
271  template <typename T>
273  {
274 
278  typedef T ValueType;
279 
283  typedef const T& ArgumentType;
284 
289  };
290 
295  template <typename T>
297  {
298 
302 
309  {
310  return TypeTraits<ValueType>::real(v);
311  }
312  };
313 
318  template <typename T>
320  {
321 
325 
332  {
333  return TypeTraits<ValueType>::imag(v);
334  }
335  };
336 
346  template <typename T1, typename T2>
348  {
349 
353  typedef const T1& Argument1Type;
354 
358  typedef const T2& Argument2Type;
359 
364  };
365 
371  template <typename T1, typename T2>
372  struct ScalarAddition : public ScalarBinaryFunctor<T1, T2>
373  {
374 
378 
386  {
387  return (t1 + t2);
388  }
389  };
390 
396  template <typename T1, typename T2>
397  struct ScalarSubtraction : public ScalarBinaryFunctor<T1, T2>
398  {
399 
403 
411  {
412  return (t1 - t2);
413  }
414  };
415 
421  template <typename T1, typename T2>
423  {
424 
428 
436  {
437  return (t1 * t2);
438  }
439  };
440 
446  template <typename T1, typename T2>
447  struct ScalarDivision : public ScalarBinaryFunctor<T1, T2>
448  {
449 
453 
461  {
462  return (t1 / t2);
463  }
464  };
465 
471  template <typename V1, typename V2>
473  {
474 
479  };
480 
486  template <typename V1, typename V2>
488  {
489 
491 
500  {
502 
503  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize()), SizeType(e2().getSize()), Base::SizeError);
504  ResultType res = ResultType();
505 
506  for (SizeType i = 0; i < size; i++)
507  res += e1()(i) * e2()(i);
508 
509  return res;
510  }
511  };
512 
519  template <typename V1, typename V2, typename T>
521  {
522 
524 
533  static ResultType apply(const VectorExpression<V1>& e1, const VectorExpression<V2>& e2, const T& sd, bool clamp)
534  {
536 
537  if (!clamp)
538  return res;
539 
540  return boost::algorithm::clamp(res, ResultType(-1), ResultType(1));
541  }
542  };
543 
549  template <typename V1, typename V2>
551  {
552 
556  typedef bool ResultType;
557 
562 
567  };
568 
574  template <typename V1, typename V2>
576  {
577 
581 
589  {
590  if (SizeType(e1().getSize()) != SizeType(e2().getSize()))
591  return false;
592 
593  for (SizeType i = 0, size = e1().getSize(); i < size; i++)
594  if (ValueType(e1()(i)) != ValueType(e2()(i)))
595  return false;
596 
597  return true;
598  }
599  };
600 
607  template <typename V1, typename V2, typename T>
609  {
610 
614  typedef bool ResultType;
615 
619  typedef const T& Argument3Type;
620 
625 
630  };
631 
638  template <typename V1, typename V2, typename T>
640  {
641 
646 
655  {
656  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
657 
658  if (SizeType(e1().getSize()) != SizeType(e2().getSize()))
659  return false;
660 
661  ComparisonType norm_inf_max(epsilon);
662 
663  for (SizeType i = 0, size = e1().getSize(); i < size; i++)
664  if (ComparisonType(TypeTraits<ValueType>::normInf(e2()(i) - e1()(i))) > norm_inf_max)
665  return false;
666 
667  return true;
668  }
669  };
670 
676  template <typename V1, typename V2>
678  {
679 
684  };
685 
691  template <typename V1, typename V2>
692  struct VectorCrossProduct : public VectorBinaryFunctor<V1, V2>
693  {
694 
696 
708  template <typename E1, typename E2, typename SizeType>
709  static ResultType apply(const VectorExpression<E1>& e1, const VectorExpression<E2>& e2, SizeType i)
710  {
711  CDPL_MATH_CHECK(e1().getSize() == 3, "Invalid vector size", Base::SizeError);
712  CDPL_MATH_CHECK(e2().getSize() == 3, "Invalid vector size", Base::SizeError);
713 
714  switch (i) {
715 
716  case 0:
717  return (e1()(1) * e2()(2) - e1()(2) * e2()(1)); // c1 = a2 * b3 - a3 * b2;
718 
719  case 1:
720  return (e1()(2) * e2()(0) - e1()(0) * e2()(2)); // c2 = a3 * b1 - a1 * b3;
721 
722  case 2:
723  return (e1()(0) * e2()(1) - e1()(1) * e2()(0)); // c3 = a1 * b2 - a2 * b1;
724 
725  default:
726  return ResultType();
727  }
728  }
729  };
730 
735  template <typename V>
737  {
738 
742  typedef typename V::ValueType ResultType;
743 
747  typedef typename V::SizeType SizeType;
748  };
749 
754  template <typename V>
756  {
757 
759 
766  {
767  typedef typename V::SizeType SizeType;
768 
769  ResultType res = ResultType();
770 
771  for (SizeType i = 0, size = e().getSize(); i < size; i++)
772  res += e()(i);
773 
774  return res;
775  }
776  };
777 
778  template <typename V>
784  {
785 
789  typedef typename V::ValueType ValueType;
790 
795 
800  };
801 
806  template <typename V>
808  {
809 
813 
820  {
821  typedef typename V::SizeType SizeType;
822 
823  RealType res = RealType();
824 
825  for (SizeType i = 0, size = e().getSize(); i < size; i++)
826  res += TypeTraits<ValueType>::norm1(e()(i));
827 
828  return res;
829  }
830  };
831 
836  template <typename V>
838  {
839 
843 
850  {
851  typedef typename V::SizeType SizeType;
852 
853  RealType res2 = RealType();
854 
855  for (SizeType i = 0, size = e().getSize(); i < size; i++) {
857 
858  res2 += t * t;
859  }
860 
861  return TypeTraits<RealType>::sqrt(res2);
862  }
863  };
864 
869  template <typename V>
871  {
872 
876 
883  {
884  typedef typename V::SizeType SizeType;
885 
886  RealType res = RealType();
887 
888  for (SizeType i = 0, size = e().getSize(); i < size; i++) {
890 
891  if (t > res)
892  res = t;
893  }
894 
895  return res;
896  }
897  };
898 
903  template <typename V>
905  {
906 
910  typedef typename V::ValueType ValueType;
911 
916 
920  typedef typename V::SizeType ResultType;
921  };
922 
927  template <typename V>
929  {
930 
934 
941  {
942  typedef typename V::SizeType SizeType;
943 
944  RealType norm = RealType();
945  ResultType res = ResultType(0);
946 
947  for (SizeType i = 0, size = e().getSize(); i < size; i++) {
949 
950  if (t > norm) {
951  norm = t;
952  res = ResultType(i);
953  }
954  }
955 
956  return res;
957  }
958  };
959 
965  template <typename M1, typename M2>
967  {
968 
972  typedef bool ResultType;
973 
978 
983  };
984 
990  template <typename M1, typename M2>
992  {
993 
997 
1005  {
1006  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
1007  return false;
1008 
1009  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
1010  return false;
1011 
1012  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
1013  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
1014  if (ValueType(e1()(i, j)) != ValueType(e2()(i, j)))
1015  return false;
1016 
1017  return true;
1018  }
1019  };
1020 
1027  template <typename M1, typename M2, typename T>
1029  {
1030 
1034  typedef bool ResultType;
1035 
1039  typedef const T& Argument3Type;
1040 
1045 
1050  };
1051 
1058  template <typename M1, typename M2, typename T>
1060  {
1061 
1066 
1075  {
1076  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
1077 
1078  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
1079  return false;
1080 
1081  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
1082  return false;
1083 
1084  ComparisonType norm_inf_max(epsilon);
1085 
1086  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
1087  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
1088  if (ComparisonType(TypeTraits<ValueType>::normInf(e2()(i, j) - e1()(i, j))) > norm_inf_max)
1089  return false;
1090 
1091  return true;
1092  }
1093  };
1094 
1099  template <typename M>
1101  {
1102 
1106  typedef typename M::ValueType ResultType;
1107  };
1108 
1113  template <typename M>
1115  {
1116 
1118 
1125  {
1126  typedef typename M::SizeType SizeType;
1127 
1128  ResultType res = ResultType();
1129  SizeType size1 = e().getSize1();
1130  SizeType size2 = e().getSize2();
1131 
1132  for (SizeType i = 0; i < size1; i++)
1133  for (SizeType j = 0; j < size2; j++)
1134  res += e()(i, j);
1135 
1136  return res;
1137  }
1138  };
1139 
1144  template <typename M>
1146  {
1147 
1149 
1157  {
1158  typedef typename M::SizeType SizeType;
1159 
1160  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(e().getSize1(), e().getSize2(), Base::SizeError);
1161  ResultType res = ResultType();
1162 
1163  for (SizeType i = 0; i < size; i++)
1164  res += e()(i, i);
1165 
1166  return res;
1167  }
1168  };
1169 
1174  template <typename M>
1176  {
1177 
1181  typedef typename M::ValueType ValueType;
1182 
1187 
1192  };
1193 
1198  template <typename M>
1200  {
1201 
1205 
1212  {
1213  typedef typename M::SizeType SizeType;
1214 
1215  RealType res = RealType();
1216  SizeType size1 = e().getSize1();
1217  SizeType size2 = e().getSize2();
1218 
1219  for (SizeType j = 0; j < size2; j++) {
1220  RealType t = RealType();
1221 
1222  for (SizeType i = 0; i < size1; i++)
1223  t += TypeTraits<ValueType>::norm1(e()(i, j));
1224 
1225  if (t > res)
1226  res = t;
1227  }
1228 
1229  return res;
1230  }
1231  };
1232 
1237  template <typename M>
1239  {
1240 
1244 
1251  {
1252  typedef typename M::SizeType SizeType;
1253 
1254  RealType res2 = RealType();
1255  SizeType size1 = e().getSize1();
1256  SizeType size2 = e().getSize2();
1257 
1258  for (SizeType i = 0; i < size1; i++) {
1259  for (SizeType j = 0; j < size2; j++) {
1260  RealType t = TypeTraits<ValueType>::norm2(e()(i, j));
1261 
1262  res2 += t * t;
1263  }
1264  }
1265 
1266  return TypeTraits<RealType>::sqrt(res2);
1267  }
1268  };
1269 
1274  template <typename M>
1276  {
1277 
1281 
1288  {
1289  typedef typename M::SizeType SizeType;
1290 
1291  RealType res = RealType();
1292  SizeType size1 = e().getSize1();
1293  SizeType size2 = e().getSize2();
1294 
1295  for (SizeType i = 0; i < size1; i++) {
1296  RealType t = RealType();
1297 
1298  for (SizeType j = 0; j < size2; j++)
1299  t += TypeTraits<ValueType>::normInf(e()(i, j));
1300 
1301  if (t > res)
1302  res = t;
1303  }
1304 
1305  return res;
1306  }
1307  };
1308 
1313  template <typename V>
1315  {
1316 
1320  typedef typename V::ValueType ResultType;
1321 
1325  typedef typename V::SizeType SizeType;
1326  };
1327 
1332  template <typename V>
1334  {
1335 
1338 
1347  template <typename E>
1349  {
1350  if (i == j)
1351  return e()(i);
1352 
1353  return ResultType();
1354  }
1355  };
1356 
1361  template <typename V>
1363  {
1364 
1367 
1377  template <typename E>
1379  {
1380  CDPL_MATH_CHECK(e().getSize() == 3, "Invalid vector size", Base::SizeError);
1381 
1382  // | 0 -a3 a2 |
1383  // cross([a1, a2, a3]) = | a3 0 -a1 |
1384  // | -a2 a1 0 |
1385  switch (i) {
1386 
1387  case 0:
1388  switch (j) {
1389 
1390  case 1:
1391  return -e()(2);
1392 
1393  case 2:
1394  return e()(1);
1395 
1396  default:
1397  return ResultType();
1398  }
1399 
1400  case 1:
1401  switch (j) {
1402 
1403  case 0:
1404  return e()(2);
1405 
1406  case 2:
1407  return -e()(0);
1408 
1409  default:
1410  return ResultType();
1411  }
1412 
1413  case 2:
1414  switch (j) {
1415 
1416  case 0:
1417  return -e()(1);
1418 
1419  case 1:
1420  return e()(0);
1421 
1422  default:
1423  return ResultType();
1424  }
1425 
1426  default:
1427  return ResultType();
1428  }
1429  }
1430  };
1431 
1437  template <typename M, typename V>
1439  {
1440 
1445 
1450 
1455  };
1456 
1462  template <typename M, typename V>
1464  {
1465 
1469 
1480  template <typename E1, typename E2>
1482  {
1483  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize2()), SizeType(e2().getSize()), Base::SizeError);
1484  ResultType res = ResultType();
1485 
1486  for (SizeType j = 0; j < size; j++)
1487  res += e1()(i, j) * e2()(j);
1488 
1489  return res;
1490  }
1491  };
1492 
1498  template <typename V, typename M>
1500  {
1501 
1505 
1516  template <typename E1, typename E2>
1518  {
1519  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize()), SizeType(e2().getSize1()), Base::SizeError);
1520  ResultType res = ResultType();
1521 
1522  for (SizeType j = 0; j < size; j++)
1523  res += e1()(j) * e2()(j, i);
1524 
1525  return res;
1526  }
1527  };
1528 
1534  template <typename M1, typename M2>
1536  {
1537 
1542 
1547 
1552  };
1553 
1559  template <typename M1, typename M2>
1560  struct MatrixProduct : public MatrixBinaryFunctor<M1, M2>
1561  {
1562 
1566 
1578  template <typename E1, typename E2>
1580  {
1581  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize2()), SizeType(e2().getSize1()), Base::SizeError);
1582  ResultType res = ResultType();
1583 
1584  for (SizeType k = 0; k < size; k++)
1585  res += e1()(i, k) * e2()(k, j);
1586 
1587  return res;
1588  }
1589  };
1590 
1596  template <typename Q1, typename Q2>
1598  {
1599 
1603  typedef bool ResultType;
1604 
1609  };
1610 
1616  template <typename Q1, typename Q2>
1618  {
1619 
1622 
1630  {
1631  return (ValueType(e1().getC1()) == ValueType(e2().getC1()) && ValueType(e1().getC2()) == ValueType(e2().getC2()) && ValueType(e1().getC3()) == ValueType(e2().getC3()) && ValueType(e1().getC4()) == ValueType(e2().getC4()));
1632  }
1633  };
1634 
1641  template <typename Q1, typename Q2, typename T>
1643  {
1644 
1648  typedef bool ResultType;
1649 
1653  typedef const T& Argument3Type;
1654 
1659  };
1660 
1667  template <typename Q1, typename Q2, typename T>
1669  {
1670 
1674 
1683  {
1684  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
1685 
1686  ComparisonType norm_inf_max(epsilon);
1687 
1688  return (ComparisonType(TypeTraits<ValueType>::normInf(e2().getC1() - e1().getC1())) <= norm_inf_max && ComparisonType(TypeTraits<ValueType>::normInf(e2().getC2() - e1().getC2())) <= norm_inf_max && ComparisonType(TypeTraits<ValueType>::normInf(e2().getC3() - e1().getC3())) <= norm_inf_max && ComparisonType(TypeTraits<ValueType>::normInf(e2().getC4() - e1().getC4())) <= norm_inf_max);
1689  }
1690  };
1691 
1696  template <typename Q>
1698  {
1699 
1703  typedef typename Q::ValueType ResultType;
1704  };
1705 
1710  template <typename Q>
1712  {
1713 
1715 
1722  {
1723  return (e().getC1() + e().getC2() + e().getC3() + e().getC4());
1724  }
1725  };
1726 
1731  template <typename Q>
1733  {
1734 
1738  typedef typename Q::ValueType ValueType;
1739 
1744 
1749  };
1750 
1755  template <typename Q>
1757  {
1758 
1762 
1769  {
1770  RealType t = e().getC1() * e().getC1() +
1771  e().getC2() * e().getC2() +
1772  e().getC3() * e().getC3() +
1773  e().getC4() * e().getC4();
1774 
1775  return TypeTraits<RealType>::sqrt(t);
1776  }
1777  };
1778 
1783  template <typename Q>
1785  {
1786 
1790 
1797  {
1798  RealType t = e().getC1() * e().getC1() +
1799  e().getC2() * e().getC2() +
1800  e().getC3() * e().getC3() +
1801  e().getC4() * e().getC4();
1802 
1803  return t;
1804  }
1805  };
1806 
1811  template <typename Q>
1813  {
1814 
1818  typedef typename Q::ValueType ResultType;
1819  };
1820 
1825  template <typename Q>
1827  {
1828 
1830 
1837  template <typename E>
1839  {
1840  return ResultType();
1841  }
1842 
1849  template <typename E>
1851  {
1852  return e().getC2();
1853  }
1854 
1861  template <typename E>
1863  {
1864  return e().getC3();
1865  }
1866 
1873  template <typename E>
1875  {
1876  return e().getC4();
1877  }
1878  };
1879 
1884  template <typename Q>
1886  {
1887 
1889 
1896  template <typename E>
1898  {
1899  return e().getC1();
1900  }
1901 
1908  template <typename E>
1910  {
1911  return -e().getC2();
1912  }
1913 
1920  template <typename E>
1922  {
1923  return -e().getC3();
1924  }
1925 
1932  template <typename E>
1934  {
1935  return -e().getC4();
1936  }
1937  };
1938 
1944  template <typename T, typename Q>
1946  {
1947 
1952 
1956  typedef const T& Argument1Type;
1957  };
1958 
1964  template <typename T, typename Q>
1966  {
1967 
1970 
1978  template <typename E>
1980  {
1981  return (t + e().getC1());
1982  }
1983 
1990  template <typename E>
1992  {
1993  return e().getC2();
1994  }
1995 
2002  template <typename E>
2004  {
2005  return e().getC3();
2006  }
2007 
2014  template <typename E>
2016  {
2017  return e().getC4();
2018  }
2019  };
2020 
2026  template <typename T, typename Q>
2028  {
2029 
2032 
2040  template <typename E>
2042  {
2043  return (t - e().getC1());
2044  }
2045 
2052  template <typename E>
2054  {
2055  return -e().getC2();
2056  }
2057 
2064  template <typename E>
2066  {
2067  return -e().getC3();
2068  }
2069 
2076  template <typename E>
2078  {
2079  return -e().getC4();
2080  }
2081  };
2082 
2088  template <typename Q, typename T>
2090  {
2091 
2096 
2100  typedef const T& Argument2Type;
2101  };
2102 
2108  template <typename Q, typename T>
2110  {
2111 
2114 
2122  template <typename E>
2124  {
2125  return (e().getC1() + t);
2126  }
2127 
2134  template <typename E>
2136  {
2137  return e().getC2();
2138  }
2139 
2146  template <typename E>
2148  {
2149  return e().getC3();
2150  }
2151 
2158  template <typename E>
2160  {
2161  return e().getC4();
2162  }
2163  };
2164 
2170  template <typename Q, typename T>
2172  {
2173 
2176 
2184  template <typename E>
2186  {
2187  return (e().getC1() - t);
2188  }
2189 
2196  template <typename E>
2198  {
2199  return e().getC2();
2200  }
2201 
2208  template <typename E>
2210  {
2211  return e().getC3();
2212  }
2213 
2220  template <typename E>
2222  {
2223  return e().getC4();
2224  }
2225  };
2226 
2232  template <typename Q, typename T>
2234  {
2235 
2238 
2246  template <typename E>
2248  {
2249  return (e().getC1() / n2);
2250  }
2251 
2259  template <typename E>
2261  {
2262  return (-e().getC2() / n2);
2263  }
2264 
2272  template <typename E>
2274  {
2275  return (-e().getC3() / n2);
2276  }
2277 
2285  template <typename E>
2287  {
2288  return (-e().getC4() / n2);
2289  }
2290  };
2291 
2297  template <typename Q1, typename Q2>
2299  {
2300 
2305  };
2306 
2312  template <typename Q1, typename Q2>
2314  {
2315 
2317 
2326  template <typename E1, typename E2>
2328  {
2329  // a = a1 * a2 - b1 * b2 - c1 * c2 - d1 * d2
2330  return (e1().getC1() * e2().getC1() - e1().getC2() * e2().getC2() - e1().getC3() * e2().getC3() - e1().getC4() * e2().getC4());
2331  }
2332 
2341  template <typename E1, typename E2>
2343  {
2344  // b = a1 * b2 + b1 * a2 + c1 * d2 - d1 * c2
2345  return (e1().getC1() * e2().getC2() + e1().getC2() * e2().getC1() + e1().getC3() * e2().getC4() - e1().getC4() * e2().getC3());
2346  }
2347 
2356  template <typename E1, typename E2>
2358  {
2359  // c = a1 * c2 - b1 * d2 + c1 * a2 + d1 * b2
2360  return (e1().getC1() * e2().getC3() - e1().getC2() * e2().getC4() + e1().getC3() * e2().getC1() + e1().getC4() * e2().getC2());
2361  }
2362 
2371  template <typename E1, typename E2>
2373  {
2374  // d = a1 * d2 + b1 * c2 - c1 * b2 + d1 * a2
2375  return (e1().getC1() * e2().getC4() + e1().getC2() * e2().getC3() - e1().getC3() * e2().getC2() + e1().getC4() * e2().getC1());
2376  }
2377  };
2378 
2385  template <typename Q1, typename Q2, typename T>
2387  {
2388 
2393 
2397  typedef const T& Argument3Type;
2398  };
2399 
2406  template <typename Q1, typename Q2, typename T>
2408  {
2409 
2412 
2422  template <typename E1, typename E2>
2424  {
2425  // a = (a1 * a2 + b1 * b2 + c1 * c2 + d1 * d2) / n2
2426  return ((e1().getC1() * e2().getC1() + e1().getC2() * e2().getC2() + e1().getC3() * e2().getC3() + e1().getC4() * e2().getC4()) / n2);
2427  }
2428 
2438  template <typename E1, typename E2>
2440  {
2441  // b = (-a1 * b2 + b1 * a2 - c1 * d2 + d1 * c2) / n2
2442  return ((-e1().getC1() * e2().getC2() + e1().getC2() * e2().getC1() - e1().getC3() * e2().getC4() + e1().getC4() * e2().getC3()) / n2);
2443  }
2444 
2454  template <typename E1, typename E2>
2456  {
2457  // c = (-a1 * c2 + b1 * d2 + c1 * a2 - d1 * b2) / n2
2458  return ((-e1().getC1() * e2().getC3() + e1().getC2() * e2().getC4() + e1().getC3() * e2().getC1() - e1().getC4() * e2().getC2()) / n2);
2459  }
2460 
2470  template <typename E1, typename E2>
2472  {
2473  // d = (-a1 * d2 - b1 * c2 + c1 * b2 + d1 * a2) / n2
2474  return ((-e1().getC1() * e2().getC4() - e1().getC2() * e2().getC3() + e1().getC3() * e2().getC2() + e1().getC4() * e2().getC1()) / n2);
2475  }
2476  };
2477 
2484  template <typename T1, typename Q, typename T2>
2486  {
2487 
2492 
2496  typedef const T1& Argument1Type;
2497 
2501  typedef const T2& Argument3Type;
2502  };
2503 
2510  template <typename T1, typename Q, typename T2>
2512  {
2513 
2517 
2526  template <typename E>
2528  {
2529  return (t * e().getC1() / n2);
2530  }
2531 
2540  template <typename E>
2542  {
2543  return (t * -e().getC2() / n2);
2544  }
2545 
2554  template <typename E>
2556  {
2557  return (t * -e().getC3() / n2);
2558  }
2559 
2568  template <typename E>
2570  {
2571  return (t * -e().getC4() / n2);
2572  }
2573  };
2574 
2580  template <typename Q, typename V>
2582  {
2583 
2588 
2592  typedef typename V::SizeType SizeType;
2593 
2598  };
2599 
2606  template <typename Q, typename V>
2608  {
2609 
2613 
2624  template <typename E1, typename E2>
2626  {
2627  CDPL_MATH_CHECK(e2().getSize() >= 3, "Invalid vector size", Base::SizeError);
2628 
2629  switch (i) {
2630 
2631  case 0: {
2632  // vr1 = (a2 + b2 - c2 - d2) * v1 + (2bc - 2ad) * v2 + (2bd + 2ac) * v3
2633  ValueType t1 = e1().getC1() * e1().getC1() + e1().getC2() * e1().getC2() - e1().getC3() * e1().getC3() - e1().getC4() * e1().getC4();
2634  ValueType t2 = ValueType(2) * (e1().getC2() * e1().getC3() - e1().getC1() * e1().getC4());
2635  ValueType t3 = ValueType(2) * (e1().getC2() * e1().getC4() + e1().getC1() * e1().getC3());
2636 
2637  return (t1 * e2()(0) + t2 * e2()(1) + t3 * e2()(2));
2638  }
2639 
2640  case 1: {
2641  // vr2 = (2bc + 2ad) * v1 + (a2 - b2 + c2 - d2) * v2 + (2cd - 2ab) * v3
2642  ValueType t1 = ValueType(2) * (e1().getC2() * e1().getC3() + e1().getC1() * e1().getC4());
2643  ValueType t2 = e1().getC1() * e1().getC1() - e1().getC2() * e1().getC2() + e1().getC3() * e1().getC3() - e1().getC4() * e1().getC4();
2644  ValueType t3 = ValueType(2) * (e1().getC3() * e1().getC4() - e1().getC1() * e1().getC2());
2645 
2646  return (t1 * e2()(0) + t2 * e2()(1) + t3 * e2()(2));
2647  }
2648 
2649  case 2: {
2650  // vr3 = (2bd - 2ac) * v1 + (2cd + 2ab) * v2 + (a2 - b2 - c2 + d2) * v3
2651  ValueType t1 = ValueType(2) * (e1().getC2() * e1().getC4() - e1().getC1() * e1().getC3());
2652  ValueType t2 = ValueType(2) * (e1().getC3() * e1().getC4() + e1().getC1() * e1().getC2());
2653  ValueType t3 = e1().getC1() * e1().getC1() - e1().getC2() * e1().getC2() - e1().getC3() * e1().getC3() + e1().getC4() * e1().getC4();
2654 
2655  return (t1 * e2()(0) + t2 * e2()(1) + t3 * e2()(2));
2656  }
2657 
2658  default:
2659  return ResultType();
2660  }
2661  }
2662  };
2663 
2669  template <typename G1, typename G2>
2671  {
2672 
2676  typedef bool ResultType;
2677 
2682 
2687  };
2688 
2694  template <typename G1, typename G2>
2695  struct GridEquality : public GridBooleanBinaryFunctor<G1, G2>
2696  {
2697 
2701 
2709  {
2710  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
2711  return false;
2712 
2713  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
2714  return false;
2715 
2716  if (SizeType(e1().getSize3()) != SizeType(e2().getSize3()))
2717  return false;
2718 
2719  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
2720  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
2721  for (SizeType k = 0, size3 = e1().getSize3(); k < size3; k++)
2722  if (ValueType(e1()(i, j, k)) != ValueType(e2()(i, j, k)))
2723  return false;
2724 
2725  return true;
2726  }
2727  };
2728 
2735  template <typename G1, typename G2, typename T>
2737  {
2738 
2742  typedef bool ResultType;
2743 
2747  typedef const T& Argument3Type;
2748 
2753 
2758  };
2759 
2766  template <typename G1, typename G2, typename T>
2768  {
2769 
2774 
2783  {
2784  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
2785 
2786  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
2787  return false;
2788 
2789  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
2790  return false;
2791 
2792  if (SizeType(e1().getSize3()) != SizeType(e2().getSize3()))
2793  return false;
2794 
2795  ComparisonType norm_inf_max(epsilon);
2796 
2797  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
2798  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
2799  for (SizeType k = 0, size3 = e1().getSize3(); k < size3; k++)
2800  if (ComparisonType(TypeTraits<ValueType>::normInf(e2()(i, j, k) - e1()(i, j, k))) > norm_inf_max)
2801  return false;
2802 
2803  return true;
2804  }
2805  };
2806 
2811  template <typename M>
2813  {
2814 
2818  typedef typename M::ValueType ResultType;
2819  };
2820 
2825  template <typename G>
2827  {
2828 
2830 
2837  {
2838  typedef typename G::SizeType SizeType;
2839 
2840  ResultType res = ResultType();
2841  SizeType size1 = e().getSize1();
2842  SizeType size2 = e().getSize2();
2843  SizeType size3 = e().getSize3();
2844 
2845  for (SizeType i = 0; i < size1; i++)
2846  for (SizeType j = 0; j < size2; j++)
2847  for (SizeType k = 0; k < size3; k++)
2848  res += e()(i, j, k);
2849 
2850  return res;
2851  }
2852  };
2853  } // namespace Math
2854 } // namespace CDPL
2855 
2856 #endif // CDPL_MATH_FUNCTIONAL_HPP
Definition of exception classes.
Definition of various preprocessor macros for error checking.
#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
#define CDPL_MATH_CHECK_SIZE_EQUALITY(size1, size2, e)
Throws the exception e if size1 differs from size2, otherwise returns std::min(size1,...
Definition: Check.hpp:84
Common type deduction.
Definition of type traits.
Thrown to indicate that the size of a (multidimensional) array is not correct.
Definition: Base/Exceptions.hpp:133
CRTP base class of all grid expression types.
Definition: Expression.hpp:188
CRTP base class of all matrix expression types.
Definition: Expression.hpp:108
CRTP base class of all quaternion expression types.
Definition: Expression.hpp:148
CRTP base class of all vector expression types.
Definition: Expression.hpp:68
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
QuaternionNorm< E >::ResultType norm(const QuaternionExpression< E > &e)
Returns the norm (Euclidean length) of the quaternion expression e.
Definition: QuaternionExpression.hpp:1574
The namespace of the Chemical Data Processing Library.
Trait that resolves the common arithmetic type of T1 and T2 via std::common_type.
Definition: CommonType.hpp:46
std::common_type< T1, T2 >::type Type
The common type.
Definition: CommonType.hpp:51
Functor producing the cross-product (skew-symmetric) matrix element at (i, j) for a 3D vector express...
Definition: Functional.hpp:1363
VectorScalarUnaryFunctor< V >::SizeType SizeType
Definition: Functional.hpp:1366
static ResultType apply(const VectorExpression< E > &e, SizeType i, SizeType j)
Returns the (i, j) element of the skew-symmetric matrix corresponding to the 3D vector e.
Definition: Functional.hpp:1378
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:1365
Functor producing the diagonal matrix element at (i, j) from a vector expression ( on the diagonal,...
Definition: Functional.hpp:1334
VectorScalarUnaryFunctor< V >::SizeType SizeType
Definition: Functional.hpp:1337
static ResultType apply(const VectorExpression< E > &e, SizeType i, SizeType j)
Returns if i equals j, otherwise 0.
Definition: Functional.hpp:1348
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:1336
Base class for binary functors that take two grid expressions and return a bool result (Math::GridEqu...
Definition: Functional.hpp:2671
CommonType< typename G1::SizeType, typename G2::SizeType >::Type SizeType
The unsigned size type (common type of the two grid size types).
Definition: Functional.hpp:2681
bool ResultType
The boolean result type.
Definition: Functional.hpp:2676
CommonType< typename G1::ValueType, typename G2::ValueType >::Type ValueType
The element value type (common type of the two grid element types).
Definition: Functional.hpp:2686
Functor returning the sum of all elements of a grid expression.
Definition: Functional.hpp:2827
GridScalarUnaryFunctor< G >::ResultType ResultType
Definition: Functional.hpp:2829
static ResultType apply(const GridExpression< G > &e)
Returns the element sum of e.
Definition: Functional.hpp:2836
Functor checking element-wise equality of two grid expressions.
Definition: Functional.hpp:2696
static ResultType apply(const GridExpression< G1 > &e1, const GridExpression< G2 > &e2)
Tells whether e1 and e2 have the same dimensions and equal element values.
Definition: Functional.hpp:2708
GridBooleanBinaryFunctor< G1, G2 >::ResultType ResultType
Definition: Functional.hpp:2700
GridBooleanBinaryFunctor< G1, G2 >::SizeType SizeType
Definition: Functional.hpp:2698
GridBooleanBinaryFunctor< G1, G2 >::ValueType ValueType
Definition: Functional.hpp:2699
Base class for unary functors that take a grid expression and return a scalar result (Math::GridEleme...
Definition: Functional.hpp:2813
M::ValueType ResultType
The scalar result type (the grid's element value type).
Definition: Functional.hpp:2818
Functor checking element-wise approximate equality of two grid expressions within an absolute toleran...
Definition: Functional.hpp:2768
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::ValueType ValueType
Definition: Functional.hpp:2771
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::ResultType ResultType
Definition: Functional.hpp:2772
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::SizeType SizeType
Definition: Functional.hpp:2770
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:2773
static ResultType apply(const GridExpression< G1 > &e1, const GridExpression< G2 > &e2, Argument3Type epsilon)
Tells whether e1 and e2 agree element-wise within the absolute tolerance epsilon.
Definition: Functional.hpp:2782
Base class for binary functors that take two matrix expressions and return a matrix element scalar re...
Definition: Functional.hpp:1536
ValueType ResultType
The scalar result type (alias for ValueType).
Definition: Functional.hpp:1551
CommonType< typename M1::ValueType, typename M2::ValueType >::Type ValueType
The element value type (common type of the two matrix element types).
Definition: Functional.hpp:1541
CommonType< typename M1::SizeType, typename M2::SizeType >::Type SizeType
The unsigned size type (common type of the two matrix size types).
Definition: Functional.hpp:1546
Base class for binary functors that take two matrix expressions and return a bool result (Math::Matri...
Definition: Functional.hpp:967
CommonType< typename M1::SizeType, typename M2::SizeType >::Type SizeType
The unsigned size type (common type of the two matrix size types).
Definition: Functional.hpp:977
CommonType< typename M1::ValueType, typename M2::ValueType >::Type ValueType
The element value type (common type of the two matrix element types).
Definition: Functional.hpp:982
bool ResultType
The boolean result type.
Definition: Functional.hpp:972
Functor returning the sum of all elements of a matrix expression.
Definition: Functional.hpp:1115
MatrixScalarUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:1117
static ResultType apply(const MatrixExpression< M > &e)
Returns the element sum of e.
Definition: Functional.hpp:1124
Functor checking element-wise equality of two matrix expressions.
Definition: Functional.hpp:992
MatrixBooleanBinaryFunctor< M1, M2 >::SizeType SizeType
Definition: Functional.hpp:994
MatrixBooleanBinaryFunctor< M1, M2 >::ResultType ResultType
Definition: Functional.hpp:996
static ResultType apply(const MatrixExpression< M1 > &e1, const MatrixExpression< M2 > &e2)
Tells whether e1 and e2 have the same dimensions and equal element values.
Definition: Functional.hpp:1004
MatrixBooleanBinaryFunctor< M1, M2 >::ValueType ValueType
Definition: Functional.hpp:995
Functor returning the L1 (maximum absolute column sum) norm of a matrix expression.
Definition: Functional.hpp:1200
MatrixScalarRealUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:1204
MatrixScalarRealUnaryFunctor< M >::RealType RealType
Definition: Functional.hpp:1203
MatrixScalarRealUnaryFunctor< M >::ValueType ValueType
Definition: Functional.hpp:1202
static ResultType apply(const MatrixExpression< M > &e)
Returns the L1 norm of e.
Definition: Functional.hpp:1211
Functor returning the Frobenius norm of a matrix expression.
Definition: Functional.hpp:1239
static ResultType apply(const MatrixExpression< M > &e)
Returns the Frobenius norm of e.
Definition: Functional.hpp:1250
MatrixScalarRealUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:1243
MatrixScalarRealUnaryFunctor< M >::RealType RealType
Definition: Functional.hpp:1242
MatrixScalarRealUnaryFunctor< M >::ValueType ValueType
Definition: Functional.hpp:1241
Functor returning the L∞ (maximum absolute row sum) norm of a matrix expression.
Definition: Functional.hpp:1276
static ResultType apply(const MatrixExpression< M > &e)
Returns the L∞ norm of e.
Definition: Functional.hpp:1287
MatrixScalarRealUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:1280
MatrixScalarRealUnaryFunctor< M >::ValueType ValueType
Definition: Functional.hpp:1278
MatrixScalarRealUnaryFunctor< M >::RealType RealType
Definition: Functional.hpp:1279
Functor returning element (i, j) of the matrix product .
Definition: Functional.hpp:1561
MatrixVectorBinaryFunctor< M1, M2 >::ValueType ValueType
Definition: Functional.hpp:1563
MatrixVectorBinaryFunctor< M1, M2 >::SizeType SizeType
Definition: Functional.hpp:1564
MatrixVectorBinaryFunctor< M1, M2 >::ResultType ResultType
Definition: Functional.hpp:1565
static ResultType apply(const MatrixExpression< E1 > &e1, const MatrixExpression< E2 > &e2, SizeType i, SizeType j)
Returns element (i, j) of the matrix product .
Definition: Functional.hpp:1579
Base class for unary functors that take a matrix expression and return a real-valued scalar (Math::Ma...
Definition: Functional.hpp:1176
M::ValueType ValueType
The matrix's element value type.
Definition: Functional.hpp:1181
RealType ResultType
The real-valued result type.
Definition: Functional.hpp:1191
TypeTraits< ValueType >::RealType RealType
The real-valued type derived from ValueType via Math::TypeTraits.
Definition: Functional.hpp:1186
Base class for unary functors that take a matrix expression and return a scalar result (Math::MatrixE...
Definition: Functional.hpp:1101
M::ValueType ResultType
The scalar result type (the matrix's element value type).
Definition: Functional.hpp:1106
Functor checking element-wise approximate equality of two matrix expressions within an absolute toler...
Definition: Functional.hpp:1060
static ResultType apply(const MatrixExpression< M1 > &e1, const MatrixExpression< M2 > &e2, Argument3Type epsilon)
Tells whether e1 and e2 agree element-wise within the absolute tolerance epsilon.
Definition: Functional.hpp:1074
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::ValueType ValueType
Definition: Functional.hpp:1063
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:1065
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::ResultType ResultType
Definition: Functional.hpp:1064
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::SizeType SizeType
Definition: Functional.hpp:1062
Functor returning the trace (sum of diagonal entries) of a matrix expression.
Definition: Functional.hpp:1146
MatrixScalarUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:1148
static ResultType apply(const MatrixExpression< M > &e)
Returns the trace of e.
Definition: Functional.hpp:1156
Base class for binary functors that take a matrix expression and a vector expression and return a vec...
Definition: Functional.hpp:1439
ValueType ResultType
The scalar result type (alias for ValueType).
Definition: Functional.hpp:1454
CommonType< typename M::ValueType, typename V::ValueType >::Type ValueType
The element value type (common type of the matrix and vector element types).
Definition: Functional.hpp:1444
CommonType< typename M::SizeType, typename V::SizeType >::Type SizeType
The unsigned size type (common type of the matrix and vector size types).
Definition: Functional.hpp:1449
Functor returning element i of the matrix-vector product .
Definition: Functional.hpp:1464
MatrixVectorBinaryFunctor< M, V >::ValueType ValueType
Definition: Functional.hpp:1466
MatrixVectorBinaryFunctor< M, V >::ResultType ResultType
Definition: Functional.hpp:1468
MatrixVectorBinaryFunctor< M, V >::SizeType SizeType
Definition: Functional.hpp:1467
static ResultType apply(const MatrixExpression< E1 > &e1, const VectorExpression< E2 > &e2, SizeType i)
Returns element i of the matrix-vector product .
Definition: Functional.hpp:1481
Base class for per-component binary functors that take two quaternion expressions and produce a quate...
Definition: Functional.hpp:2299
CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type ResultType
The component result type (common type of the two quaternion element types).
Definition: Functional.hpp:2304
Base class for binary functors that take two quaternion expressions and return a bool result (Math::Q...
Definition: Functional.hpp:1598
CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type ValueType
The component value type (common type of the two quaternion element types).
Definition: Functional.hpp:1608
bool ResultType
The boolean result type.
Definition: Functional.hpp:1603
Per-component functor returning the quaternion conjugate (keeps C1, negates C2/C3/C4).
Definition: Functional.hpp:1886
static ResultType applyC4(const QuaternionExpression< E > &e)
Returns the C4 component of the conjugate (equals -e.getC4()).
Definition: Functional.hpp:1933
static ResultType applyC2(const QuaternionExpression< E > &e)
Returns the C2 component of the conjugate (equals -e.getC2()).
Definition: Functional.hpp:1909
static ResultType applyC3(const QuaternionExpression< E > &e)
Returns the C3 component of the conjugate (equals -e.getC3()).
Definition: Functional.hpp:1921
static ResultType applyC1(const QuaternionExpression< E > &e)
Returns the C1 component of the conjugate (equals e.getC1()).
Definition: Functional.hpp:1897
QuaternionUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1888
Per-component functor returning the quaternion division (n2 is the precomputed squared norm of e_2).
Definition: Functional.hpp:2408
static ResultType applyC3(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Returns the C3 component of the quaternion division .
Definition: Functional.hpp:2455
static ResultType applyC1(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Returns the C1 component of the quaternion division .
Definition: Functional.hpp:2423
Scalar3QuaternionTernaryFunctor< Q1, Q2, T >::ResultType ResultType
Definition: Functional.hpp:2411
static ResultType applyC4(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Returns the C4 component of the quaternion division .
Definition: Functional.hpp:2471
static ResultType applyC2(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Returns the C2 component of the quaternion division .
Definition: Functional.hpp:2439
Scalar3QuaternionTernaryFunctor< Q1, Q2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:2410
Functor returning the sum of the four components of a quaternion expression.
Definition: Functional.hpp:1712
QuaternionScalarUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1714
static ResultType apply(const QuaternionExpression< Q > &e)
Returns the component sum of e.
Definition: Functional.hpp:1721
Functor checking component-wise equality of two quaternion expressions.
Definition: Functional.hpp:1618
static ResultType apply(const QuaternionExpression< Q1 > &e1, const QuaternionExpression< Q2 > &e2)
Tells whether e1 and e2 have equal components.
Definition: Functional.hpp:1629
QuaternionBooleanBinaryFunctor< Q1, Q2 >::ResultType ResultType
Definition: Functional.hpp:1621
QuaternionBooleanBinaryFunctor< Q1, Q2 >::ValueType ValueType
Definition: Functional.hpp:1620
Per-component functor returning the multiplicative inverse of a quaternion expression (n2 is the pre...
Definition: Functional.hpp:2234
static ResultType applyC3(const QuaternionExpression< E > &e, Argument2Type n2)
Returns the C3 component of the multiplicative inverse .
Definition: Functional.hpp:2273
Scalar2QuaternionBinaryFunctor< Q, T >::ResultType ResultType
Definition: Functional.hpp:2237
static ResultType applyC1(const QuaternionExpression< E > &e, Argument2Type n2)
Returns the C1 (real) component of the multiplicative inverse .
Definition: Functional.hpp:2247
Scalar2QuaternionBinaryFunctor< Q, T >::Argument2Type Argument2Type
Definition: Functional.hpp:2236
static ResultType applyC2(const QuaternionExpression< E > &e, Argument2Type n2)
Returns the C2 component of the multiplicative inverse .
Definition: Functional.hpp:2260
static ResultType applyC4(const QuaternionExpression< E > &e, Argument2Type n2)
Returns the C4 component of the multiplicative inverse .
Definition: Functional.hpp:2286
Functor returning the squared norm of a quaternion expression.
Definition: Functional.hpp:1785
QuaternionScalarRealUnaryFunctor< Q >::RealType RealType
Definition: Functional.hpp:1788
static ResultType apply(const QuaternionExpression< Q > &e)
Returns .
Definition: Functional.hpp:1796
QuaternionScalarRealUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1789
QuaternionScalarRealUnaryFunctor< Q >::ValueType ValueType
Definition: Functional.hpp:1787
Functor returning the (Euclidean) norm of a quaternion expression.
Definition: Functional.hpp:1757
QuaternionScalarRealUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1761
static ResultType apply(const QuaternionExpression< Q > &e)
Returns .
Definition: Functional.hpp:1768
QuaternionScalarRealUnaryFunctor< Q >::ValueType ValueType
Definition: Functional.hpp:1759
QuaternionScalarRealUnaryFunctor< Q >::RealType RealType
Definition: Functional.hpp:1760
Per-component functor returning the Hamilton product of two quaternion expressions.
Definition: Functional.hpp:2314
QuaternionBinaryFunctor< Q1, Q2 >::ResultType ResultType
Definition: Functional.hpp:2316
static ResultType applyC3(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Returns the C3 component of the Hamilton product .
Definition: Functional.hpp:2357
static ResultType applyC2(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Returns the C2 component of the Hamilton product .
Definition: Functional.hpp:2342
static ResultType applyC4(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Returns the C4 component of the Hamilton product .
Definition: Functional.hpp:2372
static ResultType applyC1(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Returns the C1 component of the Hamilton product .
Definition: Functional.hpp:2327
Base class for unary functors that take a quaternion expression and return a real-valued scalar (Math...
Definition: Functional.hpp:1733
RealType ResultType
The real-valued result type.
Definition: Functional.hpp:1748
Q::ValueType ValueType
The quaternion's component value type.
Definition: Functional.hpp:1738
ValueType RealType
The real-valued type (alias for ValueType).
Definition: Functional.hpp:1743
Base class for unary functors that take a quaternion expression and return a scalar result (Math::Qua...
Definition: Functional.hpp:1698
Q::ValueType ResultType
The scalar result type (the quaternion's element value type).
Definition: Functional.hpp:1703
Functor checking component-wise approximate equality of two quaternion expressions within an absolute...
Definition: Functional.hpp:1669
Scalar3QuaternionBooleanTernaryFunctor< Q1, Q2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:1673
Scalar3QuaternionBooleanTernaryFunctor< Q1, Q2, T >::ValueType ValueType
Definition: Functional.hpp:1671
Scalar3QuaternionBooleanTernaryFunctor< Q1, Q2, T >::ResultType ResultType
Definition: Functional.hpp:1672
static ResultType apply(const QuaternionExpression< Q1 > &e1, const QuaternionExpression< Q2 > &e2, Argument3Type epsilon)
Tells whether e1 and e2 agree component-wise within the absolute tolerance epsilon.
Definition: Functional.hpp:1682
Base class for per-component unary functors that take a quaternion expression and produce a quaternio...
Definition: Functional.hpp:1813
Q::ValueType ResultType
The component result type (the quaternion's element value type).
Definition: Functional.hpp:1818
Per-component functor returning the unreal (pure-quaternion) part of a quaternion expression (zeros C...
Definition: Functional.hpp:1827
QuaternionUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1829
static ResultType applyC1(const QuaternionExpression< E > &e)
Returns the C1 component of the unreal part (always zero).
Definition: Functional.hpp:1838
static ResultType applyC2(const QuaternionExpression< E > &e)
Returns the C2 component of the unreal part (equals e.getC2()).
Definition: Functional.hpp:1850
static ResultType applyC3(const QuaternionExpression< E > &e)
Returns the C3 component of the unreal part (equals e.getC3()).
Definition: Functional.hpp:1862
static ResultType applyC4(const QuaternionExpression< E > &e)
Returns the C4 component of the unreal part (equals e.getC4()).
Definition: Functional.hpp:1874
Base class for binary functors that take a quaternion expression and a vector expression and return a...
Definition: Functional.hpp:2582
ValueType ResultType
The scalar result type (alias for ValueType).
Definition: Functional.hpp:2597
V::SizeType SizeType
The unsigned size type used by the vector.
Definition: Functional.hpp:2592
CommonType< typename Q::ValueType, typename V::ValueType >::Type ValueType
The element value type (common type of the quaternion and vector element types).
Definition: Functional.hpp:2587
Functor returning element i of the rotated 3-dimensional vector (quaternion rotation of by ).
Definition: Functional.hpp:2608
QuaternionVectorBinaryFunctor< Q, V >::SizeType SizeType
Definition: Functional.hpp:2611
QuaternionVectorBinaryFunctor< Q, V >::ResultType ResultType
Definition: Functional.hpp:2612
QuaternionVectorBinaryFunctor< Q, V >::ValueType ValueType
Definition: Functional.hpp:2610
static ResultType apply(const QuaternionExpression< E1 > &e1, const VectorExpression< E2 > &e2, SizeType i)
Returns element i ( ) of the rotated 3D vector .
Definition: Functional.hpp:2625
Base class for per-component ternary functors that take a scalar T1 (lhs), a quaternion expression,...
Definition: Functional.hpp:2486
const T1 & Argument1Type
The first (scalar) argument type.
Definition: Functional.hpp:2496
const T2 & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:2501
CommonType< typename CommonType< T1, typename Q::ValueType >::Type, T2 >::Type ResultType
The component result type (common type of T1, the quaternion's element value type,...
Definition: Functional.hpp:2491
Per-component functor returning (scalar t added to the real component of e).
Definition: Functional.hpp:1966
static ResultType applyC4(Argument1Type, const QuaternionExpression< E > &e)
Returns the C4 component of .
Definition: Functional.hpp:2015
static ResultType applyC1(Argument1Type t, const QuaternionExpression< E > &e)
Returns the C1 component of .
Definition: Functional.hpp:1979
Scalar1QuaternionBinaryFunctor< T, Q >::Argument1Type Argument1Type
Definition: Functional.hpp:1968
static ResultType applyC3(Argument1Type, const QuaternionExpression< E > &e)
Returns the C3 component of .
Definition: Functional.hpp:2003
static ResultType applyC2(Argument1Type, const QuaternionExpression< E > &e)
Returns the C2 component of .
Definition: Functional.hpp:1991
Scalar1QuaternionBinaryFunctor< T, Q >::ResultType ResultType
Definition: Functional.hpp:1969
Base class for per-component binary functors that take a scalar T (lhs) and a quaternion expression (...
Definition: Functional.hpp:1946
CommonType< T, typename Q::ValueType >::Type ResultType
The component result type (common type of the scalar and the quaternion's element value type).
Definition: Functional.hpp:1951
const T & Argument1Type
The first (scalar) argument type.
Definition: Functional.hpp:1956
Per-component functor returning (scalar t with the quaternion e subtracted).
Definition: Functional.hpp:2028
Scalar1QuaternionBinaryFunctor< T, Q >::Argument1Type Argument1Type
Definition: Functional.hpp:2030
Scalar1QuaternionBinaryFunctor< T, Q >::ResultType ResultType
Definition: Functional.hpp:2031
static ResultType applyC2(Argument1Type, const QuaternionExpression< E > &e)
Returns the C2 component of .
Definition: Functional.hpp:2053
static ResultType applyC3(Argument1Type, const QuaternionExpression< E > &e)
Returns the C3 component of .
Definition: Functional.hpp:2065
static ResultType applyC1(Argument1Type t, const QuaternionExpression< E > &e)
Returns the C1 component of .
Definition: Functional.hpp:2041
static ResultType applyC4(Argument1Type, const QuaternionExpression< E > &e)
Returns the C4 component of .
Definition: Functional.hpp:2077
Per-component functor returning (scalar t added to the real component of e).
Definition: Functional.hpp:2110
static ResultType applyC4(const QuaternionExpression< E > &e, Argument2Type)
Returns the C4 component of .
Definition: Functional.hpp:2159
static ResultType applyC3(const QuaternionExpression< E > &e, Argument2Type)
Returns the C3 component of .
Definition: Functional.hpp:2147
Scalar2QuaternionBinaryFunctor< Q, T >::Argument2Type Argument2Type
Definition: Functional.hpp:2112
Scalar2QuaternionBinaryFunctor< Q, T >::ResultType ResultType
Definition: Functional.hpp:2113
static ResultType applyC1(const QuaternionExpression< E > &e, Argument2Type t)
Returns the C1 component of .
Definition: Functional.hpp:2123
static ResultType applyC2(const QuaternionExpression< E > &e, Argument2Type)
Returns the C2 component of .
Definition: Functional.hpp:2135
Base class for per-component binary functors that take a quaternion expression (lhs) and a scalar T (...
Definition: Functional.hpp:2090
CommonType< typename Q::ValueType, T >::Type ResultType
The component result type (common type of the quaternion's element value type and the scalar).
Definition: Functional.hpp:2095
const T & Argument2Type
The second (scalar) argument type.
Definition: Functional.hpp:2100
Per-component functor returning (scalar t subtracted from the real component of e).
Definition: Functional.hpp:2172
static ResultType applyC2(const QuaternionExpression< E > &e, Argument2Type)
Returns the C2 component of .
Definition: Functional.hpp:2197
static ResultType applyC1(const QuaternionExpression< E > &e, Argument2Type t)
Returns the C1 component of .
Definition: Functional.hpp:2185
static ResultType applyC4(const QuaternionExpression< E > &e, Argument2Type)
Returns the C4 component of .
Definition: Functional.hpp:2221
Scalar2QuaternionBinaryFunctor< Q, T >::ResultType ResultType
Definition: Functional.hpp:2175
static ResultType applyC3(const QuaternionExpression< E > &e, Argument2Type)
Returns the C3 component of .
Definition: Functional.hpp:2209
Scalar2QuaternionBinaryFunctor< Q, T >::Argument2Type Argument2Type
Definition: Functional.hpp:2174
Base class for ternary functors that take two grid expressions plus a tolerance scalar and return a b...
Definition: Functional.hpp:2737
bool ResultType
The boolean result type.
Definition: Functional.hpp:2742
const T & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:2747
CommonType< typename G1::ValueType, typename G2::ValueType >::Type ValueType
The element value type (common type of the two grid element types).
Definition: Functional.hpp:2757
CommonType< typename G1::SizeType, typename G2::SizeType >::Type SizeType
The unsigned size type (common type of the two grid size types).
Definition: Functional.hpp:2752
Base class for ternary functors that take two matrix expressions plus a tolerance scalar and return a...
Definition: Functional.hpp:1029
CommonType< typename M1::ValueType, typename M2::ValueType >::Type ValueType
The element value type (common type of the two matrix element types).
Definition: Functional.hpp:1049
CommonType< typename M1::SizeType, typename M2::SizeType >::Type SizeType
The unsigned size type (common type of the two matrix size types).
Definition: Functional.hpp:1044
const T & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:1039
bool ResultType
The boolean result type.
Definition: Functional.hpp:1034
Base class for ternary functors that take two quaternion expressions plus a tolerance scalar and retu...
Definition: Functional.hpp:1643
CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type ValueType
The component value type (common type of the two quaternion element types).
Definition: Functional.hpp:1658
const T & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:1653
bool ResultType
The boolean result type.
Definition: Functional.hpp:1648
Base class for per-component ternary functors that take two quaternion expressions plus a scalar (Mat...
Definition: Functional.hpp:2387
CommonType< typename CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type, T >::Type ResultType
The component result type (common type of the two quaternion element types and the scalar).
Definition: Functional.hpp:2392
const T & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:2397
Base class for ternary functors that take two vectors and a scalar tolerance and return a boolean (Ma...
Definition: Functional.hpp:609
bool ResultType
The boolean result type.
Definition: Functional.hpp:614
const T & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:619
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ValueType
The element value type (common type of the two vector element types).
Definition: Functional.hpp:629
CommonType< typename V1::SizeType, typename V2::SizeType >::Type SizeType
The unsigned size type (common type of the two vector size types).
Definition: Functional.hpp:624
Scalar in-place addition functor: apply(t1, t2) performs t1 += t2.
Definition: Functional.hpp:108
static void apply(Argument1Type t1, Argument2Type t2)
Performs t1 += t2.
Definition: Functional.hpp:118
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:111
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:110
Scalar binary addition functor: apply(t1, t2) returns t1 + t2.
Definition: Functional.hpp:373
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:375
static ResultType apply(Argument1Type t1, Argument2Type t2)
Returns t1 + t2.
Definition: Functional.hpp:385
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:376
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:377
Scalar plain-assignment functor: apply(t1, t2) performs t1 = t2.
Definition: Functional.hpp:85
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:88
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:87
static void apply(Argument1Type t1, Argument2Type t2)
Performs t1 = t2.
Definition: Functional.hpp:95
Base class for binary in-place assignment functors of the form F::apply(T1, const T2&).
Definition: Functional.hpp:65
const T2 & Argument2Type
The second (source) argument type.
Definition: Functional.hpp:75
T1 Argument1Type
The (modifiable) first argument type.
Definition: Functional.hpp:70
Base class for binary scalar functors of the form F::apply(const T1&, const T2&) returning a Math::Co...
Definition: Functional.hpp:348
const T2 & Argument2Type
The second argument type.
Definition: Functional.hpp:358
const T1 & Argument1Type
The first argument type.
Definition: Functional.hpp:353
CommonType< T1, T2 >::Type ResultType
The result type (common type of T1 and T2).
Definition: Functional.hpp:363
Scalar complex-conjugation functor: apply(v) returns (identity for real types).
Definition: Functional.hpp:250
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:253
static ResultType apply(ArgumentType v)
Returns the complex conjugate of v.
Definition: Functional.hpp:261
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:254
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:252
Scalar in-place division functor: apply(t1, t2) performs t1 /= t2.
Definition: Functional.hpp:177
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:179
static void apply(Argument1Type t1, Argument2Type t2)
Performs t1 /= t2.
Definition: Functional.hpp:187
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:180
Scalar binary division functor: apply(t1, t2) returns t1 / t2.
Definition: Functional.hpp:448
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:450
static ResultType apply(Argument1Type t1, Argument2Type t2)
Returns t1 / t2.
Definition: Functional.hpp:460
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:451
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:452
Scalar imaginary-part functor: apply(v) returns (zero for real types).
Definition: Functional.hpp:320
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:324
static ResultType apply(ArgumentType v)
Returns the imaginary part of v.
Definition: Functional.hpp:331
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:322
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:323
Scalar in-place multiplication functor: apply(t1, t2) performs t1 *= t2.
Definition: Functional.hpp:154
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:156
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:157
static void apply(Argument1Type t1, Argument2Type t2)
Performs t1 *= t2.
Definition: Functional.hpp:164
Scalar binary multiplication functor: apply(t1, t2) returns t1 * t2.
Definition: Functional.hpp:423
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:426
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:425
static ResultType apply(Argument1Type t1, Argument2Type t2)
Returns t1 * t2.
Definition: Functional.hpp:435
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:427
Scalar negation functor: apply(v) returns -v.
Definition: Functional.hpp:227
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:229
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:231
static ResultType apply(ArgumentType v)
Returns -v.
Definition: Functional.hpp:238
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:230
Per-component functor returning the scalar/quaternion division (n2 is the precomputed squared norm o...
Definition: Functional.hpp:2512
static ResultType applyC1(Argument1Type t, const QuaternionExpression< E > &e, Argument3Type n2)
Returns the C1 component of using the precomputed squared norm n2 of e.
Definition: Functional.hpp:2527
static ResultType applyC4(Argument1Type t, const QuaternionExpression< E > &e, Argument3Type n2)
Returns the C4 component of using the precomputed squared norm n2 of e.
Definition: Functional.hpp:2569
static ResultType applyC2(Argument1Type t, const QuaternionExpression< E > &e, Argument3Type n2)
Returns the C2 component of using the precomputed squared norm n2 of e.
Definition: Functional.hpp:2541
Scalar13QuaternionTernaryFunctor< T1, Q, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:2514
Scalar13QuaternionTernaryFunctor< T1, Q, T2 >::ResultType ResultType
Definition: Functional.hpp:2516
static ResultType applyC3(Argument1Type t, const QuaternionExpression< E > &e, Argument3Type n2)
Returns the C3 component of using the precomputed squared norm n2 of e.
Definition: Functional.hpp:2555
Scalar13QuaternionTernaryFunctor< T1, Q, T2 >::Argument3Type Argument3Type
Definition: Functional.hpp:2515
Base class for unary scalar functors that return the real part of T (Math::ScalarReal,...
Definition: Functional.hpp:273
TypeTraits< T >::RealType ResultType
The real-valued result type derived from ValueType via Math::TypeTraits.
Definition: Functional.hpp:288
const T & ArgumentType
The argument type (a const reference to ValueType).
Definition: Functional.hpp:283
T ValueType
The scalar value type.
Definition: Functional.hpp:278
Scalar real-part functor: apply(v) returns (identity for real types).
Definition: Functional.hpp:297
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:300
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:299
static ResultType apply(ArgumentType v)
Returns the real part of v.
Definition: Functional.hpp:308
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:301
Scalar in-place subtraction functor: apply(t1, t2) performs t1 -= t2.
Definition: Functional.hpp:131
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:134
static void apply(Argument1Type t1, Argument2Type t2)
Performs t1 -= t2.
Definition: Functional.hpp:141
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:133
Scalar binary subtraction functor: apply(t1, t2) returns t1 - t2.
Definition: Functional.hpp:398
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:402
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:401
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:400
static ResultType apply(Argument1Type t1, Argument2Type t2)
Returns t1 - t2.
Definition: Functional.hpp:410
static RealType real(ConstReference t)
Returns the real part of t (identical to t for non-complex scalars).
Definition: TypeTraits.hpp:113
static RealType conj(ConstReference t)
Returns the complex conjugate of t (identical to t for non-complex scalars).
Definition: TypeTraits.hpp:132
static RealType normInf(ConstReference t)
Returns the L∞ norm of t (identical to the absolute value for scalar values).
Definition: TypeTraits.hpp:182
static RealType imag(ConstReference)
Returns the imaginary part (always zero for non-complex scalars).
Definition: TypeTraits.hpp:122
static ValueType sqrt(ConstReference t)
Returns the square root of t.
Definition: TypeTraits.hpp:152
static RealType norm2(ConstReference t)
Returns the L2 (Euclidean) norm of t (identical to the absolute value for scalar values).
Definition: TypeTraits.hpp:172
T RealType
The real-valued type (identical to ValueType for scalar traits).
Definition: TypeTraits.hpp:96
Base class for unary scalar functors of the form F::apply(const T&) returning a T result.
Definition: Functional.hpp:203
T ValueType
The scalar value type.
Definition: Functional.hpp:208
const T & ArgumentType
The argument type (a const reference to ValueType).
Definition: Functional.hpp:213
ValueType ResultType
The result type of apply().
Definition: Functional.hpp:218
Primary traits template for scalar arithmetic value types.
Definition: TypeTraits.hpp:307
Functor returning the cosine of the angle between two vectors (optionally clamped to [-1,...
Definition: Functional.hpp:521
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2, const T &sd, bool clamp)
Returns the cosine of the angle between e1 and e2.
Definition: Functional.hpp:533
CommonType< typename VectorInnerProduct< V1, V2 >::ResultType, T >::Type ResultType
Definition: Functional.hpp:523
Base class for binary functors that take two vectors and return a vector (Math::VectorCrossProduct).
Definition: Functional.hpp:678
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ResultType
The element result type (common type of the two vector element types).
Definition: Functional.hpp:683
Base class for binary functors that take two vectors and return a boolean (Math::VectorEquality and s...
Definition: Functional.hpp:551
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ValueType
The element value type (common type of the two vector element types).
Definition: Functional.hpp:566
bool ResultType
The boolean result type.
Definition: Functional.hpp:556
CommonType< typename V1::SizeType, typename V2::SizeType >::Type SizeType
The unsigned size type (common type of the two vector size types).
Definition: Functional.hpp:561
Vector cross-product functor: apply(e1, e2, i) returns the i-th component of the 3D vector cross prod...
Definition: Functional.hpp:693
static ResultType apply(const VectorExpression< E1 > &e1, const VectorExpression< E2 > &e2, SizeType i)
Returns the i-th component of the cross product .
Definition: Functional.hpp:709
VectorScalarBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:695
Functor returning the sum of all elements of a vector expression.
Definition: Functional.hpp:756
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:758
static ResultType apply(const VectorExpression< V > &e)
Returns the sum of all elements of e.
Definition: Functional.hpp:765
Vector equality functor: apply(e1, e2) tests element-wise equality of two vector expressions.
Definition: Functional.hpp:576
VectorBooleanBinaryFunctor< V1, V2 >::ValueType ValueType
Definition: Functional.hpp:579
VectorBooleanBinaryFunctor< V1, V2 >::SizeType SizeType
Definition: Functional.hpp:578
VectorBooleanBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:580
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2)
Tells whether the vector expressions e1 and e2 are element-wise equal.
Definition: Functional.hpp:588
Vector inner-product functor: apply(e1, e2) returns .
Definition: Functional.hpp:488
VectorScalarBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:490
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2)
Returns the inner product of e1 and e2.
Definition: Functional.hpp:499
Functor returning element i of the vector-matrix product .
Definition: Functional.hpp:1500
MatrixVectorBinaryFunctor< M, V >::ResultType ResultType
Definition: Functional.hpp:1504
MatrixVectorBinaryFunctor< M, V >::SizeType SizeType
Definition: Functional.hpp:1503
static ResultType apply(const VectorExpression< E1 > &e1, const MatrixExpression< E2 > &e2, SizeType i)
Returns element i of the vector-matrix product .
Definition: Functional.hpp:1517
MatrixVectorBinaryFunctor< M, V >::ValueType ValueType
Definition: Functional.hpp:1502
Base class for unary functors that produce a matrix element from a vector expression and (i,...
Definition: Functional.hpp:1315
V::ValueType ResultType
The matrix element result type (the vector's element value type).
Definition: Functional.hpp:1320
V::SizeType SizeType
The unsigned size type used by the vector.
Definition: Functional.hpp:1325
Functor returning the L1 norm of a vector expression.
Definition: Functional.hpp:808
static ResultType apply(const VectorExpression< V > &e)
Returns the L1 norm of e.
Definition: Functional.hpp:819
VectorScalarRealUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:811
VectorScalarRealUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:810
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:812
Functor returning the L2 (Euclidean) norm of a vector expression.
Definition: Functional.hpp:838
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:842
VectorScalarRealUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:841
static ResultType apply(const VectorExpression< V > &e)
Returns the L2 norm of e.
Definition: Functional.hpp:849
VectorScalarRealUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:840
Functor returning the index of the vector element with the largest L∞ norm.
Definition: Functional.hpp:929
VectorScalarIndexUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:933
VectorScalarIndexUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:931
VectorScalarIndexUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:932
static ResultType apply(const VectorExpression< V > &e)
Returns the index of the element of e with the largest L∞ norm.
Definition: Functional.hpp:940
Functor returning the L∞ (maximum-magnitude) norm of a vector expression.
Definition: Functional.hpp:871
static ResultType apply(const VectorExpression< V > &e)
Returns the L∞ norm of e.
Definition: Functional.hpp:882
VectorScalarRealUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:873
VectorScalarRealUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:874
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:875
Base class for binary functors that take two vectors and return a scalar (Math::VectorInnerProduct,...
Definition: Functional.hpp:473
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ResultType
The scalar result type (common type of the two vector element types).
Definition: Functional.hpp:478
Base class for unary functors that take a vector and return a vector-element index (Math::VectorNormI...
Definition: Functional.hpp:905
TypeTraits< ValueType >::RealType RealType
The real-valued type derived from ValueType via Math::TypeTraits.
Definition: Functional.hpp:915
V::ValueType ValueType
The vector's element value type.
Definition: Functional.hpp:910
V::SizeType ResultType
The result type (the vector's size type, used for element indices).
Definition: Functional.hpp:920
Base class for unary functors that take a vector and return a real-valued scalar (Math::VectorNorm1,...
Definition: Functional.hpp:784
RealType ResultType
The real-valued result type.
Definition: Functional.hpp:799
TypeTraits< ValueType >::RealType RealType
The real-valued type derived from ValueType via Math::TypeTraits.
Definition: Functional.hpp:794
V::ValueType ValueType
The vector's element value type.
Definition: Functional.hpp:789
Base class for unary functors that take a vector and return a scalar (Math::VectorElementSum).
Definition: Functional.hpp:737
V::ValueType ResultType
The scalar result type (the vector's element value type).
Definition: Functional.hpp:742
V::SizeType SizeType
The unsigned size type used by the vector.
Definition: Functional.hpp:747
Vector tolerance-equality functor: apply(e1, e2, eps) tests element-wise equality within an absolute ...
Definition: Functional.hpp:640
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::ValueType ValueType
Definition: Functional.hpp:643
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::SizeType SizeType
Definition: Functional.hpp:642
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:645
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::ResultType ResultType
Definition: Functional.hpp:644
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2, Argument3Type epsilon)
Tells whether the vector expressions e1 and e2 are element-wise equal within an absolute tolerance ep...
Definition: Functional.hpp:654