Eigen  3.2.93
BlockMethods.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_PARSED_BY_DOXYGEN
12 
14 typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr;
15 typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr;
17 typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr;
18 typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr;
20 typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr;
21 typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr;
23 typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr;
24 typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr;
26 template<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
27 template<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
29 template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
30 template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
32 typedef Block<Derived> BlockXpr;
33 typedef const Block<const Derived> ConstBlockXpr;
35 template<int Rows, int Cols> struct FixedBlockXpr { typedef Block<Derived,Rows,Cols> Type; };
36 template<int Rows, int Cols> struct ConstFixedBlockXpr { typedef Block<const Derived,Rows,Cols> Type; };
37 
38 typedef VectorBlock<Derived> SegmentReturnType;
39 typedef const VectorBlock<const Derived> ConstSegmentReturnType;
40 template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; };
41 template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; };
42 
43 #endif // not EIGEN_PARSED_BY_DOXYGEN
44 
61 EIGEN_DEVICE_FUNC
62 inline BlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols)
63 {
64  return BlockXpr(derived(), startRow, startCol, blockRows, blockCols);
65 }
66 
68 EIGEN_DEVICE_FUNC
69 inline const ConstBlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols) const
70 {
71  return ConstBlockXpr(derived(), startRow, startCol, blockRows, blockCols);
72 }
73 
74 
75 
76 
87 EIGEN_DEVICE_FUNC
88 inline BlockXpr topRightCorner(Index cRows, Index cCols)
89 {
90  return BlockXpr(derived(), 0, cols() - cCols, cRows, cCols);
91 }
92 
94 EIGEN_DEVICE_FUNC
95 inline const ConstBlockXpr topRightCorner(Index cRows, Index cCols) const
96 {
97  return ConstBlockXpr(derived(), 0, cols() - cCols, cRows, cCols);
98 }
99 
110 template<int CRows, int CCols>
111 EIGEN_DEVICE_FUNC
112 inline typename FixedBlockXpr<CRows,CCols>::Type topRightCorner()
113 {
114  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
115 }
116 
118 template<int CRows, int CCols>
119 EIGEN_DEVICE_FUNC
120 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner() const
121 {
122  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
123 }
124 
142 template<int CRows, int CCols>
143 inline typename FixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols)
144 {
145  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);
146 }
147 
149 template<int CRows, int CCols>
150 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols) const
151 {
152  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);
153 }
154 
155 
156 
167 EIGEN_DEVICE_FUNC
168 inline BlockXpr topLeftCorner(Index cRows, Index cCols)
169 {
170  return BlockXpr(derived(), 0, 0, cRows, cCols);
171 }
172 
174 EIGEN_DEVICE_FUNC
175 inline const ConstBlockXpr topLeftCorner(Index cRows, Index cCols) const
176 {
177  return ConstBlockXpr(derived(), 0, 0, cRows, cCols);
178 }
179 
189 template<int CRows, int CCols>
190 EIGEN_DEVICE_FUNC
191 inline typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner()
192 {
193  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
194 }
195 
197 template<int CRows, int CCols>
198 EIGEN_DEVICE_FUNC
199 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner() const
200 {
201  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
202 }
203 
221 template<int CRows, int CCols>
222 inline typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols)
223 {
224  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);
225 }
226 
228 template<int CRows, int CCols>
229 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols) const
230 {
231  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);
232 }
233 
234 
235 
246 EIGEN_DEVICE_FUNC
247 inline BlockXpr bottomRightCorner(Index cRows, Index cCols)
248 {
249  return BlockXpr(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
250 }
251 
253 EIGEN_DEVICE_FUNC
254 inline const ConstBlockXpr bottomRightCorner(Index cRows, Index cCols) const
255 {
256  return ConstBlockXpr(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
257 }
258 
268 template<int CRows, int CCols>
269 EIGEN_DEVICE_FUNC
270 inline typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner()
271 {
272  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);
273 }
274 
276 template<int CRows, int CCols>
277 EIGEN_DEVICE_FUNC
278 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner() const
279 {
280  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);
281 }
282 
300 template<int CRows, int CCols>
301 inline typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols)
302 {
303  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
304 }
305 
307 template<int CRows, int CCols>
308 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols) const
309 {
310  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
311 }
312 
313 
314 
325 EIGEN_DEVICE_FUNC
326 inline BlockXpr bottomLeftCorner(Index cRows, Index cCols)
327 {
328  return BlockXpr(derived(), rows() - cRows, 0, cRows, cCols);
329 }
330 
332 EIGEN_DEVICE_FUNC
333 inline const ConstBlockXpr bottomLeftCorner(Index cRows, Index cCols) const
334 {
335  return ConstBlockXpr(derived(), rows() - cRows, 0, cRows, cCols);
336 }
337 
347 template<int CRows, int CCols>
348 EIGEN_DEVICE_FUNC
349 inline typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner()
350 {
351  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
352 }
353 
355 template<int CRows, int CCols>
356 EIGEN_DEVICE_FUNC
357 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner() const
358 {
359  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
360 }
361 
379 template<int CRows, int CCols>
380 inline typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols)
381 {
382  return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);
383 }
384 
386 template<int CRows, int CCols>
387 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols) const
388 {
389  return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);
390 }
391 
392 
393 
403 EIGEN_DEVICE_FUNC
404 inline RowsBlockXpr topRows(Index n)
405 {
406  return RowsBlockXpr(derived(), 0, 0, n, cols());
407 }
408 
410 EIGEN_DEVICE_FUNC
411 inline ConstRowsBlockXpr topRows(Index n) const
412 {
413  return ConstRowsBlockXpr(derived(), 0, 0, n, cols());
414 }
415 
429 template<int N>
430 EIGEN_DEVICE_FUNC
431 inline typename NRowsBlockXpr<N>::Type topRows(Index n = N)
432 {
433  return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
434 }
435 
437 template<int N>
438 EIGEN_DEVICE_FUNC
439 inline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const
440 {
441  return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
442 }
443 
444 
445 
455 EIGEN_DEVICE_FUNC
456 inline RowsBlockXpr bottomRows(Index n)
457 {
458  return RowsBlockXpr(derived(), rows() - n, 0, n, cols());
459 }
460 
462 EIGEN_DEVICE_FUNC
463 inline ConstRowsBlockXpr bottomRows(Index n) const
464 {
465  return ConstRowsBlockXpr(derived(), rows() - n, 0, n, cols());
466 }
467 
481 template<int N>
482 EIGEN_DEVICE_FUNC
483 inline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N)
484 {
485  return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
486 }
487 
489 template<int N>
490 EIGEN_DEVICE_FUNC
491 inline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const
492 {
493  return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
494 }
495 
496 
497 
508 EIGEN_DEVICE_FUNC
509 inline RowsBlockXpr middleRows(Index startRow, Index n)
510 {
511  return RowsBlockXpr(derived(), startRow, 0, n, cols());
512 }
513 
515 EIGEN_DEVICE_FUNC
516 inline ConstRowsBlockXpr middleRows(Index startRow, Index n) const
517 {
518  return ConstRowsBlockXpr(derived(), startRow, 0, n, cols());
519 }
520 
535 template<int N>
536 EIGEN_DEVICE_FUNC
537 inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N)
538 {
539  return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
540 }
541 
543 template<int N>
544 EIGEN_DEVICE_FUNC
545 inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const
546 {
547  return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
548 }
549 
550 
551 
561 EIGEN_DEVICE_FUNC
562 inline ColsBlockXpr leftCols(Index n)
563 {
564  return ColsBlockXpr(derived(), 0, 0, rows(), n);
565 }
566 
568 EIGEN_DEVICE_FUNC
569 inline ConstColsBlockXpr leftCols(Index n) const
570 {
571  return ConstColsBlockXpr(derived(), 0, 0, rows(), n);
572 }
573 
587 template<int N>
588 EIGEN_DEVICE_FUNC
589 inline typename NColsBlockXpr<N>::Type leftCols(Index n = N)
590 {
591  return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
592 }
593 
595 template<int N>
596 EIGEN_DEVICE_FUNC
597 inline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const
598 {
599  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
600 }
601 
602 
603 
613 EIGEN_DEVICE_FUNC
614 inline ColsBlockXpr rightCols(Index n)
615 {
616  return ColsBlockXpr(derived(), 0, cols() - n, rows(), n);
617 }
618 
620 EIGEN_DEVICE_FUNC
621 inline ConstColsBlockXpr rightCols(Index n) const
622 {
623  return ConstColsBlockXpr(derived(), 0, cols() - n, rows(), n);
624 }
625 
639 template<int N>
640 EIGEN_DEVICE_FUNC
641 inline typename NColsBlockXpr<N>::Type rightCols(Index n = N)
642 {
643  return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
644 }
645 
647 template<int N>
648 EIGEN_DEVICE_FUNC
649 inline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const
650 {
651  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
652 }
653 
654 
655 
666 EIGEN_DEVICE_FUNC
667 inline ColsBlockXpr middleCols(Index startCol, Index numCols)
668 {
669  return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
670 }
671 
673 EIGEN_DEVICE_FUNC
674 inline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const
675 {
676  return ConstColsBlockXpr(derived(), 0, startCol, rows(), numCols);
677 }
678 
693 template<int N>
694 EIGEN_DEVICE_FUNC
695 inline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N)
696 {
697  return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
698 }
699 
701 template<int N>
702 EIGEN_DEVICE_FUNC
703 inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const
704 {
705  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
706 }
707 
708 
709 
726 template<int NRows, int NCols>
727 EIGEN_DEVICE_FUNC
728 inline typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol)
729 {
730  return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
731 }
732 
734 template<int NRows, int NCols>
735 EIGEN_DEVICE_FUNC
736 inline const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol) const
737 {
738  return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
739 }
740 
760 template<int NRows, int NCols>
761 inline typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol,
762  Index blockRows, Index blockCols)
763 {
764  return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);
765 }
766 
768 template<int NRows, int NCols>
769 inline const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol,
770  Index blockRows, Index blockCols) const
771 {
772  return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);
773 }
774 
781 EIGEN_DEVICE_FUNC
782 inline ColXpr col(Index i)
783 {
784  return ColXpr(derived(), i);
785 }
786 
788 EIGEN_DEVICE_FUNC
789 inline ConstColXpr col(Index i) const
790 {
791  return ConstColXpr(derived(), i);
792 }
793 
800 EIGEN_DEVICE_FUNC
801 inline RowXpr row(Index i)
802 {
803  return RowXpr(derived(), i);
804 }
805 
807 EIGEN_DEVICE_FUNC
808 inline ConstRowXpr row(Index i) const
809 {
810  return ConstRowXpr(derived(), i);
811 }
812 
829 EIGEN_DEVICE_FUNC
830 inline SegmentReturnType segment(Index start, Index n)
831 {
832  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
833  return SegmentReturnType(derived(), start, n);
834 }
835 
836 
838 EIGEN_DEVICE_FUNC
839 inline ConstSegmentReturnType segment(Index start, Index n) const
840 {
841  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
842  return ConstSegmentReturnType(derived(), start, n);
843 }
844 
860 EIGEN_DEVICE_FUNC
861 inline SegmentReturnType head(Index n)
862 {
863  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
864  return SegmentReturnType(derived(), 0, n);
865 }
866 
868 EIGEN_DEVICE_FUNC
869 inline ConstSegmentReturnType head(Index n) const
870 {
871  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
872  return ConstSegmentReturnType(derived(), 0, n);
873 }
874 
890 EIGEN_DEVICE_FUNC
891 inline SegmentReturnType tail(Index n)
892 {
893  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
894  return SegmentReturnType(derived(), this->size() - n, n);
895 }
896 
898 EIGEN_DEVICE_FUNC
899 inline ConstSegmentReturnType tail(Index n) const
900 {
901  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
902  return ConstSegmentReturnType(derived(), this->size() - n, n);
903 }
904 
921 template<int N>
922 EIGEN_DEVICE_FUNC
923 inline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N)
924 {
925  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
926  return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
927 }
928 
930 template<int N>
931 EIGEN_DEVICE_FUNC
932 inline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const
933 {
934  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
935  return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);
936 }
937 
953 template<int N>
954 EIGEN_DEVICE_FUNC
955 inline typename FixedSegmentReturnType<N>::Type head(Index n = N)
956 {
957  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
958  return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
959 }
960 
962 template<int N>
963 EIGEN_DEVICE_FUNC
964 inline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const
965 {
966  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
967  return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
968 }
969 
985 template<int N>
986 EIGEN_DEVICE_FUNC
987 inline typename FixedSegmentReturnType<N>::Type tail(Index n = N)
988 {
989  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
990  return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
991 }
992 
994 template<int N>
995 EIGEN_DEVICE_FUNC
996 inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const
997 {
998  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
999  return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
1000 }
const int Dynamic
Definition: Constants.h:21