Eigen  3.3.0
 
Loading...
Searching...
No Matches
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
14typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr;
15typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr;
17typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr;
18typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr;
20typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr;
21typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr;
23typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr;
24typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr;
26template<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
27template<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
29template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
30template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
32typedef Block<Derived> BlockXpr;
33typedef const Block<const Derived> ConstBlockXpr;
35template<int Rows, int Cols> struct FixedBlockXpr { typedef Block<Derived,Rows,Cols> Type; };
36template<int Rows, int Cols> struct ConstFixedBlockXpr { typedef Block<const Derived,Rows,Cols> Type; };
37
38typedef VectorBlock<Derived> SegmentReturnType;
39typedef const VectorBlock<const Derived> ConstSegmentReturnType;
40template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; };
41template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; };
42
43#endif // not EIGEN_PARSED_BY_DOXYGEN
44
59EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
63EIGEN_DEVICE_FUNC
64inline BlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols)
65{
66 return BlockXpr(derived(), startRow, startCol, blockRows, blockCols);
67}
68
70EIGEN_DEVICE_FUNC
71inline const ConstBlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols) const
72{
73 return ConstBlockXpr(derived(), startRow, startCol, blockRows, blockCols);
74}
75
76
77
78
87EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
91EIGEN_DEVICE_FUNC
92inline BlockXpr topRightCorner(Index cRows, Index cCols)
93{
94 return BlockXpr(derived(), 0, cols() - cCols, cRows, cCols);
95}
96
98EIGEN_DEVICE_FUNC
99inline const ConstBlockXpr topRightCorner(Index cRows, Index cCols) const
100{
101 return ConstBlockXpr(derived(), 0, cols() - cCols, cRows, cCols);
102}
103
112EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
116template<int CRows, int CCols>
117EIGEN_DEVICE_FUNC
118inline typename FixedBlockXpr<CRows,CCols>::Type topRightCorner()
119{
120 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
121}
122
124template<int CRows, int CCols>
125EIGEN_DEVICE_FUNC
126inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner() const
127{
128 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
129}
130
146EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
150template<int CRows, int CCols>
151inline typename FixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols)
152{
153 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);
154}
155
157template<int CRows, int CCols>
158inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols) const
159{
160 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);
161}
162
163
164
173EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
177EIGEN_DEVICE_FUNC
178inline BlockXpr topLeftCorner(Index cRows, Index cCols)
179{
180 return BlockXpr(derived(), 0, 0, cRows, cCols);
181}
182
184EIGEN_DEVICE_FUNC
185inline const ConstBlockXpr topLeftCorner(Index cRows, Index cCols) const
186{
187 return ConstBlockXpr(derived(), 0, 0, cRows, cCols);
188}
189
197EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
201template<int CRows, int CCols>
202EIGEN_DEVICE_FUNC
203inline typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner()
204{
205 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
206}
207
209template<int CRows, int CCols>
210EIGEN_DEVICE_FUNC
211inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner() const
212{
213 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
214}
215
231EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
235template<int CRows, int CCols>
236inline typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols)
237{
238 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);
239}
240
242template<int CRows, int CCols>
243inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols) const
244{
245 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);
246}
247
248
249
258EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
262EIGEN_DEVICE_FUNC
263inline BlockXpr bottomRightCorner(Index cRows, Index cCols)
264{
265 return BlockXpr(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
266}
267
269EIGEN_DEVICE_FUNC
270inline const ConstBlockXpr bottomRightCorner(Index cRows, Index cCols) const
271{
272 return ConstBlockXpr(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
273}
274
282EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
286template<int CRows, int CCols>
287EIGEN_DEVICE_FUNC
288inline typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner()
289{
290 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);
291}
292
294template<int CRows, int CCols>
295EIGEN_DEVICE_FUNC
296inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner() const
297{
298 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);
299}
300
316EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
320template<int CRows, int CCols>
321inline typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols)
322{
323 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
324}
325
327template<int CRows, int CCols>
328inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols) const
329{
330 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
331}
332
333
334
343EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
347EIGEN_DEVICE_FUNC
348inline BlockXpr bottomLeftCorner(Index cRows, Index cCols)
349{
350 return BlockXpr(derived(), rows() - cRows, 0, cRows, cCols);
351}
352
354EIGEN_DEVICE_FUNC
355inline const ConstBlockXpr bottomLeftCorner(Index cRows, Index cCols) const
356{
357 return ConstBlockXpr(derived(), rows() - cRows, 0, cRows, cCols);
358}
359
367EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
371template<int CRows, int CCols>
372EIGEN_DEVICE_FUNC
373inline typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner()
374{
375 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
376}
377
379template<int CRows, int CCols>
380EIGEN_DEVICE_FUNC
381inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner() const
382{
383 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
384}
385
401EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
405template<int CRows, int CCols>
406inline typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols)
407{
408 return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);
409}
410
412template<int CRows, int CCols>
413inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols) const
414{
415 return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);
416}
417
418
419
427EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)
431EIGEN_DEVICE_FUNC
432inline RowsBlockXpr topRows(Index n)
433{
434 return RowsBlockXpr(derived(), 0, 0, n, cols());
435}
436
438EIGEN_DEVICE_FUNC
439inline ConstRowsBlockXpr topRows(Index n) const
440{
441 return ConstRowsBlockXpr(derived(), 0, 0, n, cols());
442}
443
455EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)
459template<int N>
460EIGEN_DEVICE_FUNC
461inline typename NRowsBlockXpr<N>::Type topRows(Index n = N)
462{
463 return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
464}
465
467template<int N>
468EIGEN_DEVICE_FUNC
469inline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const
470{
471 return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
472}
473
474
475
483EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)
487EIGEN_DEVICE_FUNC
488inline RowsBlockXpr bottomRows(Index n)
489{
490 return RowsBlockXpr(derived(), rows() - n, 0, n, cols());
491}
492
494EIGEN_DEVICE_FUNC
495inline ConstRowsBlockXpr bottomRows(Index n) const
496{
497 return ConstRowsBlockXpr(derived(), rows() - n, 0, n, cols());
498}
499
511EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)
515template<int N>
516EIGEN_DEVICE_FUNC
517inline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N)
518{
519 return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
520}
521
523template<int N>
524EIGEN_DEVICE_FUNC
525inline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const
526{
527 return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
528}
529
530
531
540EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)
544EIGEN_DEVICE_FUNC
545inline RowsBlockXpr middleRows(Index startRow, Index n)
546{
547 return RowsBlockXpr(derived(), startRow, 0, n, cols());
548}
549
551EIGEN_DEVICE_FUNC
552inline ConstRowsBlockXpr middleRows(Index startRow, Index n) const
553{
554 return ConstRowsBlockXpr(derived(), startRow, 0, n, cols());
555}
556
569EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)
573template<int N>
574EIGEN_DEVICE_FUNC
575inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N)
576{
577 return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
578}
579
581template<int N>
582EIGEN_DEVICE_FUNC
583inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const
584{
585 return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
586}
587
588
589
597EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)
601EIGEN_DEVICE_FUNC
602inline ColsBlockXpr leftCols(Index n)
603{
604 return ColsBlockXpr(derived(), 0, 0, rows(), n);
605}
606
608EIGEN_DEVICE_FUNC
609inline ConstColsBlockXpr leftCols(Index n) const
610{
611 return ConstColsBlockXpr(derived(), 0, 0, rows(), n);
612}
613
625EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)
629template<int N>
630EIGEN_DEVICE_FUNC
631inline typename NColsBlockXpr<N>::Type leftCols(Index n = N)
632{
633 return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
634}
635
637template<int N>
638EIGEN_DEVICE_FUNC
639inline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const
640{
641 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
642}
643
644
645
653EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)
657EIGEN_DEVICE_FUNC
658inline ColsBlockXpr rightCols(Index n)
659{
660 return ColsBlockXpr(derived(), 0, cols() - n, rows(), n);
661}
662
664EIGEN_DEVICE_FUNC
665inline ConstColsBlockXpr rightCols(Index n) const
666{
667 return ConstColsBlockXpr(derived(), 0, cols() - n, rows(), n);
668}
669
681EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)
685template<int N>
686EIGEN_DEVICE_FUNC
687inline typename NColsBlockXpr<N>::Type rightCols(Index n = N)
688{
689 return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
690}
691
693template<int N>
694EIGEN_DEVICE_FUNC
695inline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const
696{
697 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
698}
699
700
701
710EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)
714EIGEN_DEVICE_FUNC
715inline ColsBlockXpr middleCols(Index startCol, Index numCols)
716{
717 return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
718}
719
721EIGEN_DEVICE_FUNC
722inline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const
723{
724 return ConstColsBlockXpr(derived(), 0, startCol, rows(), numCols);
725}
726
739EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)
743template<int N>
744EIGEN_DEVICE_FUNC
745inline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N)
746{
747 return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
748}
749
751template<int N>
752EIGEN_DEVICE_FUNC
753inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const
754{
755 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
756}
757
758
759
774EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
778template<int NRows, int NCols>
779EIGEN_DEVICE_FUNC
780inline typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol)
781{
782 return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
783}
784
786template<int NRows, int NCols>
787EIGEN_DEVICE_FUNC
788inline const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol) const
789{
790 return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
791}
792
810EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
814template<int NRows, int NCols>
815inline typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol,
816 Index blockRows, Index blockCols)
817{
818 return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);
819}
820
822template<int NRows, int NCols>
823inline const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol,
824 Index blockRows, Index blockCols) const
825{
826 return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);
827}
828
834EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(column-major)
837EIGEN_DEVICE_FUNC
838inline ColXpr col(Index i)
839{
840 return ColXpr(derived(), i);
841}
842
844EIGEN_DEVICE_FUNC
845inline ConstColXpr col(Index i) const
846{
847 return ConstColXpr(derived(), i);
848}
849
855EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(row-major)
858EIGEN_DEVICE_FUNC
859inline RowXpr row(Index i)
860{
861 return RowXpr(derived(), i);
862}
863
865EIGEN_DEVICE_FUNC
866inline ConstRowXpr row(Index i) const
867{
868 return ConstRowXpr(derived(), i);
869}
870
887EIGEN_DEVICE_FUNC
888inline SegmentReturnType segment(Index start, Index n)
889{
890 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
891 return SegmentReturnType(derived(), start, n);
892}
893
894
896EIGEN_DEVICE_FUNC
897inline ConstSegmentReturnType segment(Index start, Index n) const
898{
899 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
900 return ConstSegmentReturnType(derived(), start, n);
901}
902
918EIGEN_DEVICE_FUNC
919inline SegmentReturnType head(Index n)
920{
921 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
922 return SegmentReturnType(derived(), 0, n);
923}
924
926EIGEN_DEVICE_FUNC
927inline ConstSegmentReturnType head(Index n) const
928{
929 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
930 return ConstSegmentReturnType(derived(), 0, n);
931}
932
948EIGEN_DEVICE_FUNC
949inline SegmentReturnType tail(Index n)
950{
951 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
952 return SegmentReturnType(derived(), this->size() - n, n);
953}
954
956EIGEN_DEVICE_FUNC
957inline ConstSegmentReturnType tail(Index n) const
958{
959 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
960 return ConstSegmentReturnType(derived(), this->size() - n, n);
961}
962
979template<int N>
980EIGEN_DEVICE_FUNC
981inline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N)
982{
983 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
984 return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
985}
986
988template<int N>
989EIGEN_DEVICE_FUNC
990inline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const
991{
992 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
993 return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);
994}
995
1011template<int N>
1012EIGEN_DEVICE_FUNC
1013inline typename FixedSegmentReturnType<N>::Type head(Index n = N)
1014{
1015 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
1016 return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
1017}
1018
1020template<int N>
1021EIGEN_DEVICE_FUNC
1022inline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const
1023{
1024 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
1025 return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
1026}
1027
1043template<int N>
1044EIGEN_DEVICE_FUNC
1045inline typename FixedSegmentReturnType<N>::Type tail(Index n = N)
1046{
1047 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
1048 return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
1049}
1050
1052template<int N>
1053EIGEN_DEVICE_FUNC
1054inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const
1055{
1056 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
1057 return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
1058}
const int Dynamic
Definition: Constants.h:21