Chemical Data Processing Library C++ API - Version 1.4.0
MatrixProxy.hpp
Go to the documentation of this file.
1 /*
2  * MatrixProxy.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_MATRIXPROXY_HPP
28 #define CDPL_MATH_MATRIXPROXY_HPP
29 
30 #include <type_traits>
31 
32 #include "CDPL/Math/Expression.hpp"
33 #include "CDPL/Math/TypeTraits.hpp"
34 #include "CDPL/Math/Functional.hpp"
37 #include "CDPL/Math/Range.hpp"
38 #include "CDPL/Math/Slice.hpp"
39 
40 
41 namespace CDPL
42 {
43 
44  namespace Math
45  {
46 
51  template <typename M>
52  class MatrixRow : public VectorExpression<MatrixRow<M> >
53  {
54 
55  typedef MatrixRow<M> SelfType;
56 
57  public:
61  typedef M MatrixType;
62 
66  typedef typename M::SizeType SizeType;
67 
71  typedef typename M::DifferenceType DifferenceType;
72 
76  typedef typename M::ValueType ValueType;
77 
81  typedef typename M::ConstReference ConstReference;
82 
86  typedef typename std::conditional<std::is_const<M>::value,
87  typename M::ConstReference,
88  typename M::Reference>::type Reference;
89 
93  typedef typename std::conditional<std::is_const<M>::value,
94  typename M::ConstClosureType,
95  typename M::ClosureType>::type MatrixClosureType;
96 
100  typedef const SelfType ConstClosureType;
101 
106 
113  data(m), index(i) {}
114 
121  {
122  return data(index, i);
123  }
124 
131  {
132  return data(index, i);
133  }
134 
141  {
142  return data(index, i);
143  }
144 
151  {
152  return data(index, i);
153  }
154 
160  {
161  return index;
162  }
163 
169  {
170  return data.getSize2();
171  }
172 
177  bool isEmpty() const
178  {
179  return (data.getSize2() == 0);
180  }
181 
187  {
188  return data;
189  }
190 
195  const MatrixClosureType& getData() const
196  {
197  return data;
198  }
199 
206  {
207  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(r));
208  return *this;
209  }
210 
217  template <typename E>
219  {
220  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(e));
221  return *this;
222  }
223 
230  template <typename E>
232  {
233  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(*this + e));
234  return *this;
235  }
236 
243  template <typename E>
245  {
246  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(*this - e));
247  return *this;
248  }
249 
256  template <typename T>
257  typename std::enable_if<IsScalar<T>::value, MatrixRow>::type& operator*=(const T& t)
258  {
259  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
260  return *this;
261  }
262 
269  template <typename T>
270  typename std::enable_if<IsScalar<T>::value, MatrixRow>::type& operator/=(const T& t)
271  {
272  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
273  return *this;
274  }
275 
282  template <typename E>
284  {
285  vectorAssignVector<ScalarAssignment>(*this, e);
286  return *this;
287  }
288 
295  template <typename E>
297  {
298  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
299  return *this;
300  }
301 
308  template <typename E>
310  {
311  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
312  return *this;
313  }
314 
319  void swap(MatrixRow& r)
320  {
321  if (this != &r)
322  vectorSwap(*this, r);
323  }
324 
330  friend void swap(MatrixRow& r1, MatrixRow& r2)
331  {
332  r1.swap(r2);
333  }
334 
335  private:
336  MatrixClosureType data;
337  SizeType index;
338  };
339 
344  template <typename M>
345  class MatrixColumn : public VectorExpression<MatrixColumn<M> >
346  {
347 
348  typedef MatrixColumn<M> SelfType;
349 
350  public:
354  typedef M MatrixType;
355 
359  typedef typename M::SizeType SizeType;
360 
364  typedef typename M::DifferenceType DifferenceType;
365 
369  typedef typename M::ValueType ValueType;
370 
374  typedef typename M::ConstReference ConstReference;
375 
379  typedef typename std::conditional<std::is_const<M>::value,
380  typename M::ConstReference,
381  typename M::Reference>::type Reference;
382 
386  typedef typename std::conditional<std::is_const<M>::value,
387  typename M::ConstClosureType,
388  typename M::ClosureType>::type MatrixClosureType;
389 
393  typedef const SelfType ConstClosureType;
394 
399 
406  data(m), index(i) {}
407 
414  {
415  return data(i, index);
416  }
417 
424  {
425  return data(i, index);
426  }
427 
434  {
435  return data(i, index);
436  }
437 
444  {
445  return data(i, index);
446  }
447 
453  {
454  return index;
455  }
456 
462  {
463  return data.getSize1();
464  }
465 
470  bool isEmpty() const
471  {
472  return (data.getSize1() == 0);
473  }
474 
480  {
481  return data;
482  }
483 
488  const MatrixClosureType& getData() const
489  {
490  return data;
491  }
492 
499  {
500  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(c));
501  return *this;
502  }
503 
510  template <typename E>
512  {
513  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(e));
514  return *this;
515  }
516 
523  template <typename E>
525  {
526  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(*this + e));
527  return *this;
528  }
529 
536  template <typename E>
538  {
539  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(*this - e));
540  return *this;
541  }
542 
549  template <typename T>
550  typename std::enable_if<IsScalar<T>::value, MatrixColumn>::type& operator*=(const T& t)
551  {
552  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
553  return *this;
554  }
555 
562  template <typename T>
563  typename std::enable_if<IsScalar<T>::value, MatrixColumn>::type& operator/=(const T& t)
564  {
565  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
566  return *this;
567  }
568 
575  template <typename E>
577  {
578  vectorAssignVector<ScalarAssignment>(*this, e);
579  return *this;
580  }
581 
588  template <typename E>
590  {
591  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
592  return *this;
593  }
594 
601  template <typename E>
603  {
604  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
605  return *this;
606  }
607 
613  {
614  if (this != &c)
615  vectorSwap(*this, c);
616  }
617 
623  friend void swap(MatrixColumn& c1, MatrixColumn& c2)
624  {
625  c1.swap(c2);
626  }
627 
628  private:
629  MatrixClosureType data;
630  SizeType index;
631  };
632 
637  template <typename M>
638  class MatrixRange : public MatrixExpression<MatrixRange<M> >
639  {
640 
641  typedef MatrixRange<M> SelfType;
642 
643  public:
647  typedef M MatrixType;
648 
652  typedef typename M::SizeType SizeType;
653 
657  typedef typename M::DifferenceType DifferenceType;
658 
662  typedef typename M::ValueType ValueType;
663 
667  typedef typename M::ConstReference ConstReference;
668 
672  typedef typename std::conditional<std::is_const<M>::value,
673  typename M::ConstReference,
674  typename M::Reference>::type Reference;
675 
679  typedef typename std::conditional<std::is_const<M>::value,
680  typename M::ConstClosureType,
681  typename M::ClosureType>::type MatrixClosureType;
682 
686  typedef const SelfType ConstClosureType;
687 
692 
697 
704  MatrixRange(MatrixType& m, const RangeType& r1, const RangeType& r2):
705  data(m), range1(r1), range2(r2) {}
706 
714  {
715  return data(range1(i), range2(j));
716  }
717 
725  {
726  return data(range1(i), range2(j));
727  }
728 
734  {
735  return range1.getStart();
736  }
737 
743  {
744  return range2.getStart();
745  }
746 
752  {
753  return range1.getSize();
754  }
755 
761  {
762  return range2.getSize();
763  }
764 
769  bool isEmpty() const
770  {
771  return (range1.getSize() == SizeType(0) || range2.getSize() == SizeType(0));
772  }
773 
779  {
780  return data;
781  }
782 
787  const MatrixClosureType& getData() const
788  {
789  return data;
790  }
791 
798  {
799  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(r));
800  return *this;
801  }
802 
809  template <typename E>
811  {
812  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(e));
813  return *this;
814  }
815 
822  template <typename E>
824  {
825  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(*this + e));
826  return *this;
827  }
828 
835  template <typename E>
837  {
838  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(*this - e));
839  return *this;
840  }
841 
848  template <typename T>
849  typename std::enable_if<IsScalar<T>::value, MatrixRange>::type& operator*=(const T& t)
850  {
851  matrixAssignScalar<ScalarMultiplicationAssignment>(*this, t);
852  return *this;
853  }
854 
861  template <typename T>
862  typename std::enable_if<IsScalar<T>::value, MatrixRange>::type& operator/=(const T& t)
863  {
864  matrixAssignScalar<ScalarDivisionAssignment>(*this, t);
865  return *this;
866  }
867 
874  template <typename E>
876  {
877  matrixAssignMatrix<ScalarAssignment>(*this, e);
878  return *this;
879  }
880 
887  template <typename E>
889  {
890  matrixAssignMatrix<ScalarAdditionAssignment>(*this, e);
891  return *this;
892  }
893 
900  template <typename E>
902  {
903  matrixAssignMatrix<ScalarSubtractionAssignment>(*this, e);
904  return *this;
905  }
906 
912  {
913  if (this != &r)
914  matrixSwap(*this, r);
915  }
916 
922  friend void swap(MatrixRange& r1, MatrixRange& r2)
923  {
924  r1.swap(r2);
925  }
926 
927  private:
928  MatrixClosureType data;
929  RangeType range1;
930  RangeType range2;
931  };
932 
937  template <typename M>
938  class MatrixSlice : public MatrixExpression<MatrixSlice<M> >
939  {
940 
941  typedef MatrixSlice<M> SelfType;
942 
943  public:
947  typedef M MatrixType;
948 
952  typedef typename M::SizeType SizeType;
953 
957  typedef typename M::DifferenceType DifferenceType;
958 
962  typedef typename M::ValueType ValueType;
963 
967  typedef typename M::ConstReference ConstReference;
968 
972  typedef typename std::conditional<std::is_const<M>::value,
973  typename M::ConstReference,
974  typename M::Reference>::type Reference;
975 
979  typedef typename std::conditional<std::is_const<M>::value,
980  typename M::ConstClosureType,
981  typename M::ClosureType>::type MatrixClosureType;
982 
986  typedef const SelfType ConstClosureType;
987 
992 
997 
1004  MatrixSlice(MatrixType& m, const SliceType& s1, const SliceType& s2):
1005  data(m), slice1(s1), slice2(s2) {}
1006 
1014  {
1015  return data(slice1(i), slice2(j));
1016  }
1017 
1025  {
1026  return data(slice1(i), slice2(j));
1027  }
1028 
1034  {
1035  return slice1.getStart();
1036  }
1037 
1043  {
1044  return slice2.getStart();
1045  }
1046 
1052  {
1053  return slice1.getStride();
1054  }
1055 
1061  {
1062  return slice2.getStride();
1063  }
1064 
1070  {
1071  return slice1.getSize();
1072  }
1073 
1079  {
1080  return slice2.getSize();
1081  }
1082 
1087  bool isEmpty() const
1088  {
1089  return (slice1.getSize() == SizeType(0) || slice2.getSize() == SizeType(0));
1090  }
1091 
1097  {
1098  return data;
1099  }
1100 
1106  {
1107  return data;
1108  }
1109 
1116  {
1117  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(s));
1118  return *this;
1119  }
1120 
1127  template <typename E>
1129  {
1130  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(e));
1131  return *this;
1132  }
1133 
1140  template <typename E>
1142  {
1143  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(*this + e));
1144  return *this;
1145  }
1146 
1153  template <typename E>
1155  {
1156  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(*this - e));
1157  return *this;
1158  }
1159 
1166  template <typename T>
1167  typename std::enable_if<IsScalar<T>::value, MatrixSlice>::type& operator*=(const T& t)
1168  {
1169  matrixAssignScalar<ScalarMultiplicationAssignment>(*this, t);
1170  return *this;
1171  }
1172 
1179  template <typename T>
1180  typename std::enable_if<IsScalar<T>::value, MatrixSlice>::type& operator/=(const T& t)
1181  {
1182  matrixAssignScalar<ScalarDivisionAssignment>(*this, t);
1183  return *this;
1184  }
1185 
1192  template <typename E>
1194  {
1195  matrixAssignMatrix<ScalarAssignment>(*this, e);
1196  return *this;
1197  }
1198 
1205  template <typename E>
1207  {
1208  matrixAssignMatrix<ScalarAdditionAssignment>(*this, e);
1209  return *this;
1210  }
1211 
1218  template <typename E>
1220  {
1221  matrixAssignMatrix<ScalarSubtractionAssignment>(*this, e);
1222  return *this;
1223  }
1224 
1230  {
1231  if (this != &s)
1232  matrixSwap(*this, s);
1233  }
1234 
1240  friend void swap(MatrixSlice& s1, MatrixSlice& s2)
1241  {
1242  s1.swap(s2);
1243  }
1244 
1245  private:
1246  MatrixClosureType data;
1247  SliceType slice1;
1248  SliceType slice2;
1249  };
1250 
1254  template <typename M>
1256  {};
1257 
1261  template <typename M>
1263  {};
1264 
1268  template <typename M>
1270  {};
1271 
1275  template <typename M>
1277  {};
1278 
1282  template <typename M>
1284  {};
1285 
1289  template <typename M>
1291  {};
1292 
1296  template <typename M>
1298  {};
1299 
1303  template <typename M>
1305  {};
1306 
1310  template <typename M>
1312  {};
1313 
1317  template <typename M>
1319  {};
1320 
1324  template <typename M>
1326  {};
1327 
1331  template <typename M>
1333  {};
1334 
1338  template <typename M>
1340  {};
1341 
1345  template <typename M>
1347  {};
1348 
1352  template <typename M>
1354  {};
1355 
1359  template <typename M>
1361  {};
1362 
1370  template <typename M>
1371  MatrixRow<M>
1373  {
1374  return MatrixRow<M>(e(), i);
1375  }
1376 
1384  template <typename M>
1385  MatrixRow<const M>
1387  {
1388  return MatrixRow<const M>(e(), i);
1389  }
1390 
1398  template <typename M>
1399  MatrixColumn<M>
1401  {
1402  return MatrixColumn<M>(e(), j);
1403  }
1404 
1412  template <typename M>
1413  MatrixColumn<const M>
1415  {
1416  return MatrixColumn<const M>(e(), j);
1417  }
1418 
1427  template <typename E>
1428  MatrixRange<E>
1430  const typename MatrixRange<E>::RangeType& r1,
1431  const typename MatrixRange<E>::RangeType& r2)
1432  {
1433  return MatrixRange<E>(e(), r1, r2);
1434  }
1435 
1444  template <typename E>
1445  MatrixRange<const E>
1447  const typename MatrixRange<const E>::RangeType& r1,
1448  const typename MatrixRange<const E>::RangeType& r2)
1449  {
1450  return MatrixRange<const E>(e(), r1, r2);
1451  }
1452 
1463  template <typename E>
1464  MatrixRange<E>
1466  typename MatrixRange<E>::RangeType::SizeType start1,
1467  typename MatrixRange<E>::RangeType::SizeType stop1,
1468  typename MatrixRange<E>::RangeType::SizeType start2,
1469  typename MatrixRange<E>::RangeType::SizeType stop2)
1470  {
1471  typedef typename MatrixRange<E>::RangeType RangeType;
1472 
1473  return MatrixRange<E>(e(), RangeType(start1, stop1), RangeType(start2, stop2));
1474  }
1475 
1486  template <typename E>
1487  MatrixRange<const E>
1493  {
1494  typedef typename MatrixRange<const E>::RangeType RangeType;
1495 
1496  return MatrixRange<const E>(e(), RangeType(start1, stop1), RangeType(start2, stop2));
1497  }
1498 
1507  template <typename E>
1508  MatrixSlice<E>
1510  const typename MatrixSlice<E>::SliceType& s1,
1511  const typename MatrixSlice<E>::SliceType& s2)
1512  {
1513  return MatrixSlice<E>(e(), s1, s2);
1514  }
1515 
1524  template <typename E>
1525  MatrixSlice<const E>
1527  const typename MatrixSlice<const E>::SliceType& s1,
1528  const typename MatrixSlice<const E>::SliceType& s2)
1529  {
1530  return MatrixSlice<const E>(e(), s1, s2);
1531  }
1532 
1545  template <typename E>
1546  MatrixSlice<E>
1548  typename MatrixSlice<E>::SliceType::SizeType start1,
1550  typename MatrixSlice<E>::SliceType::SizeType size1,
1551  typename MatrixSlice<E>::SliceType::SizeType start2,
1553  typename MatrixSlice<E>::SliceType::SizeType size2)
1554  {
1555  typedef typename MatrixSlice<E>::SliceType SliceType;
1556 
1557  return MatrixSlice<E>(e(), SliceType(start1, stride1, size1), SliceType(start2, stride2, size2));
1558  }
1559 
1572  template <typename E>
1573  MatrixSlice<const E>
1581  {
1582  typedef typename MatrixSlice<const E>::SliceType SliceType;
1583 
1584  return MatrixSlice<const E>(e(), SliceType(start1, stride1, size1), SliceType(start2, stride2, size2));
1585  }
1586  } // namespace Math
1587 } // namespace CDPL
1588 
1589 #endif // CDPL_MATH_MATRIXPROXY_HPP
Definition of basic expression types.
Definition of various functors.
Implementation of matrix assignment routines.
Definition of a data type for describing index ranges.
Definition of a data type for describing index slices.
Definition of type traits.
Implementation of vector assignment routines.
Vector expression proxy that views a single column of an underlying matrix.
Definition: MatrixProxy.hpp:346
friend void swap(MatrixColumn &c1, MatrixColumn &c2)
ADL-enabled free-function form of swap().
Definition: MatrixProxy.hpp:623
M::ConstReference ConstReference
Constant element reference type.
Definition: MatrixProxy.hpp:374
MatrixColumn & operator+=(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this column (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:524
MatrixColumn & assign(const VectorExpression< E > &e)
Assigns the elements of the vector expression e to this column without intermediate temporary.
Definition: MatrixProxy.hpp:576
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable element reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: MatrixProxy.hpp:381
ConstReference operator[](SizeType i) const
Returns a const reference to the element at row i of the column.
Definition: MatrixProxy.hpp:443
std::enable_if< IsScalar< T >::value, MatrixColumn >::type & operator*=(const T &t)
Multiplies every element of this column by the scalar t.
Definition: MatrixProxy.hpp:550
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:398
void swap(MatrixColumn &c)
Swaps the contents of this column with those of c (via element-wise swap of the underlying matrix ele...
Definition: MatrixProxy.hpp:612
M::SizeType SizeType
The size type used by the wrapped matrix.
Definition: MatrixProxy.hpp:359
MatrixColumn & operator=(const MatrixColumn &c)
Copy-assigns the contents of c to this column (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:498
MatrixColumn & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this column without intermediate temporary.
Definition: MatrixProxy.hpp:589
SizeType getIndex() const
Returns the column index this proxy refers to within the wrapped matrix.
Definition: MatrixProxy.hpp:452
MatrixColumn & operator=(const VectorExpression< E > &e)
Assigns the elements of the vector expression e to this column (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:511
ConstReference operator()(SizeType i) const
Returns a const reference to the element at row i of the column.
Definition: MatrixProxy.hpp:423
MatrixColumn & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this column without intermediate temporary.
Definition: MatrixProxy.hpp:602
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:393
MatrixColumn(MatrixType &m, SizeType i)
Constructs the column proxy viewing column i of m.
Definition: MatrixProxy.hpp:405
Reference operator[](SizeType i)
Returns a mutable reference to the element at row i of the column.
Definition: MatrixProxy.hpp:433
M MatrixType
The wrapped matrix type.
Definition: MatrixProxy.hpp:354
M::ValueType ValueType
The element value type of the wrapped matrix.
Definition: MatrixProxy.hpp:369
const MatrixClosureType & getData() const
Returns a const reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:488
std::conditional< std::is_const< M >::value, typename M::ConstClosureType, typename M::ClosureType >::type MatrixClosureType
Closure type used to store the wrapped matrix internally.
Definition: MatrixProxy.hpp:388
MatrixClosureType & getData()
Returns a reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:479
bool isEmpty() const
Tells whether the column is empty (the wrapped matrix has zero rows).
Definition: MatrixProxy.hpp:470
SizeType getSize() const
Returns the size of the column (number of rows of the wrapped matrix).
Definition: MatrixProxy.hpp:461
M::DifferenceType DifferenceType
The signed difference type used by the wrapped matrix.
Definition: MatrixProxy.hpp:364
std::enable_if< IsScalar< T >::value, MatrixColumn >::type & operator/=(const T &t)
Divides every element of this column by the scalar t.
Definition: MatrixProxy.hpp:563
Reference operator()(SizeType i)
Returns a mutable reference to the element at row i of the column.
Definition: MatrixProxy.hpp:413
MatrixColumn & operator-=(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this column (via a temporary to handle aliasin...
Definition: MatrixProxy.hpp:537
CRTP base class of all matrix expression types.
Definition: Expression.hpp:108
Matrix expression proxy that views a contiguous rectangular subrange of an underlying matrix.
Definition: MatrixProxy.hpp:639
M::SizeType SizeType
The size type used by the wrapped matrix.
Definition: MatrixProxy.hpp:652
MatrixRange & operator=(const MatrixRange &r)
Copy-assigns the contents of r to this matrix range (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:797
const MatrixClosureType & getData() const
Returns a const reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:787
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable element reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: MatrixProxy.hpp:674
std::conditional< std::is_const< M >::value, typename M::ConstClosureType, typename M::ClosureType >::type MatrixClosureType
Closure type used to store the wrapped matrix internally.
Definition: MatrixProxy.hpp:681
MatrixRange & operator-=(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix range (via a temporary to handle a...
Definition: MatrixProxy.hpp:836
SizeType getStart1() const
Returns the row index range's start index in the wrapped matrix.
Definition: MatrixProxy.hpp:733
SizeType getSize2() const
Returns the number of columns in the proxy (size of the column range).
Definition: MatrixProxy.hpp:760
M MatrixType
The wrapped matrix type.
Definition: MatrixProxy.hpp:647
MatrixRange & assign(const MatrixExpression< E > &e)
Assigns the elements of the matrix expression e to this matrix range without intermediate temporary.
Definition: MatrixProxy.hpp:875
MatrixRange & operator+=(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix range (via a temporary to handle aliasing...
Definition: MatrixProxy.hpp:823
SizeType getStart2() const
Returns the column index range's start index in the wrapped matrix.
Definition: MatrixProxy.hpp:742
Range< SizeType > RangeType
Range type used to specify the row and column index ranges.
Definition: MatrixProxy.hpp:696
M::ConstReference ConstReference
Constant element reference type.
Definition: MatrixProxy.hpp:667
M::ValueType ValueType
The element value type of the wrapped matrix.
Definition: MatrixProxy.hpp:662
friend void swap(MatrixRange &r1, MatrixRange &r2)
ADL-enabled free-function form of swap().
Definition: MatrixProxy.hpp:922
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at proxy index (i, j).
Definition: MatrixProxy.hpp:724
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at proxy index (i, j).
Definition: MatrixProxy.hpp:713
M::DifferenceType DifferenceType
The signed difference type used by the wrapped matrix.
Definition: MatrixProxy.hpp:657
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:691
SizeType getSize1() const
Returns the number of rows in the proxy (size of the row range).
Definition: MatrixProxy.hpp:751
void swap(MatrixRange &r)
Swaps the contents of this matrix range with those of r (via element-wise swap of the underlying matr...
Definition: MatrixProxy.hpp:911
std::enable_if< IsScalar< T >::value, MatrixRange >::type & operator*=(const T &t)
Multiplies every element of this matrix range by the scalar t.
Definition: MatrixProxy.hpp:849
std::enable_if< IsScalar< T >::value, MatrixRange >::type & operator/=(const T &t)
Divides every element of this matrix range by the scalar t.
Definition: MatrixProxy.hpp:862
MatrixRange & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix range without intermediate temporary.
Definition: MatrixProxy.hpp:888
bool isEmpty() const
Tells whether the proxy is empty (either range has size zero).
Definition: MatrixProxy.hpp:769
MatrixRange & operator=(const MatrixExpression< E > &e)
Assigns the elements of the matrix expression e to this matrix range (via a temporary to handle alias...
Definition: MatrixProxy.hpp:810
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:686
MatrixClosureType & getData()
Returns a reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:778
MatrixRange(MatrixType &m, const RangeType &r1, const RangeType &r2)
Constructs the matrix range proxy viewing rows in r1 and columns in r2 of m.
Definition: MatrixProxy.hpp:704
MatrixRange & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix range without intermediate tempora...
Definition: MatrixProxy.hpp:901
Vector expression proxy that views a single row of an underlying matrix.
Definition: MatrixProxy.hpp:53
MatrixRow & operator=(const MatrixRow &r)
Copy-assigns the contents of r to this row (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:205
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable element reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: MatrixProxy.hpp:88
MatrixRow & operator+=(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this row (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:231
M::DifferenceType DifferenceType
The signed difference type used by the wrapped matrix.
Definition: MatrixProxy.hpp:71
std::conditional< std::is_const< M >::value, typename M::ConstClosureType, typename M::ClosureType >::type MatrixClosureType
Closure type used to store the wrapped matrix internally (mutable or const flavor).
Definition: MatrixProxy.hpp:95
M MatrixType
The wrapped matrix type.
Definition: MatrixProxy.hpp:61
ConstReference operator[](SizeType i) const
Returns a const reference to the element at column i of the row.
Definition: MatrixProxy.hpp:150
MatrixRow & assign(const VectorExpression< E > &e)
Assigns the elements of the vector expression e to this row without intermediate temporary.
Definition: MatrixProxy.hpp:283
MatrixRow & operator=(const VectorExpression< E > &e)
Assigns the elements of the vector expression e to this row (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:218
std::enable_if< IsScalar< T >::value, MatrixRow >::type & operator*=(const T &t)
Multiplies every element of this row by the scalar t.
Definition: MatrixProxy.hpp:257
MatrixRow(MatrixType &m, SizeType i)
Constructs the row proxy viewing row i of m.
Definition: MatrixProxy.hpp:112
const MatrixClosureType & getData() const
Returns a const reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:195
M::ConstReference ConstReference
Constant element reference type.
Definition: MatrixProxy.hpp:81
SizeType getSize() const
Returns the size of the row (number of columns of the wrapped matrix).
Definition: MatrixProxy.hpp:168
ConstReference operator()(SizeType i) const
Returns a const reference to the element at column i of the row.
Definition: MatrixProxy.hpp:130
MatrixRow & operator-=(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this row (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:244
M::SizeType SizeType
The size type used by the wrapped matrix.
Definition: MatrixProxy.hpp:66
Reference operator()(SizeType i)
Returns a mutable reference to the element at column i of the row.
Definition: MatrixProxy.hpp:120
void swap(MatrixRow &r)
Swaps the contents of this row with those of r (via element-wise swap of the underlying matrix elemen...
Definition: MatrixProxy.hpp:319
SizeType getIndex() const
Returns the row index this proxy refers to within the wrapped matrix.
Definition: MatrixProxy.hpp:159
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:100
M::ValueType ValueType
The element value type of the wrapped matrix.
Definition: MatrixProxy.hpp:76
MatrixRow & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this row without intermediate temporary.
Definition: MatrixProxy.hpp:309
friend void swap(MatrixRow &r1, MatrixRow &r2)
ADL-enabled free-function form of swap().
Definition: MatrixProxy.hpp:330
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:105
MatrixClosureType & getData()
Returns a reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:186
bool isEmpty() const
Tells whether the row is empty (the wrapped matrix has zero columns).
Definition: MatrixProxy.hpp:177
std::enable_if< IsScalar< T >::value, MatrixRow >::type & operator/=(const T &t)
Divides every element of this row by the scalar t.
Definition: MatrixProxy.hpp:270
MatrixRow & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this row without intermediate temporary.
Definition: MatrixProxy.hpp:296
Reference operator[](SizeType i)
Returns a mutable reference to the element at column i of the row.
Definition: MatrixProxy.hpp:140
Matrix expression proxy that views a strided rectangular slice of an underlying matrix.
Definition: MatrixProxy.hpp:939
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:986
SizeType getSize2() const
Returns the number of columns in the proxy (size of the column slice).
Definition: MatrixProxy.hpp:1078
MatrixSlice & operator=(const MatrixSlice &s)
Copy-assigns the contents of s to this matrix slice (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:1115
MatrixSlice & operator-=(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix slice (via a temporary to handle a...
Definition: MatrixProxy.hpp:1154
MatrixClosureType & getData()
Returns a reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:1096
std::enable_if< IsScalar< T >::value, MatrixSlice >::type & operator*=(const T &t)
Multiplies every element of this matrix slice by the scalar t.
Definition: MatrixProxy.hpp:1167
MatrixSlice & operator=(const MatrixExpression< E > &e)
Assigns the elements of the matrix expression e to this matrix slice (via a temporary to handle alias...
Definition: MatrixProxy.hpp:1128
MatrixSlice & assign(const MatrixExpression< E > &e)
Assigns the elements of the matrix expression e to this matrix slice without intermediate temporary.
Definition: MatrixProxy.hpp:1193
SizeType getStart2() const
Returns the column slice's start index in the wrapped matrix.
Definition: MatrixProxy.hpp:1042
Slice< SizeType, DifferenceType > SliceType
Slice type used to specify the row and column slices (start, stride, size).
Definition: MatrixProxy.hpp:996
friend void swap(MatrixSlice &s1, MatrixSlice &s2)
ADL-enabled free-function form of swap().
Definition: MatrixProxy.hpp:1240
M::DifferenceType DifferenceType
The signed difference type used by the wrapped matrix.
Definition: MatrixProxy.hpp:957
const MatrixClosureType & getData() const
Returns a const reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:1105
M MatrixType
The wrapped matrix type.
Definition: MatrixProxy.hpp:947
MatrixSlice(MatrixType &m, const SliceType &s1, const SliceType &s2)
Constructs the matrix slice proxy viewing rows in s1 and columns in s2 of m.
Definition: MatrixProxy.hpp:1004
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at proxy index (i, j).
Definition: MatrixProxy.hpp:1013
M::ConstReference ConstReference
Constant element reference type.
Definition: MatrixProxy.hpp:967
MatrixSlice & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix slice without intermediate temporary.
Definition: MatrixProxy.hpp:1206
M::ValueType ValueType
The element value type of the wrapped matrix.
Definition: MatrixProxy.hpp:962
void swap(MatrixSlice &s)
Swaps the contents of this matrix slice with those of s (via element-wise swap of the underlying matr...
Definition: MatrixProxy.hpp:1229
M::SizeType SizeType
The size type used by the wrapped matrix.
Definition: MatrixProxy.hpp:952
bool isEmpty() const
Tells whether the proxy is empty (either slice has size zero).
Definition: MatrixProxy.hpp:1087
DifferenceType getStride1() const
Returns the row slice's stride in the wrapped matrix.
Definition: MatrixProxy.hpp:1051
std::conditional< std::is_const< M >::value, typename M::ConstClosureType, typename M::ClosureType >::type MatrixClosureType
Closure type used to store the wrapped matrix internally.
Definition: MatrixProxy.hpp:981
SizeType getSize1() const
Returns the number of rows in the proxy (size of the row slice).
Definition: MatrixProxy.hpp:1069
SizeType getStart1() const
Returns the row slice's start index in the wrapped matrix.
Definition: MatrixProxy.hpp:1033
DifferenceType getStride2() const
Returns the column slice's stride in the wrapped matrix.
Definition: MatrixProxy.hpp:1060
MatrixSlice & operator+=(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix slice (via a temporary to handle aliasing...
Definition: MatrixProxy.hpp:1141
MatrixSlice & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix slice without intermediate tempora...
Definition: MatrixProxy.hpp:1219
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at proxy index (i, j).
Definition: MatrixProxy.hpp:1024
std::enable_if< IsScalar< T >::value, MatrixSlice >::type & operator/=(const T &t)
Divides every element of this matrix slice by the scalar t.
Definition: MatrixProxy.hpp:1180
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable element reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: MatrixProxy.hpp:974
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:991
SizeType getStart() const
Returns the lower (inclusive) bound.
Definition: Range.hpp:93
SizeType getSize() const
Returns the size of the range.
Definition: Range.hpp:111
SizeType SizeType
The integral size/index type.
Definition: Range.hpp:57
SizeType SizeType
The integral size/index type.
Definition: Slice.hpp:62
SizeType getStart() const
Returns the starting global index.
Definition: Slice.hpp:104
SizeType getSize() const
Returns the number of entries in the slice.
Definition: Slice.hpp:122
DifferenceType getStride() const
Returns the signed step size between consecutive entries.
Definition: Slice.hpp:113
DifferenceType DifferenceType
The signed difference type used for the stride.
Definition: Slice.hpp:67
CRTP base class of all vector expression types.
Definition: Expression.hpp:68
constexpr unsigned int M
Generic type that covers any element that is a metal.
Definition: AtomType.hpp:657
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
constexpr unsigned int r
Specifies that the stereocenter has r configuration.
Definition: CIPDescriptor.hpp:76
constexpr unsigned int s
Specifies that the stereocenter has s configuration.
Definition: CIPDescriptor.hpp:81
constexpr unsigned int m
Specifies that the stereocenter has m configuration.
Definition: CIPDescriptor.hpp:116
MatrixSlice< E > slice(MatrixExpression< E > &e, const typename MatrixSlice< E >::SliceType &s1, const typename MatrixSlice< E >::SliceType &s2)
Returns a mutable matrix slice proxy viewing the strided rectangular slice (s1, s2) of e.
Definition: MatrixProxy.hpp:1509
MatrixColumn< M > column(MatrixExpression< M > &e, typename MatrixColumn< M >::SizeType j)
Returns a mutable column proxy for column j of the matrix expression e.
Definition: MatrixProxy.hpp:1400
MatrixRow< M > row(MatrixExpression< M > &e, typename MatrixRow< M >::SizeType i)
Returns a mutable row proxy for row i of the matrix expression e.
Definition: MatrixProxy.hpp:1372
void vectorSwap(V &v, VectorExpression< E > &e)
Swaps the elements of two equally sized vector expressions element by element.
Definition: VectorAssignment.hpp:97
MatrixRange< E > range(MatrixExpression< E > &e, const typename MatrixRange< E >::RangeType &r1, const typename MatrixRange< E >::RangeType &r2)
Returns a mutable matrix range proxy viewing rows in r1 and columns in r2 of e.
Definition: MatrixProxy.hpp:1429
void matrixSwap(M &m, MatrixExpression< E > &e)
Swaps the elements of two equally sized matrix expressions element by element.
Definition: MatrixAssignment.hpp:101
The namespace of the Chemical Data Processing Library.
Selects a concrete temporary matrix type compatible with the matrix expression M.
Definition: TypeTraits.hpp:337
M::MatrixTemporaryType Type
The concrete temporary matrix type compatible with the matrix expression M.
Definition: TypeTraits.hpp:342
Selects a concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:323