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 
68  typedef T1 Argument1Type;
70  typedef const T2& Argument2Type;
71  };
72 
78  template <typename T1, typename T2>
80  {
81 
84 
90  static void apply(Argument1Type t1, Argument2Type t2)
91  {
92  t1 = t2;
93  }
94  };
95 
101  template <typename T1, typename T2>
103  {
104 
107 
113  static void apply(Argument1Type t1, Argument2Type t2)
114  {
115  t1 += t2;
116  }
117  };
118 
124  template <typename T1, typename T2>
126  {
127 
130 
136  static void apply(Argument1Type t1, Argument2Type t2)
137  {
138  t1 -= t2;
139  }
140  };
141 
147  template <typename T1, typename T2>
149  {
150 
153 
159  static void apply(Argument1Type t1, Argument2Type t2)
160  {
161  t1 *= t2;
162  }
163  };
164 
170  template <typename T1, typename T2>
172  {
173 
176 
182  static void apply(Argument1Type t1, Argument2Type t2)
183  {
184  t1 /= t2;
185  }
186  };
187 
196  template <typename T>
198  {
199 
201  typedef T ValueType;
203  typedef const T& ArgumentType;
206  };
207 
212  template <typename T>
214  {
215 
219 
226  {
227  return -v;
228  }
229  };
230 
235  template <typename T>
237  {
238 
242 
249  {
250  return TypeTraits<ValueType>::conj(v);
251  }
252  };
253 
258  template <typename T>
260  {
261 
263  typedef T ValueType;
265  typedef const T& ArgumentType;
268  };
269 
274  template <typename T>
276  {
277 
281 
288  {
289  return TypeTraits<ValueType>::real(v);
290  }
291  };
292 
297  template <typename T>
299  {
300 
304 
311  {
312  return TypeTraits<ValueType>::imag(v);
313  }
314  };
315 
325  template <typename T1, typename T2>
327  {
328 
330  typedef const T1& Argument1Type;
332  typedef const T2& Argument2Type;
335  };
336 
342  template <typename T1, typename T2>
343  struct ScalarAddition : public ScalarBinaryFunctor<T1, T2>
344  {
345 
349 
357  {
358  return (t1 + t2);
359  }
360  };
361 
367  template <typename T1, typename T2>
368  struct ScalarSubtraction : public ScalarBinaryFunctor<T1, T2>
369  {
370 
374 
382  {
383  return (t1 - t2);
384  }
385  };
386 
392  template <typename T1, typename T2>
394  {
395 
399 
407  {
408  return (t1 * t2);
409  }
410  };
411 
417  template <typename T1, typename T2>
418  struct ScalarDivision : public ScalarBinaryFunctor<T1, T2>
419  {
420 
424 
432  {
433  return (t1 / t2);
434  }
435  };
436 
442  template <typename V1, typename V2>
444  {
445 
448  };
449 
455  template <typename V1, typename V2>
457  {
458 
460 
469  {
471 
472  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize()), SizeType(e2().getSize()), Base::SizeError);
473  ResultType res = ResultType();
474 
475  for (SizeType i = 0; i < size; i++)
476  res += e1()(i) * e2()(i);
477 
478  return res;
479  }
480  };
481 
488  template <typename V1, typename V2, typename T>
490  {
491 
493 
502  static ResultType apply(const VectorExpression<V1>& e1, const VectorExpression<V2>& e2, const T& sd, bool clamp)
503  {
505 
506  if (!clamp)
507  return res;
508 
509  return boost::algorithm::clamp(res, ResultType(-1), ResultType(1));
510  }
511  };
512 
518  template <typename V1, typename V2>
520  {
521 
523  typedef bool ResultType;
528  };
529 
535  template <typename V1, typename V2>
537  {
538 
542 
550  {
551  if (SizeType(e1().getSize()) != SizeType(e2().getSize()))
552  return false;
553 
554  for (SizeType i = 0, size = e1().getSize(); i < size; i++)
555  if (ValueType(e1()(i)) != ValueType(e2()(i)))
556  return false;
557 
558  return true;
559  }
560  };
561 
568  template <typename V1, typename V2, typename T>
570  {
571 
573  typedef bool ResultType;
575  typedef const T& Argument3Type;
580  };
581 
588  template <typename V1, typename V2, typename T>
590  {
591 
596 
605  {
606  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
607 
608  if (SizeType(e1().getSize()) != SizeType(e2().getSize()))
609  return false;
610 
611  ComparisonType norm_inf_max(epsilon);
612 
613  for (SizeType i = 0, size = e1().getSize(); i < size; i++)
614  if (ComparisonType(TypeTraits<ValueType>::normInf(e2()(i) - e1()(i))) > norm_inf_max)
615  return false;
616 
617  return true;
618  }
619  };
620 
626  template <typename V1, typename V2>
628  {
629 
632  };
633 
639  template <typename V1, typename V2>
640  struct VectorCrossProduct : public VectorBinaryFunctor<V1, V2>
641  {
642 
644 
656  template <typename E1, typename E2, typename SizeType>
657  static ResultType apply(const VectorExpression<E1>& e1, const VectorExpression<E2>& e2, SizeType i)
658  {
659  CDPL_MATH_CHECK(e1().getSize() == 3, "Invalid vector size", Base::SizeError);
660  CDPL_MATH_CHECK(e2().getSize() == 3, "Invalid vector size", Base::SizeError);
661 
662  switch (i) {
663 
664  case 0:
665  return (e1()(1) * e2()(2) - e1()(2) * e2()(1)); // c1 = a2 * b3 - a3 * b2;
666 
667  case 1:
668  return (e1()(2) * e2()(0) - e1()(0) * e2()(2)); // c2 = a3 * b1 - a1 * b3;
669 
670  case 2:
671  return (e1()(0) * e2()(1) - e1()(1) * e2()(0)); // c3 = a1 * b2 - a2 * b1;
672 
673  default:
674  return ResultType();
675  }
676  }
677  };
678 
683  template <typename V>
685  {
686 
688  typedef typename V::ValueType ResultType;
690  typedef typename V::SizeType SizeType;
691  };
692 
697  template <typename V>
699  {
700 
702 
709  {
710  typedef typename V::SizeType SizeType;
711 
712  ResultType res = ResultType();
713 
714  for (SizeType i = 0, size = e().getSize(); i < size; i++)
715  res += e()(i);
716 
717  return res;
718  }
719  };
720 
721  template <typename V>
727  {
728 
730  typedef typename V::ValueType ValueType;
735  };
736 
741  template <typename V>
743  {
744 
748 
755  {
756  typedef typename V::SizeType SizeType;
757 
758  RealType res = RealType();
759 
760  for (SizeType i = 0, size = e().getSize(); i < size; i++)
761  res += TypeTraits<ValueType>::norm1(e()(i));
762 
763  return res;
764  }
765  };
766 
771  template <typename V>
773  {
774 
778 
785  {
786  typedef typename V::SizeType SizeType;
787 
788  RealType res2 = RealType();
789 
790  for (SizeType i = 0, size = e().getSize(); i < size; i++) {
792 
793  res2 += t * t;
794  }
795 
796  return TypeTraits<RealType>::sqrt(res2);
797  }
798  };
799 
804  template <typename V>
806  {
807 
811 
818  {
819  typedef typename V::SizeType SizeType;
820 
821  RealType res = RealType();
822 
823  for (SizeType i = 0, size = e().getSize(); i < size; i++) {
825 
826  if (t > res)
827  res = t;
828  }
829 
830  return res;
831  }
832  };
833 
838  template <typename V>
840  {
841 
843  typedef typename V::ValueType ValueType;
847  typedef typename V::SizeType ResultType;
848  };
849 
854  template <typename V>
856  {
857 
861 
868  {
869  typedef typename V::SizeType SizeType;
870 
871  RealType norm = RealType();
872  ResultType res = ResultType(0);
873 
874  for (SizeType i = 0, size = e().getSize(); i < size; i++) {
876 
877  if (t > norm) {
878  norm = t;
879  res = ResultType(i);
880  }
881  }
882 
883  return res;
884  }
885  };
886 
892  template <typename M1, typename M2>
894  {
895 
897  typedef bool ResultType;
902  };
903 
909  template <typename M1, typename M2>
911  {
912 
916 
924  {
925  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
926  return false;
927 
928  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
929  return false;
930 
931  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
932  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
933  if (ValueType(e1()(i, j)) != ValueType(e2()(i, j)))
934  return false;
935 
936  return true;
937  }
938  };
939 
946  template <typename M1, typename M2, typename T>
948  {
949 
951  typedef bool ResultType;
953  typedef const T& Argument3Type;
958  };
959 
966  template <typename M1, typename M2, typename T>
968  {
969 
974 
983  {
984  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
985 
986  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
987  return false;
988 
989  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
990  return false;
991 
992  ComparisonType norm_inf_max(epsilon);
993 
994  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
995  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
996  if (ComparisonType(TypeTraits<ValueType>::normInf(e2()(i, j) - e1()(i, j))) > norm_inf_max)
997  return false;
998 
999  return true;
1000  }
1001  };
1002 
1007  template <typename M>
1009  {
1010 
1012  typedef typename M::ValueType ResultType;
1013  };
1014 
1019  template <typename M>
1021  {
1022 
1024 
1031  {
1032  typedef typename M::SizeType SizeType;
1033 
1034  ResultType res = ResultType();
1035  SizeType size1 = e().getSize1();
1036  SizeType size2 = e().getSize2();
1037 
1038  for (SizeType i = 0; i < size1; i++)
1039  for (SizeType j = 0; j < size2; j++)
1040  res += e()(i, j);
1041 
1042  return res;
1043  }
1044  };
1045 
1050  template <typename M>
1052  {
1053 
1055 
1063  {
1064  typedef typename M::SizeType SizeType;
1065 
1066  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(e().getSize1(), e().getSize2(), Base::SizeError);
1067  ResultType res = ResultType();
1068 
1069  for (SizeType i = 0; i < size; i++)
1070  res += e()(i, i);
1071 
1072  return res;
1073  }
1074  };
1075 
1080  template <typename M>
1082  {
1083 
1085  typedef typename M::ValueType ValueType;
1090  };
1091 
1096  template <typename M>
1098  {
1099 
1103 
1110  {
1111  typedef typename M::SizeType SizeType;
1112 
1113  RealType res = RealType();
1114  SizeType size1 = e().getSize1();
1115  SizeType size2 = e().getSize2();
1116 
1117  for (SizeType j = 0; j < size2; j++) {
1118  RealType t = RealType();
1119 
1120  for (SizeType i = 0; i < size1; i++)
1121  t += TypeTraits<ValueType>::norm1(e()(i, j));
1122 
1123  if (t > res)
1124  res = t;
1125  }
1126 
1127  return res;
1128  }
1129  };
1130 
1135  template <typename M>
1137  {
1138 
1142 
1149  {
1150  typedef typename M::SizeType SizeType;
1151 
1152  RealType res2 = RealType();
1153  SizeType size1 = e().getSize1();
1154  SizeType size2 = e().getSize2();
1155 
1156  for (SizeType i = 0; i < size1; i++) {
1157  for (SizeType j = 0; j < size2; j++) {
1158  RealType t = TypeTraits<ValueType>::norm2(e()(i, j));
1159 
1160  res2 += t * t;
1161  }
1162  }
1163 
1164  return TypeTraits<RealType>::sqrt(res2);
1165  }
1166  };
1167 
1172  template <typename M>
1174  {
1175 
1179 
1186  {
1187  typedef typename M::SizeType SizeType;
1188 
1189  RealType res = RealType();
1190  SizeType size1 = e().getSize1();
1191  SizeType size2 = e().getSize2();
1192 
1193  for (SizeType i = 0; i < size1; i++) {
1194  RealType t = RealType();
1195 
1196  for (SizeType j = 0; j < size2; j++)
1197  t += TypeTraits<ValueType>::normInf(e()(i, j));
1198 
1199  if (t > res)
1200  res = t;
1201  }
1202 
1203  return res;
1204  }
1205  };
1206 
1211  template <typename V>
1213  {
1214 
1216  typedef typename V::ValueType ResultType;
1218  typedef typename V::SizeType SizeType;
1219  };
1220 
1225  template <typename V>
1227  {
1228 
1231 
1240  template <typename E>
1242  {
1243  if (i == j)
1244  return e()(i);
1245 
1246  return ResultType();
1247  }
1248  };
1249 
1254  template <typename V>
1256  {
1257 
1260 
1270  template <typename E>
1272  {
1273  CDPL_MATH_CHECK(e().getSize() == 3, "Invalid vector size", Base::SizeError);
1274 
1275  // | 0 -a3 a2 |
1276  // cross([a1, a2, a3]) = | a3 0 -a1 |
1277  // | -a2 a1 0 |
1278  switch (i) {
1279 
1280  case 0:
1281  switch (j) {
1282 
1283  case 1:
1284  return -e()(2);
1285 
1286  case 2:
1287  return e()(1);
1288 
1289  default:
1290  return ResultType();
1291  }
1292 
1293  case 1:
1294  switch (j) {
1295 
1296  case 0:
1297  return e()(2);
1298 
1299  case 2:
1300  return -e()(0);
1301 
1302  default:
1303  return ResultType();
1304  }
1305 
1306  case 2:
1307  switch (j) {
1308 
1309  case 0:
1310  return -e()(1);
1311 
1312  case 1:
1313  return e()(0);
1314 
1315  default:
1316  return ResultType();
1317  }
1318 
1319  default:
1320  return ResultType();
1321  }
1322  }
1323  };
1324 
1330  template <typename M, typename V>
1332  {
1333 
1340  };
1341 
1347  template <typename M, typename V>
1349  {
1350 
1354 
1365  template <typename E1, typename E2>
1367  {
1368  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize2()), SizeType(e2().getSize()), Base::SizeError);
1369  ResultType res = ResultType();
1370 
1371  for (SizeType j = 0; j < size; j++)
1372  res += e1()(i, j) * e2()(j);
1373 
1374  return res;
1375  }
1376  };
1377 
1383  template <typename V, typename M>
1385  {
1386 
1390 
1401  template <typename E1, typename E2>
1403  {
1404  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize()), SizeType(e2().getSize1()), Base::SizeError);
1405  ResultType res = ResultType();
1406 
1407  for (SizeType j = 0; j < size; j++)
1408  res += e1()(j) * e2()(j, i);
1409 
1410  return res;
1411  }
1412  };
1413 
1419  template <typename M1, typename M2>
1421  {
1422 
1429  };
1430 
1436  template <typename M1, typename M2>
1437  struct MatrixProduct : public MatrixBinaryFunctor<M1, M2>
1438  {
1439 
1443 
1455  template <typename E1, typename E2>
1457  {
1458  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize2()), SizeType(e2().getSize1()), Base::SizeError);
1459  ResultType res = ResultType();
1460 
1461  for (SizeType k = 0; k < size; k++)
1462  res += e1()(i, k) * e2()(k, j);
1463 
1464  return res;
1465  }
1466  };
1467 
1473  template <typename Q1, typename Q2>
1475  {
1476 
1478  typedef bool ResultType;
1481  };
1482 
1488  template <typename Q1, typename Q2>
1490  {
1491 
1494 
1502  {
1503  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()));
1504  }
1505  };
1506 
1513  template <typename Q1, typename Q2, typename T>
1515  {
1516 
1518  typedef bool ResultType;
1520  typedef const T& Argument3Type;
1523  };
1524 
1531  template <typename Q1, typename Q2, typename T>
1533  {
1534 
1538 
1547  {
1548  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
1549 
1550  ComparisonType norm_inf_max(epsilon);
1551 
1552  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);
1553  }
1554  };
1555 
1560  template <typename Q>
1562  {
1563 
1565  typedef typename Q::ValueType ResultType;
1566  };
1567 
1572  template <typename Q>
1574  {
1575 
1577 
1584  {
1585  return (e().getC1() + e().getC2() + e().getC3() + e().getC4());
1586  }
1587  };
1588 
1593  template <typename Q>
1595  {
1596 
1598  typedef typename Q::ValueType ValueType;
1603  };
1604 
1609  template <typename Q>
1611  {
1612 
1616 
1623  {
1624  RealType t = e().getC1() * e().getC1() +
1625  e().getC2() * e().getC2() +
1626  e().getC3() * e().getC3() +
1627  e().getC4() * e().getC4();
1628 
1629  return TypeTraits<RealType>::sqrt(t);
1630  }
1631  };
1632 
1637  template <typename Q>
1639  {
1640 
1644 
1651  {
1652  RealType t = e().getC1() * e().getC1() +
1653  e().getC2() * e().getC2() +
1654  e().getC3() * e().getC3() +
1655  e().getC4() * e().getC4();
1656 
1657  return t;
1658  }
1659  };
1660 
1665  template <typename Q>
1667  {
1668 
1670  typedef typename Q::ValueType ResultType;
1671  };
1672 
1677  template <typename Q>
1679  {
1680 
1682 
1689  template <typename E>
1691  {
1692  return ResultType();
1693  }
1694 
1701  template <typename E>
1703  {
1704  return e().getC2();
1705  }
1706 
1713  template <typename E>
1715  {
1716  return e().getC3();
1717  }
1718 
1725  template <typename E>
1727  {
1728  return e().getC4();
1729  }
1730  };
1731 
1736  template <typename Q>
1738  {
1739 
1741 
1748  template <typename E>
1750  {
1751  return e().getC1();
1752  }
1753 
1760  template <typename E>
1762  {
1763  return -e().getC2();
1764  }
1765 
1772  template <typename E>
1774  {
1775  return -e().getC3();
1776  }
1777 
1784  template <typename E>
1786  {
1787  return -e().getC4();
1788  }
1789  };
1790 
1796  template <typename T, typename Q>
1798  {
1799 
1803  typedef const T& Argument1Type;
1804  };
1805 
1811  template <typename T, typename Q>
1813  {
1814 
1817 
1825  template <typename E>
1827  {
1828  return (t + e().getC1());
1829  }
1830 
1837  template <typename E>
1839  {
1840  return e().getC2();
1841  }
1842 
1849  template <typename E>
1851  {
1852  return e().getC3();
1853  }
1854 
1861  template <typename E>
1863  {
1864  return e().getC4();
1865  }
1866  };
1867 
1873  template <typename T, typename Q>
1875  {
1876 
1879 
1887  template <typename E>
1889  {
1890  return (t - e().getC1());
1891  }
1892 
1899  template <typename E>
1901  {
1902  return -e().getC2();
1903  }
1904 
1911  template <typename E>
1913  {
1914  return -e().getC3();
1915  }
1916 
1923  template <typename E>
1925  {
1926  return -e().getC4();
1927  }
1928  };
1929 
1935  template <typename Q, typename T>
1937  {
1938 
1942  typedef const T& Argument2Type;
1943  };
1944 
1950  template <typename Q, typename T>
1952  {
1953 
1956 
1964  template <typename E>
1966  {
1967  return (e().getC1() + t);
1968  }
1969 
1976  template <typename E>
1978  {
1979  return e().getC2();
1980  }
1981 
1988  template <typename E>
1990  {
1991  return e().getC3();
1992  }
1993 
2000  template <typename E>
2002  {
2003  return e().getC4();
2004  }
2005  };
2006 
2012  template <typename Q, typename T>
2014  {
2015 
2018 
2026  template <typename E>
2028  {
2029  return (e().getC1() - t);
2030  }
2031 
2038  template <typename E>
2040  {
2041  return e().getC2();
2042  }
2043 
2050  template <typename E>
2052  {
2053  return e().getC3();
2054  }
2055 
2062  template <typename E>
2064  {
2065  return e().getC4();
2066  }
2067  };
2068 
2074  template <typename Q, typename T>
2076  {
2077 
2080 
2088  template <typename E>
2090  {
2091  return (e().getC1() / n2);
2092  }
2093 
2101  template <typename E>
2103  {
2104  return (-e().getC2() / n2);
2105  }
2106 
2114  template <typename E>
2116  {
2117  return (-e().getC3() / n2);
2118  }
2119 
2127  template <typename E>
2129  {
2130  return (-e().getC4() / n2);
2131  }
2132  };
2133 
2139  template <typename Q1, typename Q2>
2141  {
2142 
2145  };
2146 
2152  template <typename Q1, typename Q2>
2154  {
2155 
2157 
2166  template <typename E1, typename E2>
2168  {
2169  // a = a1 * a2 - b1 * b2 - c1 * c2 - d1 * d2
2170  return (e1().getC1() * e2().getC1() - e1().getC2() * e2().getC2() - e1().getC3() * e2().getC3() - e1().getC4() * e2().getC4());
2171  }
2172 
2181  template <typename E1, typename E2>
2183  {
2184  // b = a1 * b2 + b1 * a2 + c1 * d2 - d1 * c2
2185  return (e1().getC1() * e2().getC2() + e1().getC2() * e2().getC1() + e1().getC3() * e2().getC4() - e1().getC4() * e2().getC3());
2186  }
2187 
2196  template <typename E1, typename E2>
2198  {
2199  // c = a1 * c2 - b1 * d2 + c1 * a2 + d1 * b2
2200  return (e1().getC1() * e2().getC3() - e1().getC2() * e2().getC4() + e1().getC3() * e2().getC1() + e1().getC4() * e2().getC2());
2201  }
2202 
2211  template <typename E1, typename E2>
2213  {
2214  // d = a1 * d2 + b1 * c2 - c1 * b2 + d1 * a2
2215  return (e1().getC1() * e2().getC4() + e1().getC2() * e2().getC3() - e1().getC3() * e2().getC2() + e1().getC4() * e2().getC1());
2216  }
2217  };
2218 
2225  template <typename Q1, typename Q2, typename T>
2227  {
2228 
2232  typedef const T& Argument3Type;
2233  };
2234 
2241  template <typename Q1, typename Q2, typename T>
2243  {
2244 
2247 
2257  template <typename E1, typename E2>
2259  {
2260  // a = (a1 * a2 + b1 * b2 + c1 * c2 + d1 * d2) / n2
2261  return ((e1().getC1() * e2().getC1() + e1().getC2() * e2().getC2() + e1().getC3() * e2().getC3() + e1().getC4() * e2().getC4()) / n2);
2262  }
2263 
2273  template <typename E1, typename E2>
2275  {
2276  // b = (-a1 * b2 + b1 * a2 - c1 * d2 + d1 * c2) / n2
2277  return ((-e1().getC1() * e2().getC2() + e1().getC2() * e2().getC1() - e1().getC3() * e2().getC4() + e1().getC4() * e2().getC3()) / n2);
2278  }
2279 
2289  template <typename E1, typename E2>
2291  {
2292  // c = (-a1 * c2 + b1 * d2 + c1 * a2 - d1 * b2) / n2
2293  return ((-e1().getC1() * e2().getC3() + e1().getC2() * e2().getC4() + e1().getC3() * e2().getC1() - e1().getC4() * e2().getC2()) / n2);
2294  }
2295 
2305  template <typename E1, typename E2>
2307  {
2308  // d = (-a1 * d2 - b1 * c2 + c1 * b2 + d1 * a2) / n2
2309  return ((-e1().getC1() * e2().getC4() - e1().getC2() * e2().getC3() + e1().getC3() * e2().getC2() + e1().getC4() * e2().getC1()) / n2);
2310  }
2311  };
2312 
2319  template <typename T1, typename Q, typename T2>
2321  {
2322 
2326  typedef const T1& Argument1Type;
2328  typedef const T2& Argument3Type;
2329  };
2330 
2337  template <typename T1, typename Q, typename T2>
2339  {
2340 
2344 
2353  template <typename E>
2355  {
2356  return (t * e().getC1() / n2);
2357  }
2358 
2367  template <typename E>
2369  {
2370  return (t * -e().getC2() / n2);
2371  }
2372 
2381  template <typename E>
2383  {
2384  return (t * -e().getC3() / n2);
2385  }
2386 
2395  template <typename E>
2397  {
2398  return (t * -e().getC4() / n2);
2399  }
2400  };
2401 
2407  template <typename Q, typename V>
2409  {
2410 
2414  typedef typename V::SizeType SizeType;
2417  };
2418 
2425  template <typename Q, typename V>
2427  {
2428 
2432 
2443  template <typename E1, typename E2>
2445  {
2446  CDPL_MATH_CHECK(e2().getSize() >= 3, "Invalid vector size", Base::SizeError);
2447 
2448  switch (i) {
2449 
2450  case 0: {
2451  // vr1 = (a2 + b2 - c2 - d2) * v1 + (2bc - 2ad) * v2 + (2bd + 2ac) * v3
2452  ValueType t1 = e1().getC1() * e1().getC1() + e1().getC2() * e1().getC2() - e1().getC3() * e1().getC3() - e1().getC4() * e1().getC4();
2453  ValueType t2 = ValueType(2) * (e1().getC2() * e1().getC3() - e1().getC1() * e1().getC4());
2454  ValueType t3 = ValueType(2) * (e1().getC2() * e1().getC4() + e1().getC1() * e1().getC3());
2455 
2456  return (t1 * e2()(0) + t2 * e2()(1) + t3 * e2()(2));
2457  }
2458 
2459  case 1: {
2460  // vr2 = (2bc + 2ad) * v1 + (a2 - b2 + c2 - d2) * v2 + (2cd - 2ab) * v3
2461  ValueType t1 = ValueType(2) * (e1().getC2() * e1().getC3() + e1().getC1() * e1().getC4());
2462  ValueType t2 = e1().getC1() * e1().getC1() - e1().getC2() * e1().getC2() + e1().getC3() * e1().getC3() - e1().getC4() * e1().getC4();
2463  ValueType t3 = ValueType(2) * (e1().getC3() * e1().getC4() - e1().getC1() * e1().getC2());
2464 
2465  return (t1 * e2()(0) + t2 * e2()(1) + t3 * e2()(2));
2466  }
2467 
2468  case 2: {
2469  // vr3 = (2bd - 2ac) * v1 + (2cd + 2ab) * v2 + (a2 - b2 - c2 + d2) * v3
2470  ValueType t1 = ValueType(2) * (e1().getC2() * e1().getC4() - e1().getC1() * e1().getC3());
2471  ValueType t2 = ValueType(2) * (e1().getC3() * e1().getC4() + e1().getC1() * e1().getC2());
2472  ValueType t3 = e1().getC1() * e1().getC1() - e1().getC2() * e1().getC2() - e1().getC3() * e1().getC3() + e1().getC4() * e1().getC4();
2473 
2474  return (t1 * e2()(0) + t2 * e2()(1) + t3 * e2()(2));
2475  }
2476 
2477  default:
2478  return ResultType();
2479  }
2480  }
2481  };
2482 
2488  template <typename G1, typename G2>
2490  {
2491 
2493  typedef bool ResultType;
2498  };
2499 
2505  template <typename G1, typename G2>
2506  struct GridEquality : public GridBooleanBinaryFunctor<G1, G2>
2507  {
2508 
2512 
2520  {
2521  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
2522  return false;
2523 
2524  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
2525  return false;
2526 
2527  if (SizeType(e1().getSize3()) != SizeType(e2().getSize3()))
2528  return false;
2529 
2530  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
2531  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
2532  for (SizeType k = 0, size3 = e1().getSize3(); k < size3; k++)
2533  if (ValueType(e1()(i, j, k)) != ValueType(e2()(i, j, k)))
2534  return false;
2535 
2536  return true;
2537  }
2538  };
2539 
2546  template <typename G1, typename G2, typename T>
2548  {
2549 
2551  typedef bool ResultType;
2553  typedef const T& Argument3Type;
2558  };
2559 
2566  template <typename G1, typename G2, typename T>
2568  {
2569 
2574 
2583  {
2584  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
2585 
2586  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
2587  return false;
2588 
2589  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
2590  return false;
2591 
2592  if (SizeType(e1().getSize3()) != SizeType(e2().getSize3()))
2593  return false;
2594 
2595  ComparisonType norm_inf_max(epsilon);
2596 
2597  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
2598  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
2599  for (SizeType k = 0, size3 = e1().getSize3(); k < size3; k++)
2600  if (ComparisonType(TypeTraits<ValueType>::normInf(e2()(i, j, k) - e1()(i, j, k))) > norm_inf_max)
2601  return false;
2602 
2603  return true;
2604  }
2605  };
2606 
2611  template <typename M>
2613  {
2614 
2616  typedef typename M::ValueType ResultType;
2617  };
2618 
2623  template <typename G>
2625  {
2626 
2628 
2635  {
2636  typedef typename G::SizeType SizeType;
2637 
2638  ResultType res = ResultType();
2639  SizeType size1 = e().getSize1();
2640  SizeType size2 = e().getSize2();
2641  SizeType size3 = e().getSize3();
2642 
2643  for (SizeType i = 0; i < size1; i++)
2644  for (SizeType j = 0; j < size2; j++)
2645  for (SizeType k = 0; k < size3; k++)
2646  res += e()(i, j, k);
2647 
2648  return res;
2649  }
2650  };
2651  } // namespace Math
2652 } // namespace CDPL
2653 
2654 #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 for all grid expression types.
Definition: Expression.hpp:180
CRTP base class for all matrix expression types.
Definition: Expression.hpp:104
CRTP base class for all quaternion expression types.
Definition: Expression.hpp:142
CRTP base class for all vector expression types.
Definition: Expression.hpp:66
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:1384
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:49
Functor producing the cross-product (skew-symmetric) matrix entry at (i, j) for a 3-vector expression...
Definition: Functional.hpp:1256
VectorScalarUnaryFunctor< V >::SizeType SizeType
Definition: Functional.hpp:1259
static ResultType apply(const VectorExpression< E > &e, SizeType i, SizeType j)
Returns the (i, j) entry of the skew-symmetric matrix corresponding to the 3-vector e.
Definition: Functional.hpp:1271
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:1258
Functor producing the diagonal-matrix entry at (i, j) from a vector expression ( on the diagonal,...
Definition: Functional.hpp:1227
VectorScalarUnaryFunctor< V >::SizeType SizeType
Definition: Functional.hpp:1230
static ResultType apply(const VectorExpression< E > &e, SizeType i, SizeType j)
Returns if i equals j, otherwise 0.
Definition: Functional.hpp:1241
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:1229
Base class for binary functors that take two grid expressions and return a bool result (Math::GridEqu...
Definition: Functional.hpp:2490
CommonType< typename G1::SizeType, typename G2::SizeType >::Type SizeType
The unsigned size type (common type of the two grid size types).
Definition: Functional.hpp:2495
bool ResultType
The boolean result type.
Definition: Functional.hpp:2493
CommonType< typename G1::ValueType, typename G2::ValueType >::Type ValueType
The cell value type (common type of the two grid cell types).
Definition: Functional.hpp:2497
Functor returning the sum of all cells of a grid expression.
Definition: Functional.hpp:2625
GridScalarUnaryFunctor< G >::ResultType ResultType
Definition: Functional.hpp:2627
static ResultType apply(const GridExpression< G > &e)
Returns the cell sum of e.
Definition: Functional.hpp:2634
Functor checking cell-wise equality of two grid expressions.
Definition: Functional.hpp:2507
static ResultType apply(const GridExpression< G1 > &e1, const GridExpression< G2 > &e2)
Tells whether e1 and e2 have the same dimensions and equal cell values.
Definition: Functional.hpp:2519
GridBooleanBinaryFunctor< G1, G2 >::ResultType ResultType
Definition: Functional.hpp:2511
GridBooleanBinaryFunctor< G1, G2 >::SizeType SizeType
Definition: Functional.hpp:2509
GridBooleanBinaryFunctor< G1, G2 >::ValueType ValueType
Definition: Functional.hpp:2510
Base class for unary functors that take a grid expression and return a scalar result (Math::GridEleme...
Definition: Functional.hpp:2613
M::ValueType ResultType
The scalar result type (the grid's cell value type).
Definition: Functional.hpp:2616
Functor checking cell-wise approximate equality of two grid expressions within an absolute tolerance.
Definition: Functional.hpp:2568
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::ValueType ValueType
Definition: Functional.hpp:2571
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::ResultType ResultType
Definition: Functional.hpp:2572
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::SizeType SizeType
Definition: Functional.hpp:2570
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:2573
static ResultType apply(const GridExpression< G1 > &e1, const GridExpression< G2 > &e2, Argument3Type epsilon)
Tells whether e1 and e2 agree cell-wise within the absolute tolerance epsilon.
Definition: Functional.hpp:2582
Base class for binary functors that take two matrix expressions and return a matrix-element scalar re...
Definition: Functional.hpp:1421
ValueType ResultType
The scalar result type (alias for ValueType).
Definition: Functional.hpp:1428
CommonType< typename M1::ValueType, typename M2::ValueType >::Type ValueType
The element value type (common type of the two matrix element types).
Definition: Functional.hpp:1424
CommonType< typename M1::SizeType, typename M2::SizeType >::Type SizeType
The unsigned size type (common type of the two matrix size types).
Definition: Functional.hpp:1426
Base class for binary functors that take two matrix expressions and return a bool result (Math::Matri...
Definition: Functional.hpp:894
CommonType< typename M1::SizeType, typename M2::SizeType >::Type SizeType
The unsigned size type (common type of the two matrix size types).
Definition: Functional.hpp:899
CommonType< typename M1::ValueType, typename M2::ValueType >::Type ValueType
The element value type (common type of the two matrix element types).
Definition: Functional.hpp:901
bool ResultType
The boolean result type.
Definition: Functional.hpp:897
Functor returning the sum of all elements of a matrix expression.
Definition: Functional.hpp:1021
MatrixScalarUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:1023
static ResultType apply(const MatrixExpression< M > &e)
Returns the element sum of e.
Definition: Functional.hpp:1030
Functor checking element-wise equality of two matrix expressions.
Definition: Functional.hpp:911
MatrixBooleanBinaryFunctor< M1, M2 >::SizeType SizeType
Definition: Functional.hpp:913
MatrixBooleanBinaryFunctor< M1, M2 >::ResultType ResultType
Definition: Functional.hpp:915
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:923
MatrixBooleanBinaryFunctor< M1, M2 >::ValueType ValueType
Definition: Functional.hpp:914
Functor returning the L1 (maximum absolute column sum) norm of a matrix expression.
Definition: Functional.hpp:1098
MatrixScalarRealUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:1102
MatrixScalarRealUnaryFunctor< M >::RealType RealType
Definition: Functional.hpp:1101
MatrixScalarRealUnaryFunctor< M >::ValueType ValueType
Definition: Functional.hpp:1100
static ResultType apply(const MatrixExpression< M > &e)
Returns the L1 norm of e.
Definition: Functional.hpp:1109
Functor returning the Frobenius norm of a matrix expression.
Definition: Functional.hpp:1137
static ResultType apply(const MatrixExpression< M > &e)
Returns the Frobenius norm of e.
Definition: Functional.hpp:1148
MatrixScalarRealUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:1141
MatrixScalarRealUnaryFunctor< M >::RealType RealType
Definition: Functional.hpp:1140
MatrixScalarRealUnaryFunctor< M >::ValueType ValueType
Definition: Functional.hpp:1139
Functor returning the L∞ (maximum absolute row sum) norm of a matrix expression.
Definition: Functional.hpp:1174
static ResultType apply(const MatrixExpression< M > &e)
Returns the L∞ norm of e.
Definition: Functional.hpp:1185
MatrixScalarRealUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:1178
MatrixScalarRealUnaryFunctor< M >::ValueType ValueType
Definition: Functional.hpp:1176
MatrixScalarRealUnaryFunctor< M >::RealType RealType
Definition: Functional.hpp:1177
Functor returning entry (i, j) of the matrix product .
Definition: Functional.hpp:1438
MatrixVectorBinaryFunctor< M1, M2 >::ValueType ValueType
Definition: Functional.hpp:1440
MatrixVectorBinaryFunctor< M1, M2 >::SizeType SizeType
Definition: Functional.hpp:1441
MatrixVectorBinaryFunctor< M1, M2 >::ResultType ResultType
Definition: Functional.hpp:1442
static ResultType apply(const MatrixExpression< E1 > &e1, const MatrixExpression< E2 > &e2, SizeType i, SizeType j)
Returns entry (i, j) of the matrix product .
Definition: Functional.hpp:1456
Base class for unary functors that take a matrix expression and return a real-valued scalar (Math::Ma...
Definition: Functional.hpp:1082
M::ValueType ValueType
The matrix's element value type.
Definition: Functional.hpp:1085
RealType ResultType
The real-valued result type.
Definition: Functional.hpp:1089
TypeTraits< ValueType >::RealType RealType
The real-valued type derived from ValueType via Math::TypeTraits.
Definition: Functional.hpp:1087
Base class for unary functors that take a matrix expression and return a scalar result (Math::MatrixE...
Definition: Functional.hpp:1009
M::ValueType ResultType
The scalar result type (the matrix's element value type).
Definition: Functional.hpp:1012
Functor checking element-wise approximate equality of two matrix expressions within an absolute toler...
Definition: Functional.hpp:968
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:982
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::ValueType ValueType
Definition: Functional.hpp:971
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:973
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::ResultType ResultType
Definition: Functional.hpp:972
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::SizeType SizeType
Definition: Functional.hpp:970
Functor returning the trace (sum of diagonal entries) of a matrix expression.
Definition: Functional.hpp:1052
MatrixScalarUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:1054
static ResultType apply(const MatrixExpression< M > &e)
Returns the trace of e.
Definition: Functional.hpp:1062
Base class for binary functors that take a matrix expression and a vector expression and return a vec...
Definition: Functional.hpp:1332
ValueType ResultType
The scalar result type (alias for ValueType).
Definition: Functional.hpp:1339
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:1335
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:1337
Functor returning element i of the matrix-vector product .
Definition: Functional.hpp:1349
MatrixVectorBinaryFunctor< M, V >::ValueType ValueType
Definition: Functional.hpp:1351
MatrixVectorBinaryFunctor< M, V >::ResultType ResultType
Definition: Functional.hpp:1353
MatrixVectorBinaryFunctor< M, V >::SizeType SizeType
Definition: Functional.hpp:1352
static ResultType apply(const MatrixExpression< E1 > &e1, const VectorExpression< E2 > &e2, SizeType i)
Returns element i of the matrix-vector product .
Definition: Functional.hpp:1366
Base class for per-component binary functors that take two quaternion expressions and produce a quate...
Definition: Functional.hpp:2141
CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type ResultType
The component result type (common type of the two quaternion element types).
Definition: Functional.hpp:2144
Base class for binary functors that take two quaternion expressions and return a bool result (Math::Q...
Definition: Functional.hpp:1475
CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type ValueType
The component value type (common type of the two quaternion element types).
Definition: Functional.hpp:1480
bool ResultType
The boolean result type.
Definition: Functional.hpp:1478
Per-component functor returning the quaternion conjugate (keeps C1, negates C2/C3/C4).
Definition: Functional.hpp:1738
static ResultType applyC4(const QuaternionExpression< E > &e)
Returns the C4 component of the conjugate (equals -e.getC4()).
Definition: Functional.hpp:1785
static ResultType applyC2(const QuaternionExpression< E > &e)
Returns the C2 component of the conjugate (equals -e.getC2()).
Definition: Functional.hpp:1761
static ResultType applyC3(const QuaternionExpression< E > &e)
Returns the C3 component of the conjugate (equals -e.getC3()).
Definition: Functional.hpp:1773
static ResultType applyC1(const QuaternionExpression< E > &e)
Returns the C1 component of the conjugate (equals e.getC1()).
Definition: Functional.hpp:1749
QuaternionUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1740
Per-component functor returning the quaternion division (n2 is the precomputed squared norm of e_2).
Definition: Functional.hpp:2243
static ResultType applyC3(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Returns the C3 component of the quaternion division .
Definition: Functional.hpp:2290
static ResultType applyC1(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Returns the C1 component of the quaternion division .
Definition: Functional.hpp:2258
Scalar3QuaternionTernaryFunctor< Q1, Q2, T >::ResultType ResultType
Definition: Functional.hpp:2246
static ResultType applyC4(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Returns the C4 component of the quaternion division .
Definition: Functional.hpp:2306
static ResultType applyC2(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Returns the C2 component of the quaternion division .
Definition: Functional.hpp:2274
Scalar3QuaternionTernaryFunctor< Q1, Q2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:2245
Functor returning the sum of the four components of a quaternion expression.
Definition: Functional.hpp:1574
QuaternionScalarUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1576
static ResultType apply(const QuaternionExpression< Q > &e)
Returns the component sum of e.
Definition: Functional.hpp:1583
Functor checking component-wise equality of two quaternion expressions.
Definition: Functional.hpp:1490
static ResultType apply(const QuaternionExpression< Q1 > &e1, const QuaternionExpression< Q2 > &e2)
Tells whether e1 and e2 have equal components.
Definition: Functional.hpp:1501
QuaternionBooleanBinaryFunctor< Q1, Q2 >::ResultType ResultType
Definition: Functional.hpp:1493
QuaternionBooleanBinaryFunctor< Q1, Q2 >::ValueType ValueType
Definition: Functional.hpp:1492
Per-component functor returning the multiplicative inverse of a quaternion expression (n2 is the pre...
Definition: Functional.hpp:2076
static ResultType applyC3(const QuaternionExpression< E > &e, Argument2Type n2)
Returns the C3 component of the multiplicative inverse .
Definition: Functional.hpp:2115
Scalar2QuaternionBinaryFunctor< Q, T >::ResultType ResultType
Definition: Functional.hpp:2079
static ResultType applyC1(const QuaternionExpression< E > &e, Argument2Type n2)
Returns the C1 (real) component of the multiplicative inverse .
Definition: Functional.hpp:2089
Scalar2QuaternionBinaryFunctor< Q, T >::Argument2Type Argument2Type
Definition: Functional.hpp:2078
static ResultType applyC2(const QuaternionExpression< E > &e, Argument2Type n2)
Returns the C2 component of the multiplicative inverse .
Definition: Functional.hpp:2102
static ResultType applyC4(const QuaternionExpression< E > &e, Argument2Type n2)
Returns the C4 component of the multiplicative inverse .
Definition: Functional.hpp:2128
Functor returning the squared norm of a quaternion expression.
Definition: Functional.hpp:1639
QuaternionScalarRealUnaryFunctor< Q >::RealType RealType
Definition: Functional.hpp:1642
static ResultType apply(const QuaternionExpression< Q > &e)
Returns .
Definition: Functional.hpp:1650
QuaternionScalarRealUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1643
QuaternionScalarRealUnaryFunctor< Q >::ValueType ValueType
Definition: Functional.hpp:1641
Functor returning the (Euclidean) norm of a quaternion expression.
Definition: Functional.hpp:1611
QuaternionScalarRealUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1615
static ResultType apply(const QuaternionExpression< Q > &e)
Returns .
Definition: Functional.hpp:1622
QuaternionScalarRealUnaryFunctor< Q >::ValueType ValueType
Definition: Functional.hpp:1613
QuaternionScalarRealUnaryFunctor< Q >::RealType RealType
Definition: Functional.hpp:1614
Per-component functor returning the Hamilton product of two quaternion expressions.
Definition: Functional.hpp:2154
QuaternionBinaryFunctor< Q1, Q2 >::ResultType ResultType
Definition: Functional.hpp:2156
static ResultType applyC3(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Returns the C3 component of the Hamilton product .
Definition: Functional.hpp:2197
static ResultType applyC2(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Returns the C2 component of the Hamilton product .
Definition: Functional.hpp:2182
static ResultType applyC4(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Returns the C4 component of the Hamilton product .
Definition: Functional.hpp:2212
static ResultType applyC1(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Returns the C1 component of the Hamilton product .
Definition: Functional.hpp:2167
Base class for unary functors that take a quaternion expression and return a real-valued scalar (Math...
Definition: Functional.hpp:1595
RealType ResultType
The real-valued result type.
Definition: Functional.hpp:1602
Q::ValueType ValueType
The quaternion's component value type.
Definition: Functional.hpp:1598
ValueType RealType
The real-valued type (alias for ValueType).
Definition: Functional.hpp:1600
Base class for unary functors that take a quaternion expression and return a scalar result (Math::Qua...
Definition: Functional.hpp:1562
Q::ValueType ResultType
The scalar result type (the quaternion's element value type).
Definition: Functional.hpp:1565
Functor checking component-wise approximate equality of two quaternion expressions within an absolute...
Definition: Functional.hpp:1533
Scalar3QuaternionBooleanTernaryFunctor< Q1, Q2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:1537
Scalar3QuaternionBooleanTernaryFunctor< Q1, Q2, T >::ValueType ValueType
Definition: Functional.hpp:1535
Scalar3QuaternionBooleanTernaryFunctor< Q1, Q2, T >::ResultType ResultType
Definition: Functional.hpp:1536
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:1546
Base class for per-component unary functors that take a quaternion expression and produce a quaternio...
Definition: Functional.hpp:1667
Q::ValueType ResultType
The component result type (the quaternion's element value type).
Definition: Functional.hpp:1670
Per-component functor returning the unreal (pure-quaternion) part of a quaternion expression (zeros C...
Definition: Functional.hpp:1679
QuaternionUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1681
static ResultType applyC1(const QuaternionExpression< E > &e)
Returns the C1 component of the unreal part (always zero).
Definition: Functional.hpp:1690
static ResultType applyC2(const QuaternionExpression< E > &e)
Returns the C2 component of the unreal part (equals e.getC2()).
Definition: Functional.hpp:1702
static ResultType applyC3(const QuaternionExpression< E > &e)
Returns the C3 component of the unreal part (equals e.getC3()).
Definition: Functional.hpp:1714
static ResultType applyC4(const QuaternionExpression< E > &e)
Returns the C4 component of the unreal part (equals e.getC4()).
Definition: Functional.hpp:1726
Base class for binary functors that take a quaternion expression and a vector expression and return a...
Definition: Functional.hpp:2409
ValueType ResultType
The scalar result type (alias for ValueType).
Definition: Functional.hpp:2416
V::SizeType SizeType
The unsigned size type used by the vector.
Definition: Functional.hpp:2414
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:2412
Functor returning element i of the rotated 3-dimensional vector (quaternion rotation of by ).
Definition: Functional.hpp:2427
QuaternionVectorBinaryFunctor< Q, V >::SizeType SizeType
Definition: Functional.hpp:2430
QuaternionVectorBinaryFunctor< Q, V >::ResultType ResultType
Definition: Functional.hpp:2431
QuaternionVectorBinaryFunctor< Q, V >::ValueType ValueType
Definition: Functional.hpp:2429
static ResultType apply(const QuaternionExpression< E1 > &e1, const VectorExpression< E2 > &e2, SizeType i)
Returns element i ( ) of the rotated 3-vector .
Definition: Functional.hpp:2444
Base class for per-component ternary functors that take a scalar T1 (lhs), a quaternion expression,...
Definition: Functional.hpp:2321
const T1 & Argument1Type
The first (scalar) argument type.
Definition: Functional.hpp:2326
const T2 & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:2328
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:2324
Per-component functor returning (scalar t added to the real component of e).
Definition: Functional.hpp:1813
static ResultType applyC4(Argument1Type, const QuaternionExpression< E > &e)
Returns the C4 component of .
Definition: Functional.hpp:1862
static ResultType applyC1(Argument1Type t, const QuaternionExpression< E > &e)
Returns the C1 component of .
Definition: Functional.hpp:1826
Scalar1QuaternionBinaryFunctor< T, Q >::Argument1Type Argument1Type
Definition: Functional.hpp:1815
static ResultType applyC3(Argument1Type, const QuaternionExpression< E > &e)
Returns the C3 component of .
Definition: Functional.hpp:1850
static ResultType applyC2(Argument1Type, const QuaternionExpression< E > &e)
Returns the C2 component of .
Definition: Functional.hpp:1838
Scalar1QuaternionBinaryFunctor< T, Q >::ResultType ResultType
Definition: Functional.hpp:1816
Base class for per-component binary functors that take a scalar T (lhs) and a quaternion expression (...
Definition: Functional.hpp:1798
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:1801
const T & Argument1Type
The first (scalar) argument type.
Definition: Functional.hpp:1803
Per-component functor returning (scalar t with the quaternion e subtracted).
Definition: Functional.hpp:1875
Scalar1QuaternionBinaryFunctor< T, Q >::Argument1Type Argument1Type
Definition: Functional.hpp:1877
Scalar1QuaternionBinaryFunctor< T, Q >::ResultType ResultType
Definition: Functional.hpp:1878
static ResultType applyC2(Argument1Type, const QuaternionExpression< E > &e)
Returns the C2 component of .
Definition: Functional.hpp:1900
static ResultType applyC3(Argument1Type, const QuaternionExpression< E > &e)
Returns the C3 component of .
Definition: Functional.hpp:1912
static ResultType applyC1(Argument1Type t, const QuaternionExpression< E > &e)
Returns the C1 component of .
Definition: Functional.hpp:1888
static ResultType applyC4(Argument1Type, const QuaternionExpression< E > &e)
Returns the C4 component of .
Definition: Functional.hpp:1924
Per-component functor returning (scalar t added to the real component of e).
Definition: Functional.hpp:1952
static ResultType applyC4(const QuaternionExpression< E > &e, Argument2Type)
Returns the C4 component of .
Definition: Functional.hpp:2001
static ResultType applyC3(const QuaternionExpression< E > &e, Argument2Type)
Returns the C3 component of .
Definition: Functional.hpp:1989
Scalar2QuaternionBinaryFunctor< Q, T >::Argument2Type Argument2Type
Definition: Functional.hpp:1954
Scalar2QuaternionBinaryFunctor< Q, T >::ResultType ResultType
Definition: Functional.hpp:1955
static ResultType applyC1(const QuaternionExpression< E > &e, Argument2Type t)
Returns the C1 component of .
Definition: Functional.hpp:1965
static ResultType applyC2(const QuaternionExpression< E > &e, Argument2Type)
Returns the C2 component of .
Definition: Functional.hpp:1977
Base class for per-component binary functors that take a quaternion expression (lhs) and a scalar T (...
Definition: Functional.hpp:1937
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:1940
const T & Argument2Type
The second (scalar) argument type.
Definition: Functional.hpp:1942
Per-component functor returning (scalar t subtracted from the real component of e).
Definition: Functional.hpp:2014
static ResultType applyC2(const QuaternionExpression< E > &e, Argument2Type)
Returns the C2 component of .
Definition: Functional.hpp:2039
static ResultType applyC1(const QuaternionExpression< E > &e, Argument2Type t)
Returns the C1 component of .
Definition: Functional.hpp:2027
static ResultType applyC4(const QuaternionExpression< E > &e, Argument2Type)
Returns the C4 component of .
Definition: Functional.hpp:2063
Scalar2QuaternionBinaryFunctor< Q, T >::ResultType ResultType
Definition: Functional.hpp:2017
static ResultType applyC3(const QuaternionExpression< E > &e, Argument2Type)
Returns the C3 component of .
Definition: Functional.hpp:2051
Scalar2QuaternionBinaryFunctor< Q, T >::Argument2Type Argument2Type
Definition: Functional.hpp:2016
Base class for ternary functors that take two grid expressions plus a tolerance scalar and return a b...
Definition: Functional.hpp:2548
bool ResultType
The boolean result type.
Definition: Functional.hpp:2551
const T & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:2553
CommonType< typename G1::ValueType, typename G2::ValueType >::Type ValueType
The cell value type (common type of the two grid cell types).
Definition: Functional.hpp:2557
CommonType< typename G1::SizeType, typename G2::SizeType >::Type SizeType
The unsigned size type (common type of the two grid size types).
Definition: Functional.hpp:2555
Base class for ternary functors that take two matrix expressions plus a tolerance scalar and return a...
Definition: Functional.hpp:948
CommonType< typename M1::ValueType, typename M2::ValueType >::Type ValueType
The element value type (common type of the two matrix element types).
Definition: Functional.hpp:957
CommonType< typename M1::SizeType, typename M2::SizeType >::Type SizeType
The unsigned size type (common type of the two matrix size types).
Definition: Functional.hpp:955
const T & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:953
bool ResultType
The boolean result type.
Definition: Functional.hpp:951
Base class for ternary functors that take two quaternion expressions plus a tolerance scalar and retu...
Definition: Functional.hpp:1515
CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type ValueType
The component value type (common type of the two quaternion element types).
Definition: Functional.hpp:1522
const T & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:1520
bool ResultType
The boolean result type.
Definition: Functional.hpp:1518
Base class for per-component ternary functors that take two quaternion expressions plus a scalar (Mat...
Definition: Functional.hpp:2227
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:2230
const T & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:2232
Base class for ternary functors that take two vectors and a scalar tolerance and return a boolean (Ma...
Definition: Functional.hpp:570
bool ResultType
The boolean result type.
Definition: Functional.hpp:573
const T & Argument3Type
The third (scalar) argument type.
Definition: Functional.hpp:575
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ValueType
The element value type (common type of the two vector element types).
Definition: Functional.hpp:579
CommonType< typename V1::SizeType, typename V2::SizeType >::Type SizeType
The unsigned size type (common type of the two vector size types).
Definition: Functional.hpp:577
Scalar in-place addition functor: apply(t1, t2) performs t1 += t2.
Definition: Functional.hpp:103
static void apply(Argument1Type t1, Argument2Type t2)
Performs t1 += t2.
Definition: Functional.hpp:113
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:106
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:105
Scalar binary addition functor: apply(t1, t2) returns t1 + t2.
Definition: Functional.hpp:344
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:346
static ResultType apply(Argument1Type t1, Argument2Type t2)
Returns t1 + t2.
Definition: Functional.hpp:356
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:347
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:348
Scalar plain-assignment functor: apply(t1, t2) performs t1 = t2.
Definition: Functional.hpp:80
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:83
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:82
static void apply(Argument1Type t1, Argument2Type t2)
Performs t1 = t2.
Definition: Functional.hpp:90
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:70
T1 Argument1Type
The (modifiable) first argument type.
Definition: Functional.hpp:68
Base class for binary scalar functors of the form F::apply(const T1&, const T2&) returning a Math::Co...
Definition: Functional.hpp:327
const T2 & Argument2Type
The second argument type.
Definition: Functional.hpp:332
const T1 & Argument1Type
The first argument type.
Definition: Functional.hpp:330
CommonType< T1, T2 >::Type ResultType
The result type (common type of T1 and T2).
Definition: Functional.hpp:334
Scalar complex-conjugation functor: apply(v) returns (identity for real types).
Definition: Functional.hpp:237
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:240
static ResultType apply(ArgumentType v)
Returns the complex conjugate of v.
Definition: Functional.hpp:248
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:241
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:239
Scalar in-place division functor: apply(t1, t2) performs t1 /= t2.
Definition: Functional.hpp:172
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:174
static void apply(Argument1Type t1, Argument2Type t2)
Performs t1 /= t2.
Definition: Functional.hpp:182
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:175
Scalar binary division functor: apply(t1, t2) returns t1 / t2.
Definition: Functional.hpp:419
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:421
static ResultType apply(Argument1Type t1, Argument2Type t2)
Returns t1 / t2.
Definition: Functional.hpp:431
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:422
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:423
Scalar imaginary-part functor: apply(v) returns (zero for real types).
Definition: Functional.hpp:299
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:303
static ResultType apply(ArgumentType v)
Returns the imaginary part of v.
Definition: Functional.hpp:310
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:301
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:302
Scalar in-place multiplication functor: apply(t1, t2) performs t1 *= t2.
Definition: Functional.hpp:149
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:151
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:152
static void apply(Argument1Type t1, Argument2Type t2)
Performs t1 *= t2.
Definition: Functional.hpp:159
Scalar binary multiplication functor: apply(t1, t2) returns t1 * t2.
Definition: Functional.hpp:394
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:397
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:396
static ResultType apply(Argument1Type t1, Argument2Type t2)
Returns t1 * t2.
Definition: Functional.hpp:406
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:398
Scalar negation functor: apply(v) returns -v.
Definition: Functional.hpp:214
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:216
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:218
static ResultType apply(ArgumentType v)
Returns -v.
Definition: Functional.hpp:225
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:217
Per-component functor returning the scalar/quaternion division (n2 is the precomputed squared norm o...
Definition: Functional.hpp:2339
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:2354
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:2396
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:2368
Scalar13QuaternionTernaryFunctor< T1, Q, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:2341
Scalar13QuaternionTernaryFunctor< T1, Q, T2 >::ResultType ResultType
Definition: Functional.hpp:2343
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:2382
Scalar13QuaternionTernaryFunctor< T1, Q, T2 >::Argument3Type Argument3Type
Definition: Functional.hpp:2342
Base class for unary scalar functors that return the real part of T (Math::ScalarReal,...
Definition: Functional.hpp:260
TypeTraits< T >::RealType ResultType
The real-valued result type derived from ValueType via Math::TypeTraits.
Definition: Functional.hpp:267
const T & ArgumentType
The argument type (a const reference to ValueType).
Definition: Functional.hpp:265
T ValueType
The scalar value type.
Definition: Functional.hpp:263
Scalar real-part functor: apply(v) returns (identity for real types).
Definition: Functional.hpp:276
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:279
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:278
static ResultType apply(ArgumentType v)
Returns the real part of v.
Definition: Functional.hpp:287
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:280
Scalar in-place subtraction functor: apply(t1, t2) performs t1 -= t2.
Definition: Functional.hpp:126
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:129
static void apply(Argument1Type t1, Argument2Type t2)
Performs t1 -= t2.
Definition: Functional.hpp:136
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:128
Scalar binary subtraction functor: apply(t1, t2) returns t1 - t2.
Definition: Functional.hpp:369
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:373
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:372
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:371
static ResultType apply(Argument1Type t1, Argument2Type t2)
Returns t1 - t2.
Definition: Functional.hpp:381
static RealType real(ConstReference t)
Returns the real part of t (identical to t for non-complex scalars).
Definition: TypeTraits.hpp:102
static RealType conj(ConstReference t)
Returns the complex conjugate of t (identical to t for non-complex scalars).
Definition: TypeTraits.hpp:121
static RealType normInf(ConstReference t)
Returns the L∞ norm of t (identical to the absolute value for scalar values).
Definition: TypeTraits.hpp:171
static RealType imag(ConstReference)
Returns the imaginary part (always zero for non-complex scalars).
Definition: TypeTraits.hpp:111
static ValueType sqrt(ConstReference t)
Returns the square root of t.
Definition: TypeTraits.hpp:141
static RealType norm2(ConstReference t)
Returns the L2 (Euclidean) norm of t (identical to the absolute value for scalar values).
Definition: TypeTraits.hpp:161
T RealType
The real-valued type (identical to ValueType for scalar traits).
Definition: TypeTraits.hpp:91
Base class for unary scalar functors of the form F::apply(const T&) returning a T result.
Definition: Functional.hpp:198
T ValueType
The scalar value type.
Definition: Functional.hpp:201
const T & ArgumentType
The argument type (a const reference to ValueType).
Definition: Functional.hpp:203
ValueType ResultType
The result type of apply().
Definition: Functional.hpp:205
Primary traits template for scalar arithmetic value types.
Definition: TypeTraits.hpp:285
Functor returning the cosine of the angle between two vectors (optionally clamped to [-1,...
Definition: Functional.hpp:490
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:502
CommonType< typename VectorInnerProduct< V1, V2 >::ResultType, T >::Type ResultType
Definition: Functional.hpp:492
Base class for binary functors that take two vectors and return a vector (Math::VectorCrossProduct).
Definition: Functional.hpp:628
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ResultType
The element result type (common type of the two vector element types).
Definition: Functional.hpp:631
Base class for binary functors that take two vectors and return a boolean (Math::VectorEquality and s...
Definition: Functional.hpp:520
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ValueType
The element value type (common type of the two vector element types).
Definition: Functional.hpp:527
bool ResultType
The boolean result type.
Definition: Functional.hpp:523
CommonType< typename V1::SizeType, typename V2::SizeType >::Type SizeType
The unsigned size type (common type of the two vector size types).
Definition: Functional.hpp:525
Vector cross-product functor: apply(e1, e2, i) returns the i-th component of the 3-vector cross produ...
Definition: Functional.hpp:641
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:657
VectorScalarBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:643
Functor returning the sum of all elements of a vector expression.
Definition: Functional.hpp:699
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:701
static ResultType apply(const VectorExpression< V > &e)
Returns the sum of all elements of e.
Definition: Functional.hpp:708
Vector equality functor: apply(e1, e2) tests element-wise equality of two vector expressions.
Definition: Functional.hpp:537
VectorBooleanBinaryFunctor< V1, V2 >::ValueType ValueType
Definition: Functional.hpp:540
VectorBooleanBinaryFunctor< V1, V2 >::SizeType SizeType
Definition: Functional.hpp:539
VectorBooleanBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:541
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:549
Vector inner-product functor: apply(e1, e2) returns .
Definition: Functional.hpp:457
VectorScalarBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:459
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2)
Returns the inner product of e1 and e2.
Definition: Functional.hpp:468
Functor returning element i of the vector-matrix product .
Definition: Functional.hpp:1385
MatrixVectorBinaryFunctor< M, V >::ResultType ResultType
Definition: Functional.hpp:1389
MatrixVectorBinaryFunctor< M, V >::SizeType SizeType
Definition: Functional.hpp:1388
static ResultType apply(const VectorExpression< E1 > &e1, const MatrixExpression< E2 > &e2, SizeType i)
Returns element i of the vector-matrix product .
Definition: Functional.hpp:1402
MatrixVectorBinaryFunctor< M, V >::ValueType ValueType
Definition: Functional.hpp:1387
Base class for unary functors that produce a matrix element from a vector expression and (i,...
Definition: Functional.hpp:1213
V::ValueType ResultType
The matrix-entry result type (the vector's element value type).
Definition: Functional.hpp:1216
V::SizeType SizeType
The unsigned size type used by the vector.
Definition: Functional.hpp:1218
Functor returning the L1 norm of a vector expression.
Definition: Functional.hpp:743
static ResultType apply(const VectorExpression< V > &e)
Returns the L1 norm of e.
Definition: Functional.hpp:754
VectorScalarRealUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:746
VectorScalarRealUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:745
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:747
Functor returning the L2 (Euclidean) norm of a vector expression.
Definition: Functional.hpp:773
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:777
VectorScalarRealUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:776
static ResultType apply(const VectorExpression< V > &e)
Returns the L2 norm of e.
Definition: Functional.hpp:784
VectorScalarRealUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:775
Functor returning the index of the vector element with the largest L∞ norm.
Definition: Functional.hpp:856
VectorScalarIndexUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:860
VectorScalarIndexUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:858
VectorScalarIndexUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:859
static ResultType apply(const VectorExpression< V > &e)
Returns the index of the element of e with the largest L∞ norm.
Definition: Functional.hpp:867
Functor returning the L∞ (maximum-magnitude) norm of a vector expression.
Definition: Functional.hpp:806
static ResultType apply(const VectorExpression< V > &e)
Returns the L∞ norm of e.
Definition: Functional.hpp:817
VectorScalarRealUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:808
VectorScalarRealUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:809
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:810
Base class for binary functors that take two vectors and return a scalar (Math::VectorInnerProduct,...
Definition: Functional.hpp:444
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ResultType
The scalar result type (common type of the two vector element types).
Definition: Functional.hpp:447
Base class for unary functors that take a vector and return a vector-element index (Math::VectorNormI...
Definition: Functional.hpp:840
TypeTraits< ValueType >::RealType RealType
The real-valued type derived from ValueType via Math::TypeTraits.
Definition: Functional.hpp:845
V::ValueType ValueType
The vector's element value type.
Definition: Functional.hpp:843
V::SizeType ResultType
The result type (the vector's size type, used for element indices).
Definition: Functional.hpp:847
Base class for unary functors that take a vector and return a real-valued scalar (Math::VectorNorm1,...
Definition: Functional.hpp:727
RealType ResultType
The real-valued result type.
Definition: Functional.hpp:734
TypeTraits< ValueType >::RealType RealType
The real-valued type derived from ValueType via Math::TypeTraits.
Definition: Functional.hpp:732
V::ValueType ValueType
The vector's element value type.
Definition: Functional.hpp:730
Base class for unary functors that take a vector and return a scalar (Math::VectorElementSum).
Definition: Functional.hpp:685
V::ValueType ResultType
The scalar result type (the vector's element value type).
Definition: Functional.hpp:688
V::SizeType SizeType
The unsigned size type used by the vector.
Definition: Functional.hpp:690
Vector tolerance-equality functor: apply(e1, e2, eps) tests element-wise equality within an absolute ...
Definition: Functional.hpp:590
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::ValueType ValueType
Definition: Functional.hpp:593
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::SizeType SizeType
Definition: Functional.hpp:592
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:595
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::ResultType ResultType
Definition: Functional.hpp:594
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:604