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:
59  typedef M MatrixType;
61  typedef typename M::SizeType SizeType;
63  typedef typename M::DifferenceType DifferenceType;
65  typedef typename M::ValueType ValueType;
67  typedef typename M::ConstReference ConstReference;
69  typedef typename std::conditional<std::is_const<M>::value,
70  typename M::ConstReference,
71  typename M::Reference>::type Reference;
73  typedef typename std::conditional<std::is_const<M>::value,
74  typename M::ConstClosureType,
75  typename M::ClosureType>::type MatrixClosureType;
77  typedef const SelfType ConstClosureType;
80 
87  data(m), index(i) {}
88 
95  {
96  return data(index, i);
97  }
98 
105  {
106  return data(index, i);
107  }
108 
115  {
116  return data(index, i);
117  }
118 
125  {
126  return data(index, i);
127  }
128 
134  {
135  return index;
136  }
137 
143  {
144  return data.getSize2();
145  }
146 
151  bool isEmpty() const
152  {
153  return (data.getSize2() == 0);
154  }
155 
161  {
162  return data;
163  }
164 
169  const MatrixClosureType& getData() const
170  {
171  return data;
172  }
173 
180  {
181  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(r));
182  return *this;
183  }
184 
191  template <typename E>
193  {
194  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(e));
195  return *this;
196  }
197 
204  template <typename E>
206  {
207  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(*this + e));
208  return *this;
209  }
210 
217  template <typename E>
219  {
220  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(*this - e));
221  return *this;
222  }
223 
230  template <typename T>
231  typename std::enable_if<IsScalar<T>::value, MatrixRow>::type& operator*=(const T& t)
232  {
233  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
234  return *this;
235  }
236 
243  template <typename T>
244  typename std::enable_if<IsScalar<T>::value, MatrixRow>::type& operator/=(const T& t)
245  {
246  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
247  return *this;
248  }
249 
256  template <typename E>
258  {
259  vectorAssignVector<ScalarAssignment>(*this, e);
260  return *this;
261  }
262 
269  template <typename E>
271  {
272  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
273  return *this;
274  }
275 
282  template <typename E>
284  {
285  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
286  return *this;
287  }
288 
293  void swap(MatrixRow& r)
294  {
295  if (this != &r)
296  vectorSwap(*this, r);
297  }
298 
304  friend void swap(MatrixRow& r1, MatrixRow& r2)
305  {
306  r1.swap(r2);
307  }
308 
309  private:
310  MatrixClosureType data;
311  SizeType index;
312  };
313 
318  template <typename M>
319  class MatrixColumn : public VectorExpression<MatrixColumn<M> >
320  {
321 
322  typedef MatrixColumn<M> SelfType;
323 
324  public:
326  typedef M MatrixType;
328  typedef typename M::SizeType SizeType;
330  typedef typename M::DifferenceType DifferenceType;
332  typedef typename M::ValueType ValueType;
334  typedef typename M::ConstReference ConstReference;
336  typedef typename std::conditional<std::is_const<M>::value,
337  typename M::ConstReference,
338  typename M::Reference>::type Reference;
340  typedef typename std::conditional<std::is_const<M>::value,
341  typename M::ConstClosureType,
342  typename M::ClosureType>::type MatrixClosureType;
344  typedef const SelfType ConstClosureType;
347 
354  data(m), index(i) {}
355 
362  {
363  return data(i, index);
364  }
365 
372  {
373  return data(i, index);
374  }
375 
382  {
383  return data(i, index);
384  }
385 
392  {
393  return data(i, index);
394  }
395 
401  {
402  return index;
403  }
404 
410  {
411  return data.getSize1();
412  }
413 
418  bool isEmpty() const
419  {
420  return (data.getSize1() == 0);
421  }
422 
428  {
429  return data;
430  }
431 
436  const MatrixClosureType& getData() const
437  {
438  return data;
439  }
440 
447  {
448  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(c));
449  return *this;
450  }
451 
458  template <typename E>
460  {
461  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(e));
462  return *this;
463  }
464 
471  template <typename E>
473  {
474  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(*this + e));
475  return *this;
476  }
477 
484  template <typename E>
486  {
487  vectorAssignVector<ScalarAssignment>(*this, typename VectorTemporaryTraits<M>::Type(*this - e));
488  return *this;
489  }
490 
497  template <typename T>
498  typename std::enable_if<IsScalar<T>::value, MatrixColumn>::type& operator*=(const T& t)
499  {
500  vectorAssignScalar<ScalarMultiplicationAssignment>(*this, t);
501  return *this;
502  }
503 
510  template <typename T>
511  typename std::enable_if<IsScalar<T>::value, MatrixColumn>::type& operator/=(const T& t)
512  {
513  vectorAssignScalar<ScalarDivisionAssignment>(*this, t);
514  return *this;
515  }
516 
523  template <typename E>
525  {
526  vectorAssignVector<ScalarAssignment>(*this, e);
527  return *this;
528  }
529 
536  template <typename E>
538  {
539  vectorAssignVector<ScalarAdditionAssignment>(*this, e);
540  return *this;
541  }
542 
549  template <typename E>
551  {
552  vectorAssignVector<ScalarSubtractionAssignment>(*this, e);
553  return *this;
554  }
555 
561  {
562  if (this != &c)
563  vectorSwap(*this, c);
564  }
565 
571  friend void swap(MatrixColumn& c1, MatrixColumn& c2)
572  {
573  c1.swap(c2);
574  }
575 
576  private:
577  MatrixClosureType data;
578  SizeType index;
579  };
580 
585  template <typename M>
586  class MatrixRange : public MatrixExpression<MatrixRange<M> >
587  {
588 
589  typedef MatrixRange<M> SelfType;
590 
591  public:
593  typedef M MatrixType;
595  typedef typename M::SizeType SizeType;
597  typedef typename M::DifferenceType DifferenceType;
599  typedef typename M::ValueType ValueType;
601  typedef typename M::ConstReference ConstReference;
603  typedef typename std::conditional<std::is_const<M>::value,
604  typename M::ConstReference,
605  typename M::Reference>::type Reference;
607  typedef typename std::conditional<std::is_const<M>::value,
608  typename M::ConstClosureType,
609  typename M::ClosureType>::type MatrixClosureType;
611  typedef const SelfType ConstClosureType;
616 
623  MatrixRange(MatrixType& m, const RangeType& r1, const RangeType& r2):
624  data(m), range1(r1), range2(r2) {}
625 
633  {
634  return data(range1(i), range2(j));
635  }
636 
644  {
645  return data(range1(i), range2(j));
646  }
647 
653  {
654  return range1.getStart();
655  }
656 
662  {
663  return range2.getStart();
664  }
665 
671  {
672  return range1.getSize();
673  }
674 
680  {
681  return range2.getSize();
682  }
683 
688  bool isEmpty() const
689  {
690  return (range1.getSize() == SizeType(0) || range2.getSize() == SizeType(0));
691  }
692 
698  {
699  return data;
700  }
701 
706  const MatrixClosureType& getData() const
707  {
708  return data;
709  }
710 
717  {
718  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(r));
719  return *this;
720  }
721 
728  template <typename E>
730  {
731  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(e));
732  return *this;
733  }
734 
741  template <typename E>
743  {
744  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(*this + e));
745  return *this;
746  }
747 
754  template <typename E>
756  {
757  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(*this - e));
758  return *this;
759  }
760 
767  template <typename T>
768  typename std::enable_if<IsScalar<T>::value, MatrixRange>::type& operator*=(const T& t)
769  {
770  matrixAssignScalar<ScalarMultiplicationAssignment>(*this, t);
771  return *this;
772  }
773 
780  template <typename T>
781  typename std::enable_if<IsScalar<T>::value, MatrixRange>::type& operator/=(const T& t)
782  {
783  matrixAssignScalar<ScalarDivisionAssignment>(*this, t);
784  return *this;
785  }
786 
793  template <typename E>
795  {
796  matrixAssignMatrix<ScalarAssignment>(*this, e);
797  return *this;
798  }
799 
806  template <typename E>
808  {
809  matrixAssignMatrix<ScalarAdditionAssignment>(*this, e);
810  return *this;
811  }
812 
819  template <typename E>
821  {
822  matrixAssignMatrix<ScalarSubtractionAssignment>(*this, e);
823  return *this;
824  }
825 
831  {
832  if (this != &r)
833  matrixSwap(*this, r);
834  }
835 
841  friend void swap(MatrixRange& r1, MatrixRange& r2)
842  {
843  r1.swap(r2);
844  }
845 
846  private:
847  MatrixClosureType data;
848  RangeType range1;
849  RangeType range2;
850  };
851 
856  template <typename M>
857  class MatrixSlice : public MatrixExpression<MatrixSlice<M> >
858  {
859 
860  typedef MatrixSlice<M> SelfType;
861 
862  public:
864  typedef M MatrixType;
866  typedef typename M::SizeType SizeType;
868  typedef typename M::DifferenceType DifferenceType;
870  typedef typename M::ValueType ValueType;
872  typedef typename M::ConstReference ConstReference;
874  typedef typename std::conditional<std::is_const<M>::value,
875  typename M::ConstReference,
876  typename M::Reference>::type Reference;
878  typedef typename std::conditional<std::is_const<M>::value,
879  typename M::ConstClosureType,
880  typename M::ClosureType>::type MatrixClosureType;
882  typedef const SelfType ConstClosureType;
887 
894  MatrixSlice(MatrixType& m, const SliceType& s1, const SliceType& s2):
895  data(m), slice1(s1), slice2(s2) {}
896 
904  {
905  return data(slice1(i), slice2(j));
906  }
907 
915  {
916  return data(slice1(i), slice2(j));
917  }
918 
924  {
925  return slice1.getStart();
926  }
927 
933  {
934  return slice2.getStart();
935  }
936 
942  {
943  return slice1.getStride();
944  }
945 
951  {
952  return slice2.getStride();
953  }
954 
960  {
961  return slice1.getSize();
962  }
963 
969  {
970  return slice2.getSize();
971  }
972 
977  bool isEmpty() const
978  {
979  return (slice1.getSize() == SizeType(0) || slice2.getSize() == SizeType(0));
980  }
981 
987  {
988  return data;
989  }
990 
995  const MatrixClosureType& getData() const
996  {
997  return data;
998  }
999 
1006  {
1007  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(s));
1008  return *this;
1009  }
1010 
1017  template <typename E>
1019  {
1020  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(e));
1021  return *this;
1022  }
1023 
1030  template <typename E>
1032  {
1033  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(*this + e));
1034  return *this;
1035  }
1036 
1043  template <typename E>
1045  {
1046  matrixAssignMatrix<ScalarAssignment>(*this, typename MatrixTemporaryTraits<M>::Type(*this - e));
1047  return *this;
1048  }
1049 
1056  template <typename T>
1057  typename std::enable_if<IsScalar<T>::value, MatrixSlice>::type& operator*=(const T& t)
1058  {
1059  matrixAssignScalar<ScalarMultiplicationAssignment>(*this, t);
1060  return *this;
1061  }
1062 
1069  template <typename T>
1070  typename std::enable_if<IsScalar<T>::value, MatrixSlice>::type& operator/=(const T& t)
1071  {
1072  matrixAssignScalar<ScalarDivisionAssignment>(*this, t);
1073  return *this;
1074  }
1075 
1082  template <typename E>
1084  {
1085  matrixAssignMatrix<ScalarAssignment>(*this, e);
1086  return *this;
1087  }
1088 
1095  template <typename E>
1097  {
1098  matrixAssignMatrix<ScalarAdditionAssignment>(*this, e);
1099  return *this;
1100  }
1101 
1108  template <typename E>
1110  {
1111  matrixAssignMatrix<ScalarSubtractionAssignment>(*this, e);
1112  return *this;
1113  }
1114 
1120  {
1121  if (this != &s)
1122  matrixSwap(*this, s);
1123  }
1124 
1130  friend void swap(MatrixSlice& s1, MatrixSlice& s2)
1131  {
1132  s1.swap(s2);
1133  }
1134 
1135  private:
1136  MatrixClosureType data;
1137  SliceType slice1;
1138  SliceType slice2;
1139  };
1140 
1142  template <typename M>
1144  {};
1145 
1147  template <typename M>
1149  {};
1150 
1152  template <typename M>
1154  {};
1155 
1157  template <typename M>
1159  {};
1160 
1162  template <typename M>
1164  {};
1165 
1167  template <typename M>
1169  {};
1170 
1172  template <typename M>
1174  {};
1175 
1177  template <typename M>
1179  {};
1180 
1182  template <typename M>
1184  {};
1185 
1187  template <typename M>
1189  {};
1190 
1192  template <typename M>
1194  {};
1195 
1197  template <typename M>
1199  {};
1200 
1202  template <typename M>
1204  {};
1205 
1207  template <typename M>
1209  {};
1210 
1212  template <typename M>
1214  {};
1215 
1217  template <typename M>
1219  {};
1220 
1228  template <typename M>
1229 
1230  MatrixRow<M>
1232  {
1233  return MatrixRow<M>(e(), i);
1234  }
1235 
1243  template <typename M>
1244  MatrixRow<const M>
1246  {
1247  return MatrixRow<const M>(e(), i);
1248  }
1249 
1257  template <typename M>
1258  MatrixColumn<M>
1260  {
1261  return MatrixColumn<M>(e(), j);
1262  }
1263 
1271  template <typename M>
1272  MatrixColumn<const M>
1274  {
1275  return MatrixColumn<const M>(e(), j);
1276  }
1277 
1286  template <typename E>
1287  MatrixRange<E>
1289  const typename MatrixRange<E>::RangeType& r1,
1290  const typename MatrixRange<E>::RangeType& r2)
1291  {
1292  return MatrixRange<E>(e(), r1, r2);
1293  }
1294 
1303  template <typename E>
1304  MatrixRange<const E>
1306  const typename MatrixRange<const E>::RangeType& r1,
1307  const typename MatrixRange<const E>::RangeType& r2)
1308  {
1309  return MatrixRange<const E>(e(), r1, r2);
1310  }
1311 
1322  template <typename E>
1323  MatrixRange<E>
1325  typename MatrixRange<E>::RangeType::SizeType start1,
1326  typename MatrixRange<E>::RangeType::SizeType stop1,
1327  typename MatrixRange<E>::RangeType::SizeType start2,
1328  typename MatrixRange<E>::RangeType::SizeType stop2)
1329  {
1330  typedef typename MatrixRange<E>::RangeType RangeType;
1331 
1332  return MatrixRange<E>(e(), RangeType(start1, stop1), RangeType(start2, stop2));
1333  }
1334 
1345  template <typename E>
1346  MatrixRange<const E>
1352  {
1353  typedef typename MatrixRange<const E>::RangeType RangeType;
1354 
1355  return MatrixRange<const E>(e(), RangeType(start1, stop1), RangeType(start2, stop2));
1356  }
1357 
1366  template <typename E>
1367  MatrixSlice<E>
1369  const typename MatrixSlice<E>::SliceType& s1,
1370  const typename MatrixSlice<E>::SliceType& s2)
1371  {
1372  return MatrixSlice<E>(e(), s1, s2);
1373  }
1374 
1383  template <typename E>
1384  MatrixSlice<const E>
1386  const typename MatrixSlice<const E>::SliceType& s1,
1387  const typename MatrixSlice<const E>::SliceType& s2)
1388  {
1389  return MatrixSlice<const E>(e(), s1, s2);
1390  }
1391 
1404  template <typename E>
1405  MatrixSlice<E>
1407  typename MatrixSlice<E>::SliceType::SizeType start1,
1409  typename MatrixSlice<E>::SliceType::SizeType size1,
1410  typename MatrixSlice<E>::SliceType::SizeType start2,
1412  typename MatrixSlice<E>::SliceType::SizeType size2)
1413  {
1414  typedef typename MatrixSlice<E>::SliceType SliceType;
1415 
1416  return MatrixSlice<E>(e(), SliceType(start1, stride1, size1), SliceType(start2, stride2, size2));
1417  }
1418 
1431  template <typename E>
1432  MatrixSlice<const E>
1440  {
1441  typedef typename MatrixSlice<const E>::SliceType SliceType;
1442 
1443  return MatrixSlice<const E>(e(), SliceType(start1, stride1, size1), SliceType(start2, stride2, size2));
1444  }
1445  } // namespace Math
1446 } // namespace CDPL
1447 
1448 #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:320
friend void swap(MatrixColumn &c1, MatrixColumn &c2)
ADL-enabled free-function form of swap().
Definition: MatrixProxy.hpp:571
M::ConstReference ConstReference
Constant reference type to an element.
Definition: MatrixProxy.hpp:334
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:472
MatrixColumn & assign(const VectorExpression< E > &e)
Assigns the elements of the vector expression e to this column without intermediate temporary.
Definition: MatrixProxy.hpp:524
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: MatrixProxy.hpp:338
ConstReference operator[](SizeType i) const
Returns a const reference to the element at row i of the column (alias for operator()).
Definition: MatrixProxy.hpp:391
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:498
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:346
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:560
M::SizeType SizeType
The size type used by the wrapped matrix.
Definition: MatrixProxy.hpp:328
MatrixColumn & operator=(const MatrixColumn &c)
Copy-assigns the contents of c to this column (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:446
MatrixColumn & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this column without intermediate temporary.
Definition: MatrixProxy.hpp:537
SizeType getIndex() const
Returns the column index this proxy refers to within the wrapped matrix.
Definition: MatrixProxy.hpp:400
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:459
ConstReference operator()(SizeType i) const
Returns a const reference to the element at row i of the column.
Definition: MatrixProxy.hpp:371
MatrixColumn & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this column without intermediate temporary.
Definition: MatrixProxy.hpp:550
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:344
MatrixColumn(MatrixType &m, SizeType i)
Constructs the column proxy viewing column i of m.
Definition: MatrixProxy.hpp:353
Reference operator[](SizeType i)
Returns a mutable reference to the element at row i of the column (alias for operator()).
Definition: MatrixProxy.hpp:381
M MatrixType
The wrapped matrix type.
Definition: MatrixProxy.hpp:326
M::ValueType ValueType
The element value type of the wrapped matrix.
Definition: MatrixProxy.hpp:332
const MatrixClosureType & getData() const
Returns a const reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:436
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:342
MatrixClosureType & getData()
Returns a reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:427
bool isEmpty() const
Tells whether the column is empty (the wrapped matrix has zero rows).
Definition: MatrixProxy.hpp:418
SizeType getSize() const
Returns the size of the column (number of rows of the wrapped matrix).
Definition: MatrixProxy.hpp:409
M::DifferenceType DifferenceType
The signed difference type used by the wrapped matrix.
Definition: MatrixProxy.hpp:330
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:511
Reference operator()(SizeType i)
Returns a mutable reference to the element at row i of the column.
Definition: MatrixProxy.hpp:361
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:485
CRTP base class for all matrix expression types.
Definition: Expression.hpp:104
Matrix-expression proxy that views a contiguous rectangular subrange of an underlying matrix.
Definition: MatrixProxy.hpp:587
M::SizeType SizeType
The size type used by the wrapped matrix.
Definition: MatrixProxy.hpp:595
MatrixRange & operator=(const MatrixRange &r)
Copy-assigns the contents of r to this matrix range (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:716
const MatrixClosureType & getData() const
Returns a const reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:706
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: MatrixProxy.hpp:605
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:609
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:755
SizeType getStart1() const
Returns the row index range's start index in the wrapped matrix.
Definition: MatrixProxy.hpp:652
SizeType getSize2() const
Returns the number of columns in the proxy (size of the column range).
Definition: MatrixProxy.hpp:679
M MatrixType
The wrapped matrix type.
Definition: MatrixProxy.hpp:593
MatrixRange & assign(const MatrixExpression< E > &e)
Assigns the elements of the matrix expression e to this matrix range without intermediate temporary.
Definition: MatrixProxy.hpp:794
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:742
SizeType getStart2() const
Returns the column index range's start index in the wrapped matrix.
Definition: MatrixProxy.hpp:661
Range< SizeType > RangeType
Range type used to specify the row and column index ranges.
Definition: MatrixProxy.hpp:615
M::ConstReference ConstReference
Constant reference type to an element.
Definition: MatrixProxy.hpp:601
M::ValueType ValueType
The element value type of the wrapped matrix.
Definition: MatrixProxy.hpp:599
friend void swap(MatrixRange &r1, MatrixRange &r2)
ADL-enabled free-function form of swap().
Definition: MatrixProxy.hpp:841
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at proxy index (i, j).
Definition: MatrixProxy.hpp:643
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at proxy index (i, j).
Definition: MatrixProxy.hpp:632
M::DifferenceType DifferenceType
The signed difference type used by the wrapped matrix.
Definition: MatrixProxy.hpp:597
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:613
SizeType getSize1() const
Returns the number of rows in the proxy (size of the row range).
Definition: MatrixProxy.hpp:670
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:830
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:768
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:781
MatrixRange & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix range without intermediate temporary.
Definition: MatrixProxy.hpp:807
bool isEmpty() const
Tells whether the proxy is empty (either range has size zero).
Definition: MatrixProxy.hpp:688
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:729
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:611
MatrixClosureType & getData()
Returns a reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:697
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:623
MatrixRange & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix range without intermediate tempora...
Definition: MatrixProxy.hpp:820
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:179
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: MatrixProxy.hpp:71
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:205
M::DifferenceType DifferenceType
The signed difference type used by the wrapped matrix.
Definition: MatrixProxy.hpp:63
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:75
M MatrixType
The wrapped matrix type.
Definition: MatrixProxy.hpp:59
ConstReference operator[](SizeType i) const
Returns a const reference to the element at column i of the row (alias for operator()).
Definition: MatrixProxy.hpp:124
MatrixRow & assign(const VectorExpression< E > &e)
Assigns the elements of the vector expression e to this row without intermediate temporary.
Definition: MatrixProxy.hpp:257
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:192
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:231
MatrixRow(MatrixType &m, SizeType i)
Constructs the row proxy viewing row i of m.
Definition: MatrixProxy.hpp:86
const MatrixClosureType & getData() const
Returns a const reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:169
M::ConstReference ConstReference
Constant reference type to an element.
Definition: MatrixProxy.hpp:67
SizeType getSize() const
Returns the size of the row (number of columns of the wrapped matrix).
Definition: MatrixProxy.hpp:142
ConstReference operator()(SizeType i) const
Returns a const reference to the element at column i of the row.
Definition: MatrixProxy.hpp:104
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:218
M::SizeType SizeType
The size type used by the wrapped matrix.
Definition: MatrixProxy.hpp:61
Reference operator()(SizeType i)
Returns a mutable reference to the element at column i of the row.
Definition: MatrixProxy.hpp:94
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:293
SizeType getIndex() const
Returns the row index this proxy refers to within the wrapped matrix.
Definition: MatrixProxy.hpp:133
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:77
M::ValueType ValueType
The element value type of the wrapped matrix.
Definition: MatrixProxy.hpp:65
MatrixRow & minusAssign(const VectorExpression< E > &e)
Subtracts the elements of the vector expression e from this row without intermediate temporary.
Definition: MatrixProxy.hpp:283
friend void swap(MatrixRow &r1, MatrixRow &r2)
ADL-enabled free-function form of swap().
Definition: MatrixProxy.hpp:304
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:79
MatrixClosureType & getData()
Returns a reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:160
bool isEmpty() const
Tells whether the row is empty (the wrapped matrix has zero columns).
Definition: MatrixProxy.hpp:151
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:244
MatrixRow & plusAssign(const VectorExpression< E > &e)
Adds the elements of the vector expression e to this row without intermediate temporary.
Definition: MatrixProxy.hpp:270
Reference operator[](SizeType i)
Returns a mutable reference to the element at column i of the row (alias for operator()).
Definition: MatrixProxy.hpp:114
Matrix-expression proxy that views a strided rectangular slice of an underlying matrix.
Definition: MatrixProxy.hpp:858
const SelfType ConstClosureType
Constant closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:882
SizeType getSize2() const
Returns the number of columns in the proxy (size of the column slice).
Definition: MatrixProxy.hpp:968
MatrixSlice & operator=(const MatrixSlice &s)
Copy-assigns the contents of s to this matrix slice (via a temporary to handle aliasing).
Definition: MatrixProxy.hpp:1005
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:1044
MatrixClosureType & getData()
Returns a reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:986
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:1057
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:1018
MatrixSlice & assign(const MatrixExpression< E > &e)
Assigns the elements of the matrix expression e to this matrix slice without intermediate temporary.
Definition: MatrixProxy.hpp:1083
SizeType getStart2() const
Returns the column slice's start index in the wrapped matrix.
Definition: MatrixProxy.hpp:932
Slice< SizeType, DifferenceType > SliceType
Slice type used to specify the row and column slices (start, stride, size).
Definition: MatrixProxy.hpp:886
friend void swap(MatrixSlice &s1, MatrixSlice &s2)
ADL-enabled free-function form of swap().
Definition: MatrixProxy.hpp:1130
M::DifferenceType DifferenceType
The signed difference type used by the wrapped matrix.
Definition: MatrixProxy.hpp:868
const MatrixClosureType & getData() const
Returns a const reference to the wrapped matrix (via its stored closure).
Definition: MatrixProxy.hpp:995
M MatrixType
The wrapped matrix type.
Definition: MatrixProxy.hpp:864
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:894
Reference operator()(SizeType i, SizeType j)
Returns a mutable reference to the element at proxy index (i, j).
Definition: MatrixProxy.hpp:903
M::ConstReference ConstReference
Constant reference type to an element.
Definition: MatrixProxy.hpp:872
MatrixSlice & plusAssign(const MatrixExpression< E > &e)
Adds the elements of the matrix expression e to this matrix slice without intermediate temporary.
Definition: MatrixProxy.hpp:1096
M::ValueType ValueType
The element value type of the wrapped matrix.
Definition: MatrixProxy.hpp:870
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:1119
M::SizeType SizeType
The size type used by the wrapped matrix.
Definition: MatrixProxy.hpp:866
bool isEmpty() const
Tells whether the proxy is empty (either slice has size zero).
Definition: MatrixProxy.hpp:977
DifferenceType getStride1() const
Returns the row slice's stride in the wrapped matrix.
Definition: MatrixProxy.hpp:941
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:880
SizeType getSize1() const
Returns the number of rows in the proxy (size of the row slice).
Definition: MatrixProxy.hpp:959
SizeType getStart1() const
Returns the row slice's start index in the wrapped matrix.
Definition: MatrixProxy.hpp:923
DifferenceType getStride2() const
Returns the column slice's stride in the wrapped matrix.
Definition: MatrixProxy.hpp:950
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:1031
MatrixSlice & minusAssign(const MatrixExpression< E > &e)
Subtracts the elements of the matrix expression e from this matrix slice without intermediate tempora...
Definition: MatrixProxy.hpp:1109
ConstReference operator()(SizeType i, SizeType j) const
Returns a const reference to the element at proxy index (i, j).
Definition: MatrixProxy.hpp:914
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:1070
std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
Mutable reference type (degrades to ConstReference when the wrapped matrix is const).
Definition: MatrixProxy.hpp:876
SelfType ClosureType
Closure type used when this proxy appears inside another expression.
Definition: MatrixProxy.hpp:884
SizeType getStart() const
Returns the lower (inclusive) bound.
Definition: Range.hpp:91
SizeType getSize() const
Returns the size of the range, .
Definition: Range.hpp:109
SizeType SizeType
The integral size/index type.
Definition: Range.hpp:55
SizeType SizeType
The integral size/index type.
Definition: Slice.hpp:60
SizeType getStart() const
Returns the starting global index.
Definition: Slice.hpp:99
SizeType getSize() const
Returns the number of entries in the slice.
Definition: Slice.hpp:117
DifferenceType getStride() const
Returns the signed step size between consecutive entries.
Definition: Slice.hpp:108
DifferenceType DifferenceType
The signed difference type used for the stride.
Definition: Slice.hpp:62
CRTP base class for all vector expression types.
Definition: Expression.hpp:66
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:1368
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:1259
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:1231
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:1288
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:313
M::MatrixTemporaryType Type
The concrete temporary matrix type compatible with the matrix expression M.
Definition: TypeTraits.hpp:316
Selects a concrete temporary vector type compatible with the vector expression V.
Definition: TypeTraits.hpp:301