Chemical Data Processing Library C++ API - Version 1.2.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 
53  template <typename T1, typename T2>
55  {
56 
57  typedef T1 Argument1Type;
58  typedef const T2& Argument2Type;
59  };
60 
61  template <typename T1, typename T2>
63  {
64 
67 
68  static void apply(Argument1Type t1, Argument2Type t2)
69  {
70  t1 = t2;
71  }
72  };
73 
74  template <typename T1, typename T2>
76  {
77 
80 
81  static void apply(Argument1Type t1, Argument2Type t2)
82  {
83  t1 += t2;
84  }
85  };
86 
87  template <typename T1, typename T2>
89  {
90 
93 
94  static void apply(Argument1Type t1, Argument2Type t2)
95  {
96  t1 -= t2;
97  }
98  };
99 
100  template <typename T1, typename T2>
102  {
103 
106 
107  static void apply(Argument1Type t1, Argument2Type t2)
108  {
109  t1 *= t2;
110  }
111  };
112 
113  template <typename T1, typename T2>
115  {
116 
119 
120  static void apply(Argument1Type t1, Argument2Type t2)
121  {
122  t1 /= t2;
123  }
124  };
125 
126  template <typename T>
128  {
129 
130  typedef T ValueType;
131  typedef const T& ArgumentType;
133  };
134 
135  template <typename T>
137  {
138 
142 
144  {
145  return -v;
146  }
147  };
148 
149  template <typename T>
151  {
152 
156 
158  {
159  return TypeTraits<ValueType>::conj(v);
160  }
161  };
162 
163  template <typename T>
165  {
166 
167  typedef T ValueType;
168  typedef const T& ArgumentType;
170  };
171 
172  template <typename T>
174  {
175 
179 
181  {
182  return TypeTraits<ValueType>::real(v);
183  }
184  };
185 
186  template <typename T>
188  {
189 
193 
195  {
196  return TypeTraits<ValueType>::imag(v);
197  }
198  };
199 
200  template <typename T1, typename T2>
202  {
203 
204  typedef const T1& Argument1Type;
205  typedef const T2& Argument2Type;
207  };
208 
209  template <typename T1, typename T2>
210  struct ScalarAddition : public ScalarBinaryFunctor<T1, T2>
211  {
212 
216 
218  {
219  return (t1 + t2);
220  }
221  };
222 
223  template <typename T1, typename T2>
224  struct ScalarSubtraction : public ScalarBinaryFunctor<T1, T2>
225  {
226 
230 
232  {
233  return (t1 - t2);
234  }
235  };
236 
237  template <typename T1, typename T2>
239  {
240 
244 
246  {
247  return (t1 * t2);
248  }
249  };
250 
251  template <typename T1, typename T2>
252  struct ScalarDivision : public ScalarBinaryFunctor<T1, T2>
253  {
254 
258 
260  {
261  return (t1 / t2);
262  }
263  };
264 
265  template <typename V1, typename V2>
267  {
268 
270  };
271 
272  template <typename V1, typename V2>
274  {
275 
277 
279  {
281 
282  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize()), SizeType(e2().getSize()), Base::SizeError);
283  ResultType res = ResultType();
284 
285  for (SizeType i = 0; i < size; i++)
286  res += e1()(i) * e2()(i);
287 
288  return res;
289  }
290  };
291 
292  template <typename V1, typename V2, typename T>
294  {
295 
297 
298  static ResultType apply(const VectorExpression<V1>& e1, const VectorExpression<V2>& e2, const T& sd, bool clamp)
299  {
301 
302  if (!clamp)
303  return res;
304 
305  return boost::algorithm::clamp(res, ResultType(-1), ResultType(1));
306  }
307  };
308 
309  template <typename V1, typename V2>
311  {
312 
313  typedef bool ResultType;
316  };
317 
318  template <typename V1, typename V2>
320  {
321 
325 
327  {
328  if (SizeType(e1().getSize()) != SizeType(e2().getSize()))
329  return false;
330 
331  for (SizeType i = 0, size = e1().getSize(); i < size; i++)
332  if (ValueType(e1()(i)) != ValueType(e2()(i)))
333  return false;
334 
335  return true;
336  }
337  };
338 
339  template <typename V1, typename V2, typename T>
341  {
342 
343  typedef bool ResultType;
344  typedef const T& Argument3Type;
347  };
348 
349  template <typename V1, typename V2, typename T>
351  {
352 
357 
359  {
360  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
361 
362  if (SizeType(e1().getSize()) != SizeType(e2().getSize()))
363  return false;
364 
365  ComparisonType norm_inf_max(epsilon);
366 
367  for (SizeType i = 0, size = e1().getSize(); i < size; i++)
368  if (ComparisonType(TypeTraits<ValueType>::normInf(e2()(i) - e1()(i))) > norm_inf_max)
369  return false;
370 
371  return true;
372  }
373  };
374 
375  template <typename V1, typename V2>
377  {
378 
380  };
381 
382  template <typename V1, typename V2>
383  struct VectorCrossProduct : public VectorBinaryFunctor<V1, V2>
384  {
385 
387 
388  template <typename E1, typename E2, typename SizeType>
389  static ResultType apply(const VectorExpression<E1>& e1, const VectorExpression<E2>& e2, SizeType i)
390  {
391  CDPL_MATH_CHECK(e1().getSize() == 3, "Invalid vector size", Base::SizeError);
392  CDPL_MATH_CHECK(e2().getSize() == 3, "Invalid vector size", Base::SizeError);
393 
394  switch (i) {
395 
396  case 0:
397  return (e1()(1) * e2()(2) - e1()(2) * e2()(1)); // c1 = a2 * b3 - a3 * b2;
398 
399  case 1:
400  return (e1()(2) * e2()(0) - e1()(0) * e2()(2)); // c2 = a3 * b1 - a1 * b3;
401 
402  case 2:
403  return (e1()(0) * e2()(1) - e1()(1) * e2()(0)); // c3 = a1 * b2 - a2 * b1;
404 
405  default:
406  return ResultType();
407  }
408  }
409  };
410 
411  template <typename V>
413  {
414 
415  typedef typename V::ValueType ResultType;
416  typedef typename V::SizeType SizeType;
417  };
418 
419  template <typename V>
421  {
422 
424 
426  {
427  typedef typename V::SizeType SizeType;
428 
429  ResultType res = ResultType();
430 
431  for (SizeType i = 0, size = e().getSize(); i < size; i++)
432  res += e()(i);
433 
434  return res;
435  }
436  };
437 
438  template <typename V>
440  {
441 
442  typedef typename V::ValueType ValueType;
445  };
446 
447  template <typename V>
449  {
450 
454 
456  {
457  typedef typename V::SizeType SizeType;
458 
459  RealType res = RealType();
460 
461  for (SizeType i = 0, size = e().getSize(); i < size; i++)
462  res += TypeTraits<ValueType>::norm1(e()(i));
463 
464  return res;
465  }
466  };
467 
468  template <typename V>
470  {
471 
475 
477  {
478  typedef typename V::SizeType SizeType;
479 
480  RealType res2 = RealType();
481 
482  for (SizeType i = 0, size = e().getSize(); i < size; i++) {
484 
485  res2 += t * t;
486  }
487 
488  return TypeTraits<RealType>::sqrt(res2);
489  }
490  };
491 
492  template <typename V>
494  {
495 
499 
501  {
502  typedef typename V::SizeType SizeType;
503 
504  RealType res = RealType();
505 
506  for (SizeType i = 0, size = e().getSize(); i < size; i++) {
508 
509  if (t > res)
510  res = t;
511  }
512 
513  return res;
514  }
515  };
516 
517  template <typename V>
519  {
520 
521  typedef typename V::ValueType ValueType;
523  typedef typename V::SizeType ResultType;
524  };
525 
526  template <typename V>
528  {
529 
533 
535  {
536  typedef typename V::SizeType SizeType;
537 
538  RealType norm = RealType();
539  ResultType res = ResultType(0);
540 
541  for (SizeType i = 0, size = e().getSize(); i < size; i++) {
543 
544  if (t > norm) {
545  norm = t;
546  res = ResultType(i);
547  }
548  }
549 
550  return res;
551  }
552  };
553 
554  template <typename M1, typename M2>
556  {
557 
558  typedef bool ResultType;
561  };
562 
563  template <typename M1, typename M2>
565  {
566 
570 
572  {
573  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
574  return false;
575 
576  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
577  return false;
578 
579  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
580  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
581  if (ValueType(e1()(i, j)) != ValueType(e2()(i, j)))
582  return false;
583 
584  return true;
585  }
586  };
587 
588  template <typename M1, typename M2, typename T>
590  {
591 
592  typedef bool ResultType;
593  typedef const T& Argument3Type;
596  };
597 
598  template <typename M1, typename M2, typename T>
600  {
601 
606 
608  {
609  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
610 
611  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
612  return false;
613 
614  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
615  return false;
616 
617  ComparisonType norm_inf_max(epsilon);
618 
619  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
620  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
621  if (ComparisonType(TypeTraits<ValueType>::normInf(e2()(i, j) - e1()(i, j))) > norm_inf_max)
622  return false;
623 
624  return true;
625  }
626  };
627 
628  template <typename M>
630  {
631 
632  typedef typename M::ValueType ResultType;
633  };
634 
635  template <typename M>
637  {
638 
640 
642  {
643  typedef typename M::SizeType SizeType;
644 
645  ResultType res = ResultType();
646  SizeType size1 = e().getSize1();
647  SizeType size2 = e().getSize2();
648 
649  for (SizeType i = 0; i < size1; i++)
650  for (SizeType j = 0; j < size2; j++)
651  res += e()(i, j);
652 
653  return res;
654  }
655  };
656 
657  template <typename M>
659  {
660 
662 
664  {
665  typedef typename M::SizeType SizeType;
666 
667  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(e().getSize1(), e().getSize2(), Base::SizeError);
668  ResultType res = ResultType();
669 
670  for (SizeType i = 0; i < size; i++)
671  res += e()(i, i);
672 
673  return res;
674  }
675  };
676 
677  template <typename M>
679  {
680 
681  typedef typename M::ValueType ValueType;
684  };
685 
686  template <typename M>
688  {
689 
693 
695  {
696  typedef typename M::SizeType SizeType;
697 
698  RealType res = RealType();
699  SizeType size1 = e().getSize1();
700  SizeType size2 = e().getSize2();
701 
702  for (SizeType j = 0; j < size2; j++) {
703  RealType t = RealType();
704 
705  for (SizeType i = 0; i < size1; i++)
706  t += TypeTraits<ValueType>::norm1(e()(i, j));
707 
708  if (t > res)
709  res = t;
710  }
711 
712  return res;
713  }
714  };
715 
716  template <typename M>
718  {
719 
723 
725  {
726  typedef typename M::SizeType SizeType;
727 
728  RealType res2 = RealType();
729  SizeType size1 = e().getSize1();
730  SizeType size2 = e().getSize2();
731 
732  for (SizeType i = 0; i < size1; i++) {
733  for (SizeType j = 0; j < size2; j++) {
734  RealType t = TypeTraits<ValueType>::norm2(e()(i, j));
735 
736  res2 += t * t;
737  }
738  }
739 
740  return TypeTraits<RealType>::sqrt(res2);
741  }
742  };
743 
744  template <typename M>
746  {
747 
751 
753  {
754  typedef typename M::SizeType SizeType;
755 
756  RealType res = RealType();
757  SizeType size1 = e().getSize1();
758  SizeType size2 = e().getSize2();
759 
760  for (SizeType i = 0; i < size1; i++) {
761  RealType t = RealType();
762 
763  for (SizeType j = 0; j < size2; j++)
764  t += TypeTraits<ValueType>::normInf(e()(i, j));
765 
766  if (t > res)
767  res = t;
768  }
769 
770  return res;
771  }
772  };
773 
774  template <typename V>
776  {
777 
778  typedef typename V::ValueType ResultType;
779  typedef typename V::SizeType SizeType;
780  };
781 
782  template <typename V>
784  {
785 
788 
789  template <typename E>
791  {
792  if (i == j)
793  return e()(i);
794 
795  return ResultType();
796  }
797  };
798 
799  template <typename V>
801  {
802 
805 
806  template <typename E>
808  {
809  CDPL_MATH_CHECK(e().getSize() == 3, "Invalid vector size", Base::SizeError);
810 
811  // | 0 -a3 a2 |
812  // cross([a1, a2, a3]) = | a3 0 -a1 |
813  // | -a2 a1 0 |
814  switch (i) {
815 
816  case 0:
817  switch (j) {
818 
819  case 1:
820  return -e()(2);
821 
822  case 2:
823  return e()(1);
824 
825  default:
826  return ResultType();
827  }
828 
829  case 1:
830  switch (j) {
831 
832  case 0:
833  return e()(2);
834 
835  case 2:
836  return -e()(0);
837 
838  default:
839  return ResultType();
840  }
841 
842  case 2:
843  switch (j) {
844 
845  case 0:
846  return -e()(1);
847 
848  case 1:
849  return e()(0);
850 
851  default:
852  return ResultType();
853  }
854 
855  default:
856  return ResultType();
857  }
858  }
859  };
860 
861  template <typename M, typename V>
863  {
864 
868  };
869 
870  template <typename M, typename V>
872  {
873 
877 
878  template <typename E1, typename E2>
880  {
881  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize2()), SizeType(e2().getSize()), Base::SizeError);
882  ResultType res = ResultType();
883 
884  for (SizeType j = 0; j < size; j++)
885  res += e1()(i, j) * e2()(j);
886 
887  return res;
888  }
889  };
890 
891  template <typename V, typename M>
893  {
894 
898 
899  template <typename E1, typename E2>
901  {
902  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize()), SizeType(e2().getSize1()), Base::SizeError);
903  ResultType res = ResultType();
904 
905  for (SizeType j = 0; j < size; j++)
906  res += e1()(j) * e2()(j, i);
907 
908  return res;
909  }
910  };
911 
912  template <typename M1, typename M2>
914  {
915 
919  };
920 
921  template <typename M1, typename M2>
922  struct MatrixProduct : public MatrixBinaryFunctor<M1, M2>
923  {
924 
928 
929  template <typename E1, typename E2>
931  {
932  SizeType size = CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(e1().getSize2()), SizeType(e2().getSize1()), Base::SizeError);
933  ResultType res = ResultType();
934 
935  for (SizeType k = 0; k < size; k++)
936  res += e1()(i, k) * e2()(k, j);
937 
938  return res;
939  }
940  };
941 
942  template <typename Q1, typename Q2>
944  {
945 
946  typedef bool ResultType;
948  };
949 
950  template <typename Q1, typename Q2>
952  {
953 
956 
958  {
959  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()));
960  }
961  };
962 
963  template <typename Q1, typename Q2, typename T>
965  {
966 
967  typedef bool ResultType;
968  typedef const T& Argument3Type;
970  };
971 
972  template <typename Q1, typename Q2, typename T>
974  {
975 
979 
981  {
982  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
983 
984  ComparisonType norm_inf_max(epsilon);
985 
986  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);
987  }
988  };
989 
990  template <typename Q>
992  {
993 
994  typedef typename Q::ValueType ResultType;
995  };
996 
997  template <typename Q>
999  {
1000 
1002 
1004  {
1005  return (e().getC1() + e().getC2() + e().getC3() + e().getC4());
1006  }
1007  };
1008 
1009  template <typename Q>
1011  {
1012 
1013  typedef typename Q::ValueType ValueType;
1016  };
1017 
1018  template <typename Q>
1020  {
1021 
1025 
1027  {
1028  RealType t = e().getC1() * e().getC1() +
1029  e().getC2() * e().getC2() +
1030  e().getC3() * e().getC3() +
1031  e().getC4() * e().getC4();
1032 
1033  return TypeTraits<RealType>::sqrt(t);
1034  }
1035  };
1036 
1037  template <typename Q>
1039  {
1040 
1044 
1046  {
1047  RealType t = e().getC1() * e().getC1() +
1048  e().getC2() * e().getC2() +
1049  e().getC3() * e().getC3() +
1050  e().getC4() * e().getC4();
1051 
1052  return t;
1053  }
1054  };
1055 
1056  template <typename Q>
1058  {
1059 
1060  typedef typename Q::ValueType ResultType;
1061  };
1062 
1063  template <typename Q>
1065  {
1066 
1068 
1069  template <typename E>
1071  {
1072  return ResultType();
1073  }
1074 
1075  template <typename E>
1077  {
1078  return e().getC2();
1079  }
1080 
1081  template <typename E>
1083  {
1084  return e().getC3();
1085  }
1086 
1087  template <typename E>
1089  {
1090  return e().getC4();
1091  }
1092  };
1093 
1094  template <typename Q>
1096  {
1097 
1099 
1100  template <typename E>
1102  {
1103  return e().getC1();
1104  }
1105 
1106  template <typename E>
1108  {
1109  return -e().getC2();
1110  }
1111 
1112  template <typename E>
1114  {
1115  return -e().getC3();
1116  }
1117 
1118  template <typename E>
1120  {
1121  return -e().getC4();
1122  }
1123  };
1124 
1125  template <typename T, typename Q>
1127  {
1128 
1130  typedef const T& Argument1Type;
1131  };
1132 
1133  template <typename T, typename Q>
1135  {
1136 
1139 
1140  template <typename E>
1142  {
1143  return (t + e().getC1());
1144  }
1145 
1146  template <typename E>
1148  {
1149  return e().getC2();
1150  }
1151 
1152  template <typename E>
1154  {
1155  return e().getC3();
1156  }
1157 
1158  template <typename E>
1160  {
1161  return e().getC4();
1162  }
1163  };
1164 
1165  template <typename T, typename Q>
1167  {
1168 
1171 
1172  template <typename E>
1174  {
1175  return (t - e().getC1());
1176  }
1177 
1178  template <typename E>
1180  {
1181  return -e().getC2();
1182  }
1183 
1184  template <typename E>
1186  {
1187  return -e().getC3();
1188  }
1189 
1190  template <typename E>
1192  {
1193  return -e().getC4();
1194  }
1195  };
1196 
1197  template <typename Q, typename T>
1199  {
1200 
1202  typedef const T& Argument2Type;
1203  };
1204 
1205  template <typename Q, typename T>
1207  {
1208 
1211 
1212  template <typename E>
1214  {
1215  return (e().getC1() + t);
1216  }
1217 
1218  template <typename E>
1220  {
1221  return e().getC2();
1222  }
1223 
1224  template <typename E>
1226  {
1227  return e().getC3();
1228  }
1229 
1230  template <typename E>
1232  {
1233  return e().getC4();
1234  }
1235  };
1236 
1237  template <typename Q, typename T>
1239  {
1240 
1243 
1244  template <typename E>
1246  {
1247  return (e().getC1() - t);
1248  }
1249 
1250  template <typename E>
1252  {
1253  return e().getC2();
1254  }
1255 
1256  template <typename E>
1258  {
1259  return e().getC3();
1260  }
1261 
1262  template <typename E>
1264  {
1265  return e().getC4();
1266  }
1267  };
1268 
1269  template <typename Q, typename T>
1271  {
1272 
1275 
1276  template <typename E>
1278  {
1279  return (e().getC1() / n2);
1280  }
1281 
1282  template <typename E>
1284  {
1285  return (-e().getC2() / n2);
1286  }
1287 
1288  template <typename E>
1290  {
1291  return (-e().getC3() / n2);
1292  }
1293 
1294  template <typename E>
1296  {
1297  return (-e().getC4() / n2);
1298  }
1299  };
1300 
1301  template <typename Q1, typename Q2>
1303  {
1304 
1306  };
1307 
1308  template <typename Q1, typename Q2>
1310  {
1311 
1313 
1314  template <typename E1, typename E2>
1316  {
1317  // a = a1 * a2 - b1 * b2 - c1 * c2 - d1 * d2
1318  return (e1().getC1() * e2().getC1() - e1().getC2() * e2().getC2() - e1().getC3() * e2().getC3() - e1().getC4() * e2().getC4());
1319  }
1320 
1321  template <typename E1, typename E2>
1323  {
1324  // b = a1 * b2 + b1 * a2 + c1 * d2 - d1 * c2
1325  return (e1().getC1() * e2().getC2() + e1().getC2() * e2().getC1() + e1().getC3() * e2().getC4() - e1().getC4() * e2().getC3());
1326  }
1327 
1328  template <typename E1, typename E2>
1330  {
1331  // c = a1 * c2 - b1 * d2 + c1 * a2 + d1 * b2
1332  return (e1().getC1() * e2().getC3() - e1().getC2() * e2().getC4() + e1().getC3() * e2().getC1() + e1().getC4() * e2().getC2());
1333  }
1334 
1335  template <typename E1, typename E2>
1337  {
1338  // d = a1 * d2 + b1 * c2 - c1 * b2 + d1 * a2
1339  return (e1().getC1() * e2().getC4() + e1().getC2() * e2().getC3() - e1().getC3() * e2().getC2() + e1().getC4() * e2().getC1());
1340  }
1341  };
1342 
1343  template <typename Q1, typename Q2, typename T>
1345  {
1346 
1348  typedef const T& Argument3Type;
1349  };
1350 
1351  template <typename Q1, typename Q2, typename T>
1353  {
1354 
1357 
1358  template <typename E1, typename E2>
1360  {
1361  // a = (a1 * a2 + b1 * b2 + c1 * c2 + d1 * d2) / n2
1362  return ((e1().getC1() * e2().getC1() + e1().getC2() * e2().getC2() + e1().getC3() * e2().getC3() + e1().getC4() * e2().getC4()) / n2);
1363  }
1364 
1365  template <typename E1, typename E2>
1367  {
1368  // b = (-a1 * b2 + b1 * a2 - c1 * d2 + d1 * c2) / n2
1369  return ((-e1().getC1() * e2().getC2() + e1().getC2() * e2().getC1() - e1().getC3() * e2().getC4() + e1().getC4() * e2().getC3()) / n2);
1370  }
1371 
1372  template <typename E1, typename E2>
1374  {
1375  // c = (-a1 * c2 + b1 * d2 + c1 * a2 - d1 * b2) / n2
1376  return ((-e1().getC1() * e2().getC3() + e1().getC2() * e2().getC4() + e1().getC3() * e2().getC1() - e1().getC4() * e2().getC2()) / n2);
1377  }
1378 
1379  template <typename E1, typename E2>
1381  {
1382  // d = (-a1 * d2 - b1 * c2 + c1 * b2 + d1 * a2) / n2
1383  return ((-e1().getC1() * e2().getC4() - e1().getC2() * e2().getC3() + e1().getC3() * e2().getC2() + e1().getC4() * e2().getC1()) / n2);
1384  }
1385  };
1386 
1387  template <typename T1, typename Q, typename T2>
1389  {
1390 
1392  typedef const T1& Argument1Type;
1393  typedef const T2& Argument3Type;
1394  };
1395 
1396  template <typename T1, typename Q, typename T2>
1398  {
1399 
1403 
1404  template <typename E>
1406  {
1407  return (t * e().getC1() / n2);
1408  }
1409 
1410  template <typename E>
1412  {
1413  return (t * -e().getC2() / n2);
1414  }
1415 
1416  template <typename E>
1418  {
1419  return (t * -e().getC3() / n2);
1420  }
1421 
1422  template <typename E>
1424  {
1425  return (t * -e().getC4() / n2);
1426  }
1427  };
1428 
1429  template <typename Q, typename V>
1431  {
1432 
1434  typedef typename V::SizeType SizeType;
1436  };
1437 
1438  template <typename Q, typename V>
1440  {
1441 
1445 
1446  template <typename E1, typename E2>
1448  {
1449  CDPL_MATH_CHECK(e2().getSize() >= 3, "Invalid vector size", Base::SizeError);
1450 
1451  switch (i) {
1452 
1453  case 0: {
1454  // vr1 = (a2 + b2 - c2 - d2) * v1 + (2bc - 2ad) * v2 + (2bd + 2ac) * v3
1455  ValueType t1 = e1().getC1() * e1().getC1() + e1().getC2() * e1().getC2() - e1().getC3() * e1().getC3() - e1().getC4() * e1().getC4();
1456  ValueType t2 = ValueType(2) * (e1().getC2() * e1().getC3() - e1().getC1() * e1().getC4());
1457  ValueType t3 = ValueType(2) * (e1().getC2() * e1().getC4() + e1().getC1() * e1().getC3());
1458 
1459  return (t1 * e2()(0) + t2 * e2()(1) + t3 * e2()(2));
1460  }
1461 
1462  case 1: {
1463  // vr2 = (2bc + 2ad) * v1 + (a2 - b2 + c2 - d2) * v2 + (2cd - 2ab) * v3
1464  ValueType t1 = ValueType(2) * (e1().getC2() * e1().getC3() + e1().getC1() * e1().getC4());
1465  ValueType t2 = e1().getC1() * e1().getC1() - e1().getC2() * e1().getC2() + e1().getC3() * e1().getC3() - e1().getC4() * e1().getC4();
1466  ValueType t3 = ValueType(2) * (e1().getC3() * e1().getC4() - e1().getC1() * e1().getC2());
1467 
1468  return (t1 * e2()(0) + t2 * e2()(1) + t3 * e2()(2));
1469  }
1470 
1471  case 2: {
1472  // vr3 = (2bd - 2ac) * v1 + (2cd + 2ab) * v2 + (a2 - b2 - c2 + d2) * v3
1473  ValueType t1 = ValueType(2) * (e1().getC2() * e1().getC4() - e1().getC1() * e1().getC3());
1474  ValueType t2 = ValueType(2) * (e1().getC3() * e1().getC4() + e1().getC1() * e1().getC2());
1475  ValueType t3 = e1().getC1() * e1().getC1() - e1().getC2() * e1().getC2() - e1().getC3() * e1().getC3() + e1().getC4() * e1().getC4();
1476 
1477  return (t1 * e2()(0) + t2 * e2()(1) + t3 * e2()(2));
1478  }
1479 
1480  default:
1481  return ResultType();
1482  }
1483  }
1484  };
1485 
1486  template <typename G1, typename G2>
1488  {
1489 
1490  typedef bool ResultType;
1493  };
1494 
1495  template <typename G1, typename G2>
1496  struct GridEquality : public GridBooleanBinaryFunctor<G1, G2>
1497  {
1498 
1502 
1504  {
1505  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
1506  return false;
1507 
1508  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
1509  return false;
1510 
1511  if (SizeType(e1().getSize3()) != SizeType(e2().getSize3()))
1512  return false;
1513 
1514  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
1515  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
1516  for (SizeType k = 0, size3 = e1().getSize3(); k < size3; k++)
1517  if (ValueType(e1()(i, j, k)) != ValueType(e2()(i, j, k)))
1518  return false;
1519 
1520  return true;
1521  }
1522  };
1523 
1524  template <typename G1, typename G2, typename T>
1526  {
1527 
1528  typedef bool ResultType;
1529  typedef const T& Argument3Type;
1532  };
1533 
1534  template <typename G1, typename G2, typename T>
1536  {
1537 
1542 
1544  {
1545  typedef typename CommonType<typename TypeTraits<ValueType>::RealType, T>::Type ComparisonType;
1546 
1547  if (SizeType(e1().getSize1()) != SizeType(e2().getSize1()))
1548  return false;
1549 
1550  if (SizeType(e1().getSize2()) != SizeType(e2().getSize2()))
1551  return false;
1552 
1553  if (SizeType(e1().getSize3()) != SizeType(e2().getSize3()))
1554  return false;
1555 
1556  ComparisonType norm_inf_max(epsilon);
1557 
1558  for (SizeType i = 0, size1 = e1().getSize1(); i < size1; i++)
1559  for (SizeType j = 0, size2 = e1().getSize2(); j < size2; j++)
1560  for (SizeType k = 0, size3 = e1().getSize3(); k < size3; k++)
1561  if (ComparisonType(TypeTraits<ValueType>::normInf(e2()(i, j, k) - e1()(i, j, k))) > norm_inf_max)
1562  return false;
1563 
1564  return true;
1565  }
1566  };
1567 
1568  template <typename M>
1570  {
1571 
1572  typedef typename M::ValueType ResultType;
1573  };
1574 
1575  template <typename G>
1577  {
1578 
1580 
1582  {
1583  typedef typename G::SizeType SizeType;
1584 
1585  ResultType res = ResultType();
1586  SizeType size1 = e().getSize1();
1587  SizeType size2 = e().getSize2();
1588  SizeType size3 = e().getSize3();
1589 
1590  for (SizeType i = 0; i < size1; i++)
1591  for (SizeType j = 0; j < size2; j++)
1592  for (SizeType k = 0; k < size3; k++)
1593  res += e()(i, j, k);
1594 
1595  return res;
1596  }
1597  };
1598  } // namespace Math
1599 } // namespace CDPL
1600 
1601 #endif // CDPL_MATH_FUNCTIONAL_HPP
Definition of exception classes.
Definition of various preprocessor macros for error checking.
#define CDPL_MATH_CHECK(expr, msg, e)
Definition: Check.hpp:36
#define CDPL_MATH_CHECK_SIZE_EQUALITY(size1, size2, e)
Definition: Check.hpp:62
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
Definition: Expression.hpp:120
Definition: Expression.hpp:76
Definition: Expression.hpp:98
Definition: Expression.hpp:54
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
QuaternionNorm< E >::ResultType norm(const QuaternionExpression< E > &e)
Definition: QuaternionExpression.hpp:797
The namespace of the Chemical Data Processing Library.
Definition: CommonType.hpp:41
std::common_type< T1, T2 >::type Type
Definition: CommonType.hpp:43
Definition: Functional.hpp:801
VectorScalarUnaryFunctor< V >::SizeType SizeType
Definition: Functional.hpp:804
static ResultType apply(const VectorExpression< E > &e, SizeType i, SizeType j)
Definition: Functional.hpp:807
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:803
Definition: Functional.hpp:784
VectorScalarUnaryFunctor< V >::SizeType SizeType
Definition: Functional.hpp:787
static ResultType apply(const VectorExpression< E > &e, SizeType i, SizeType j)
Definition: Functional.hpp:790
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:786
Definition: Functional.hpp:1488
CommonType< typename G1::SizeType, typename G2::SizeType >::Type SizeType
Definition: Functional.hpp:1491
bool ResultType
Definition: Functional.hpp:1490
CommonType< typename G1::ValueType, typename G2::ValueType >::Type ValueType
Definition: Functional.hpp:1492
Definition: Functional.hpp:1577
GridScalarUnaryFunctor< G >::ResultType ResultType
Definition: Functional.hpp:1579
static ResultType apply(const GridExpression< G > &e)
Definition: Functional.hpp:1581
Definition: Functional.hpp:1497
static ResultType apply(const GridExpression< G1 > &e1, const GridExpression< G2 > &e2)
Definition: Functional.hpp:1503
GridBooleanBinaryFunctor< G1, G2 >::ResultType ResultType
Definition: Functional.hpp:1501
GridBooleanBinaryFunctor< G1, G2 >::SizeType SizeType
Definition: Functional.hpp:1499
GridBooleanBinaryFunctor< G1, G2 >::ValueType ValueType
Definition: Functional.hpp:1500
Definition: Functional.hpp:1570
M::ValueType ResultType
Definition: Functional.hpp:1572
Definition: Functional.hpp:1536
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::ValueType ValueType
Definition: Functional.hpp:1539
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::ResultType ResultType
Definition: Functional.hpp:1540
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::SizeType SizeType
Definition: Functional.hpp:1538
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:1541
static ResultType apply(const GridExpression< G1 > &e1, const GridExpression< G2 > &e2, Argument3Type epsilon)
Definition: Functional.hpp:1543
Definition: Functional.hpp:914
ValueType ResultType
Definition: Functional.hpp:918
CommonType< typename M1::ValueType, typename M2::ValueType >::Type ValueType
Definition: Functional.hpp:916
CommonType< typename M1::SizeType, typename M2::SizeType >::Type SizeType
Definition: Functional.hpp:917
Definition: Functional.hpp:556
CommonType< typename M1::SizeType, typename M2::SizeType >::Type SizeType
Definition: Functional.hpp:559
CommonType< typename M1::ValueType, typename M2::ValueType >::Type ValueType
Definition: Functional.hpp:560
bool ResultType
Definition: Functional.hpp:558
Definition: Functional.hpp:637
MatrixScalarUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:639
static ResultType apply(const MatrixExpression< M > &e)
Definition: Functional.hpp:641
Definition: Functional.hpp:565
MatrixBooleanBinaryFunctor< M1, M2 >::SizeType SizeType
Definition: Functional.hpp:567
MatrixBooleanBinaryFunctor< M1, M2 >::ResultType ResultType
Definition: Functional.hpp:569
static ResultType apply(const MatrixExpression< M1 > &e1, const MatrixExpression< M2 > &e2)
Definition: Functional.hpp:571
MatrixBooleanBinaryFunctor< M1, M2 >::ValueType ValueType
Definition: Functional.hpp:568
Definition: Functional.hpp:688
MatrixScalarRealUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:692
MatrixScalarRealUnaryFunctor< M >::RealType RealType
Definition: Functional.hpp:691
MatrixScalarRealUnaryFunctor< M >::ValueType ValueType
Definition: Functional.hpp:690
static ResultType apply(const MatrixExpression< M > &e)
Definition: Functional.hpp:694
Definition: Functional.hpp:718
static ResultType apply(const MatrixExpression< M > &e)
Definition: Functional.hpp:724
MatrixScalarRealUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:722
MatrixScalarRealUnaryFunctor< M >::RealType RealType
Definition: Functional.hpp:721
MatrixScalarRealUnaryFunctor< M >::ValueType ValueType
Definition: Functional.hpp:720
Definition: Functional.hpp:746
static ResultType apply(const MatrixExpression< M > &e)
Definition: Functional.hpp:752
MatrixScalarRealUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:750
MatrixScalarRealUnaryFunctor< M >::ValueType ValueType
Definition: Functional.hpp:748
MatrixScalarRealUnaryFunctor< M >::RealType RealType
Definition: Functional.hpp:749
Definition: Functional.hpp:923
MatrixVectorBinaryFunctor< M1, M2 >::ValueType ValueType
Definition: Functional.hpp:925
MatrixVectorBinaryFunctor< M1, M2 >::SizeType SizeType
Definition: Functional.hpp:926
MatrixVectorBinaryFunctor< M1, M2 >::ResultType ResultType
Definition: Functional.hpp:927
static ResultType apply(const MatrixExpression< E1 > &e1, const MatrixExpression< E2 > &e2, SizeType i, SizeType j)
Definition: Functional.hpp:930
Definition: Functional.hpp:679
M::ValueType ValueType
Definition: Functional.hpp:681
RealType ResultType
Definition: Functional.hpp:683
TypeTraits< ValueType >::RealType RealType
Definition: Functional.hpp:682
Definition: Functional.hpp:630
M::ValueType ResultType
Definition: Functional.hpp:632
Definition: Functional.hpp:600
static ResultType apply(const MatrixExpression< M1 > &e1, const MatrixExpression< M2 > &e2, Argument3Type epsilon)
Definition: Functional.hpp:607
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::ValueType ValueType
Definition: Functional.hpp:603
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:605
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::ResultType ResultType
Definition: Functional.hpp:604
Scalar3MatrixBooleanTernaryFunctor< M1, M2, T >::SizeType SizeType
Definition: Functional.hpp:602
Definition: Functional.hpp:659
MatrixScalarUnaryFunctor< M >::ResultType ResultType
Definition: Functional.hpp:661
static ResultType apply(const MatrixExpression< M > &e)
Definition: Functional.hpp:663
Definition: Functional.hpp:863
ValueType ResultType
Definition: Functional.hpp:867
CommonType< typename M::ValueType, typename V::ValueType >::Type ValueType
Definition: Functional.hpp:865
CommonType< typename M::SizeType, typename V::SizeType >::Type SizeType
Definition: Functional.hpp:866
Definition: Functional.hpp:872
MatrixVectorBinaryFunctor< M, V >::ValueType ValueType
Definition: Functional.hpp:874
MatrixVectorBinaryFunctor< M, V >::ResultType ResultType
Definition: Functional.hpp:876
MatrixVectorBinaryFunctor< M, V >::SizeType SizeType
Definition: Functional.hpp:875
static ResultType apply(const MatrixExpression< E1 > &e1, const VectorExpression< E2 > &e2, SizeType i)
Definition: Functional.hpp:879
Definition: Functional.hpp:1303
CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type ResultType
Definition: Functional.hpp:1305
Definition: Functional.hpp:944
CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type ValueType
Definition: Functional.hpp:947
bool ResultType
Definition: Functional.hpp:946
Definition: Functional.hpp:1096
static ResultType applyC4(const QuaternionExpression< E > &e)
Definition: Functional.hpp:1119
static ResultType applyC2(const QuaternionExpression< E > &e)
Definition: Functional.hpp:1107
static ResultType applyC3(const QuaternionExpression< E > &e)
Definition: Functional.hpp:1113
static ResultType applyC1(const QuaternionExpression< E > &e)
Definition: Functional.hpp:1101
QuaternionUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1098
Definition: Functional.hpp:1353
static ResultType applyC3(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Definition: Functional.hpp:1373
static ResultType applyC1(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Definition: Functional.hpp:1359
Scalar3QuaternionTernaryFunctor< Q1, Q2, T >::ResultType ResultType
Definition: Functional.hpp:1356
static ResultType applyC4(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Definition: Functional.hpp:1380
static ResultType applyC2(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2, Argument3Type n2)
Definition: Functional.hpp:1366
Scalar3QuaternionTernaryFunctor< Q1, Q2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:1355
Definition: Functional.hpp:999
QuaternionScalarUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1001
static ResultType apply(const QuaternionExpression< Q > &e)
Definition: Functional.hpp:1003
Definition: Functional.hpp:952
static ResultType apply(const QuaternionExpression< Q1 > &e1, const QuaternionExpression< Q2 > &e2)
Definition: Functional.hpp:957
QuaternionBooleanBinaryFunctor< Q1, Q2 >::ResultType ResultType
Definition: Functional.hpp:955
QuaternionBooleanBinaryFunctor< Q1, Q2 >::ValueType ValueType
Definition: Functional.hpp:954
Definition: Functional.hpp:1271
static ResultType applyC3(const QuaternionExpression< E > &e, Argument2Type n2)
Definition: Functional.hpp:1289
Scalar2QuaternionBinaryFunctor< Q, T >::ResultType ResultType
Definition: Functional.hpp:1274
static ResultType applyC1(const QuaternionExpression< E > &e, Argument2Type n2)
Definition: Functional.hpp:1277
Scalar2QuaternionBinaryFunctor< Q, T >::Argument2Type Argument2Type
Definition: Functional.hpp:1273
static ResultType applyC2(const QuaternionExpression< E > &e, Argument2Type n2)
Definition: Functional.hpp:1283
static ResultType applyC4(const QuaternionExpression< E > &e, Argument2Type n2)
Definition: Functional.hpp:1295
Definition: Functional.hpp:1039
QuaternionScalarRealUnaryFunctor< Q >::RealType RealType
Definition: Functional.hpp:1042
static ResultType apply(const QuaternionExpression< Q > &e)
Definition: Functional.hpp:1045
QuaternionScalarRealUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1043
QuaternionScalarRealUnaryFunctor< Q >::ValueType ValueType
Definition: Functional.hpp:1041
Definition: Functional.hpp:1020
QuaternionScalarRealUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1024
static ResultType apply(const QuaternionExpression< Q > &e)
Definition: Functional.hpp:1026
QuaternionScalarRealUnaryFunctor< Q >::ValueType ValueType
Definition: Functional.hpp:1022
QuaternionScalarRealUnaryFunctor< Q >::RealType RealType
Definition: Functional.hpp:1023
Definition: Functional.hpp:1310
QuaternionBinaryFunctor< Q1, Q2 >::ResultType ResultType
Definition: Functional.hpp:1312
static ResultType applyC3(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Definition: Functional.hpp:1329
static ResultType applyC2(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Definition: Functional.hpp:1322
static ResultType applyC4(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Definition: Functional.hpp:1336
static ResultType applyC1(const QuaternionExpression< E1 > &e1, const QuaternionExpression< E2 > &e2)
Definition: Functional.hpp:1315
Definition: Functional.hpp:1011
RealType ResultType
Definition: Functional.hpp:1015
Q::ValueType ValueType
Definition: Functional.hpp:1013
ValueType RealType
Definition: Functional.hpp:1014
Definition: Functional.hpp:992
Q::ValueType ResultType
Definition: Functional.hpp:994
Definition: Functional.hpp:974
Scalar3QuaternionBooleanTernaryFunctor< Q1, Q2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:978
Scalar3QuaternionBooleanTernaryFunctor< Q1, Q2, T >::ValueType ValueType
Definition: Functional.hpp:976
Scalar3QuaternionBooleanTernaryFunctor< Q1, Q2, T >::ResultType ResultType
Definition: Functional.hpp:977
static ResultType apply(const QuaternionExpression< Q1 > &e1, const QuaternionExpression< Q2 > &e2, Argument3Type epsilon)
Definition: Functional.hpp:980
Definition: Functional.hpp:1058
Q::ValueType ResultType
Definition: Functional.hpp:1060
Definition: Functional.hpp:1065
QuaternionUnaryFunctor< Q >::ResultType ResultType
Definition: Functional.hpp:1067
static ResultType applyC1(const QuaternionExpression< E > &e)
Definition: Functional.hpp:1070
static ResultType applyC2(const QuaternionExpression< E > &e)
Definition: Functional.hpp:1076
static ResultType applyC3(const QuaternionExpression< E > &e)
Definition: Functional.hpp:1082
static ResultType applyC4(const QuaternionExpression< E > &e)
Definition: Functional.hpp:1088
Definition: Functional.hpp:1431
ValueType ResultType
Definition: Functional.hpp:1435
V::SizeType SizeType
Definition: Functional.hpp:1434
CommonType< typename Q::ValueType, typename V::ValueType >::Type ValueType
Definition: Functional.hpp:1433
Definition: Functional.hpp:1440
QuaternionVectorBinaryFunctor< Q, V >::SizeType SizeType
Definition: Functional.hpp:1443
QuaternionVectorBinaryFunctor< Q, V >::ResultType ResultType
Definition: Functional.hpp:1444
QuaternionVectorBinaryFunctor< Q, V >::ValueType ValueType
Definition: Functional.hpp:1442
static ResultType apply(const QuaternionExpression< E1 > &e1, const VectorExpression< E2 > &e2, SizeType i)
Definition: Functional.hpp:1447
Definition: Functional.hpp:1389
const T1 & Argument1Type
Definition: Functional.hpp:1392
const T2 & Argument3Type
Definition: Functional.hpp:1393
CommonType< typename CommonType< T1, typename Q::ValueType >::Type, T2 >::Type ResultType
Definition: Functional.hpp:1391
Definition: Functional.hpp:1135
static ResultType applyC4(Argument1Type, const QuaternionExpression< E > &e)
Definition: Functional.hpp:1159
static ResultType applyC1(Argument1Type t, const QuaternionExpression< E > &e)
Definition: Functional.hpp:1141
Scalar1QuaternionBinaryFunctor< T, Q >::Argument1Type Argument1Type
Definition: Functional.hpp:1137
static ResultType applyC3(Argument1Type, const QuaternionExpression< E > &e)
Definition: Functional.hpp:1153
static ResultType applyC2(Argument1Type, const QuaternionExpression< E > &e)
Definition: Functional.hpp:1147
Scalar1QuaternionBinaryFunctor< T, Q >::ResultType ResultType
Definition: Functional.hpp:1138
Definition: Functional.hpp:1127
CommonType< T, typename Q::ValueType >::Type ResultType
Definition: Functional.hpp:1129
const T & Argument1Type
Definition: Functional.hpp:1130
Definition: Functional.hpp:1167
Scalar1QuaternionBinaryFunctor< T, Q >::Argument1Type Argument1Type
Definition: Functional.hpp:1169
Scalar1QuaternionBinaryFunctor< T, Q >::ResultType ResultType
Definition: Functional.hpp:1170
static ResultType applyC2(Argument1Type, const QuaternionExpression< E > &e)
Definition: Functional.hpp:1179
static ResultType applyC3(Argument1Type, const QuaternionExpression< E > &e)
Definition: Functional.hpp:1185
static ResultType applyC1(Argument1Type t, const QuaternionExpression< E > &e)
Definition: Functional.hpp:1173
static ResultType applyC4(Argument1Type, const QuaternionExpression< E > &e)
Definition: Functional.hpp:1191
Definition: Functional.hpp:1207
static ResultType applyC4(const QuaternionExpression< E > &e, Argument2Type)
Definition: Functional.hpp:1231
static ResultType applyC3(const QuaternionExpression< E > &e, Argument2Type)
Definition: Functional.hpp:1225
Scalar2QuaternionBinaryFunctor< Q, T >::Argument2Type Argument2Type
Definition: Functional.hpp:1209
Scalar2QuaternionBinaryFunctor< Q, T >::ResultType ResultType
Definition: Functional.hpp:1210
static ResultType applyC1(const QuaternionExpression< E > &e, Argument2Type t)
Definition: Functional.hpp:1213
static ResultType applyC2(const QuaternionExpression< E > &e, Argument2Type)
Definition: Functional.hpp:1219
Definition: Functional.hpp:1199
CommonType< typename Q::ValueType, T >::Type ResultType
Definition: Functional.hpp:1201
const T & Argument2Type
Definition: Functional.hpp:1202
Definition: Functional.hpp:1239
static ResultType applyC2(const QuaternionExpression< E > &e, Argument2Type)
Definition: Functional.hpp:1251
static ResultType applyC1(const QuaternionExpression< E > &e, Argument2Type t)
Definition: Functional.hpp:1245
static ResultType applyC4(const QuaternionExpression< E > &e, Argument2Type)
Definition: Functional.hpp:1263
Scalar2QuaternionBinaryFunctor< Q, T >::ResultType ResultType
Definition: Functional.hpp:1242
static ResultType applyC3(const QuaternionExpression< E > &e, Argument2Type)
Definition: Functional.hpp:1257
Scalar2QuaternionBinaryFunctor< Q, T >::Argument2Type Argument2Type
Definition: Functional.hpp:1241
Definition: Functional.hpp:1526
bool ResultType
Definition: Functional.hpp:1528
const T & Argument3Type
Definition: Functional.hpp:1529
CommonType< typename G1::ValueType, typename G2::ValueType >::Type ValueType
Definition: Functional.hpp:1531
CommonType< typename G1::SizeType, typename G2::SizeType >::Type SizeType
Definition: Functional.hpp:1530
CommonType< typename M1::ValueType, typename M2::ValueType >::Type ValueType
Definition: Functional.hpp:595
CommonType< typename M1::SizeType, typename M2::SizeType >::Type SizeType
Definition: Functional.hpp:594
const T & Argument3Type
Definition: Functional.hpp:593
bool ResultType
Definition: Functional.hpp:592
CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type ValueType
Definition: Functional.hpp:969
const T & Argument3Type
Definition: Functional.hpp:968
bool ResultType
Definition: Functional.hpp:967
Definition: Functional.hpp:1345
CommonType< typename CommonType< typename Q1::ValueType, typename Q2::ValueType >::Type, T >::Type ResultType
Definition: Functional.hpp:1347
const T & Argument3Type
Definition: Functional.hpp:1348
bool ResultType
Definition: Functional.hpp:343
const T & Argument3Type
Definition: Functional.hpp:344
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ValueType
Definition: Functional.hpp:346
CommonType< typename V1::SizeType, typename V2::SizeType >::Type SizeType
Definition: Functional.hpp:345
Definition: Functional.hpp:76
static void apply(Argument1Type t1, Argument2Type t2)
Definition: Functional.hpp:81
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:79
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:78
Definition: Functional.hpp:211
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:213
static ResultType apply(Argument1Type t1, Argument2Type t2)
Definition: Functional.hpp:217
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:214
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:215
Definition: Functional.hpp:63
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:66
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:65
static void apply(Argument1Type t1, Argument2Type t2)
Definition: Functional.hpp:68
Definition: Functional.hpp:55
const T2 & Argument2Type
Definition: Functional.hpp:58
T1 Argument1Type
Definition: Functional.hpp:57
Definition: Functional.hpp:202
const T2 & Argument2Type
Definition: Functional.hpp:205
const T1 & Argument1Type
Definition: Functional.hpp:204
CommonType< T1, T2 >::Type ResultType
Definition: Functional.hpp:206
Definition: Functional.hpp:151
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:154
static ResultType apply(ArgumentType v)
Definition: Functional.hpp:157
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:155
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:153
Definition: Functional.hpp:115
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:117
static void apply(Argument1Type t1, Argument2Type t2)
Definition: Functional.hpp:120
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:118
Definition: Functional.hpp:253
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:255
static ResultType apply(Argument1Type t1, Argument2Type t2)
Definition: Functional.hpp:259
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:256
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:257
Definition: Functional.hpp:188
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:192
static ResultType apply(ArgumentType v)
Definition: Functional.hpp:194
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:190
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:191
Definition: Functional.hpp:102
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:104
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:105
static void apply(Argument1Type t1, Argument2Type t2)
Definition: Functional.hpp:107
Definition: Functional.hpp:239
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:242
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:241
static ResultType apply(Argument1Type t1, Argument2Type t2)
Definition: Functional.hpp:245
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:243
Definition: Functional.hpp:137
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:139
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:141
static ResultType apply(ArgumentType v)
Definition: Functional.hpp:143
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:140
Definition: Functional.hpp:1398
static ResultType applyC1(Argument1Type t, const QuaternionExpression< E > &e, Argument3Type n2)
Definition: Functional.hpp:1405
static ResultType applyC4(Argument1Type t, const QuaternionExpression< E > &e, Argument3Type n2)
Definition: Functional.hpp:1423
static ResultType applyC2(Argument1Type t, const QuaternionExpression< E > &e, Argument3Type n2)
Definition: Functional.hpp:1411
Scalar13QuaternionTernaryFunctor< T1, Q, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:1400
Scalar13QuaternionTernaryFunctor< T1, Q, T2 >::ResultType ResultType
Definition: Functional.hpp:1402
static ResultType applyC3(Argument1Type t, const QuaternionExpression< E > &e, Argument3Type n2)
Definition: Functional.hpp:1417
Scalar13QuaternionTernaryFunctor< T1, Q, T2 >::Argument3Type Argument3Type
Definition: Functional.hpp:1401
Definition: Functional.hpp:165
TypeTraits< T >::RealType ResultType
Definition: Functional.hpp:169
const T & ArgumentType
Definition: Functional.hpp:168
T ValueType
Definition: Functional.hpp:167
Definition: Functional.hpp:174
ScalarUnaryFunctor< T >::ArgumentType ArgumentType
Definition: Functional.hpp:177
ScalarUnaryFunctor< T >::ValueType ValueType
Definition: Functional.hpp:176
static ResultType apply(ArgumentType v)
Definition: Functional.hpp:180
ScalarUnaryFunctor< T >::ResultType ResultType
Definition: Functional.hpp:178
Definition: Functional.hpp:89
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:92
static void apply(Argument1Type t1, Argument2Type t2)
Definition: Functional.hpp:94
ScalarBinaryAssignmentFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:91
Definition: Functional.hpp:225
ScalarBinaryFunctor< T1, T2 >::ResultType ResultType
Definition: Functional.hpp:229
ScalarBinaryFunctor< T1, T2 >::Argument2Type Argument2Type
Definition: Functional.hpp:228
ScalarBinaryFunctor< T1, T2 >::Argument1Type Argument1Type
Definition: Functional.hpp:227
static ResultType apply(Argument1Type t1, Argument2Type t2)
Definition: Functional.hpp:231
static RealType real(ConstReference t)
Definition: TypeTraits.hpp:74
static RealType conj(ConstReference t)
Definition: TypeTraits.hpp:84
static RealType normInf(ConstReference t)
Definition: TypeTraits.hpp:109
static RealType imag(ConstReference)
Definition: TypeTraits.hpp:79
static ValueType sqrt(ConstReference t)
Definition: TypeTraits.hpp:94
static RealType norm2(ConstReference t)
Definition: TypeTraits.hpp:104
T RealType
Definition: TypeTraits.hpp:70
Definition: Functional.hpp:128
T ValueType
Definition: Functional.hpp:130
const T & ArgumentType
Definition: Functional.hpp:131
ValueType ResultType
Definition: Functional.hpp:132
Definition: TypeTraits.hpp:171
Definition: Functional.hpp:294
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2, const T &sd, bool clamp)
Definition: Functional.hpp:298
CommonType< typename VectorInnerProduct< V1, V2 >::ResultType, T >::Type ResultType
Definition: Functional.hpp:296
Definition: Functional.hpp:377
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ResultType
Definition: Functional.hpp:379
Definition: Functional.hpp:311
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ValueType
Definition: Functional.hpp:315
bool ResultType
Definition: Functional.hpp:313
CommonType< typename V1::SizeType, typename V2::SizeType >::Type SizeType
Definition: Functional.hpp:314
Definition: Functional.hpp:384
static ResultType apply(const VectorExpression< E1 > &e1, const VectorExpression< E2 > &e2, SizeType i)
Definition: Functional.hpp:389
VectorScalarBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:386
Definition: Functional.hpp:421
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:423
static ResultType apply(const VectorExpression< V > &e)
Definition: Functional.hpp:425
Definition: Functional.hpp:320
VectorBooleanBinaryFunctor< V1, V2 >::ValueType ValueType
Definition: Functional.hpp:323
VectorBooleanBinaryFunctor< V1, V2 >::SizeType SizeType
Definition: Functional.hpp:322
VectorBooleanBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:324
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2)
Definition: Functional.hpp:326
Definition: Functional.hpp:274
VectorScalarBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:276
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2)
Definition: Functional.hpp:278
Definition: Functional.hpp:893
MatrixVectorBinaryFunctor< M, V >::ResultType ResultType
Definition: Functional.hpp:897
MatrixVectorBinaryFunctor< M, V >::SizeType SizeType
Definition: Functional.hpp:896
static ResultType apply(const VectorExpression< E1 > &e1, const MatrixExpression< E2 > &e2, SizeType i)
Definition: Functional.hpp:900
MatrixVectorBinaryFunctor< M, V >::ValueType ValueType
Definition: Functional.hpp:895
Definition: Functional.hpp:776
V::ValueType ResultType
Definition: Functional.hpp:778
V::SizeType SizeType
Definition: Functional.hpp:779
Definition: Functional.hpp:449
static ResultType apply(const VectorExpression< V > &e)
Definition: Functional.hpp:455
VectorScalarRealUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:452
VectorScalarRealUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:451
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:453
Definition: Functional.hpp:470
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:474
VectorScalarRealUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:473
static ResultType apply(const VectorExpression< V > &e)
Definition: Functional.hpp:476
VectorScalarRealUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:472
Definition: Functional.hpp:528
VectorScalarIndexUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:532
VectorScalarIndexUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:530
VectorScalarIndexUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:531
static ResultType apply(const VectorExpression< V > &e)
Definition: Functional.hpp:534
Definition: Functional.hpp:494
static ResultType apply(const VectorExpression< V > &e)
Definition: Functional.hpp:500
VectorScalarRealUnaryFunctor< V >::ValueType ValueType
Definition: Functional.hpp:496
VectorScalarRealUnaryFunctor< V >::RealType RealType
Definition: Functional.hpp:497
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:498
Definition: Functional.hpp:267
CommonType< typename V1::ValueType, typename V2::ValueType >::Type ResultType
Definition: Functional.hpp:269
Definition: Functional.hpp:519
TypeTraits< ValueType >::RealType RealType
Definition: Functional.hpp:522
V::ValueType ValueType
Definition: Functional.hpp:521
V::SizeType ResultType
Definition: Functional.hpp:523
Definition: Functional.hpp:440
RealType ResultType
Definition: Functional.hpp:444
TypeTraits< ValueType >::RealType RealType
Definition: Functional.hpp:443
V::ValueType ValueType
Definition: Functional.hpp:442
Definition: Functional.hpp:413
V::ValueType ResultType
Definition: Functional.hpp:415
V::SizeType SizeType
Definition: Functional.hpp:416
Definition: Functional.hpp:351
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::ValueType ValueType
Definition: Functional.hpp:354
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::SizeType SizeType
Definition: Functional.hpp:353
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::Argument3Type Argument3Type
Definition: Functional.hpp:356
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::ResultType ResultType
Definition: Functional.hpp:355
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2, Argument3Type epsilon)
Definition: Functional.hpp:358