Medial Code Documentation
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
12#ifndef EIGEN_PARSED_BY_DOXYGEN
13
15typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr;
16typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr;
18typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr;
19typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr;
21typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr;
22typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr;
24typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr;
25typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr;
27template<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
28template<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
30template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
31template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
32
33typedef VectorBlock<Derived> SegmentReturnType;
34typedef const VectorBlock<const Derived> ConstSegmentReturnType;
35template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; };
36template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; };
37
38#endif // not EIGEN_PARSED_BY_DOXYGEN
39
56EIGEN_DEVICE_FUNC
57inline Block<Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols)
58{
59 return Block<Derived>(derived(), startRow, startCol, blockRows, blockCols);
60}
61
63EIGEN_DEVICE_FUNC
64inline const Block<const Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols) const
65{
66 return Block<const Derived>(derived(), startRow, startCol, blockRows, blockCols);
67}
68
69
70
71
82EIGEN_DEVICE_FUNC
83inline Block<Derived> topRightCorner(Index cRows, Index cCols)
84{
85 return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
86}
87
89EIGEN_DEVICE_FUNC
90inline const Block<const Derived> topRightCorner(Index cRows, Index cCols) const
91{
92 return Block<const Derived>(derived(), 0, cols() - cCols, cRows, cCols);
93}
94
105template<int CRows, int CCols>
106EIGEN_DEVICE_FUNC
107inline Block<Derived, CRows, CCols> topRightCorner()
108{
109 return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
110}
111
113template<int CRows, int CCols>
114EIGEN_DEVICE_FUNC
115inline const Block<const Derived, CRows, CCols> topRightCorner() const
116{
117 return Block<const Derived, CRows, CCols>(derived(), 0, cols() - CCols);
118}
119
137template<int CRows, int CCols>
138inline Block<Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols)
139{
140 return Block<Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols);
141}
142
144template<int CRows, int CCols>
145inline const Block<const Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols) const
146{
147 return Block<const Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols);
148}
149
150
151
162EIGEN_DEVICE_FUNC
163inline Block<Derived> topLeftCorner(Index cRows, Index cCols)
164{
165 return Block<Derived>(derived(), 0, 0, cRows, cCols);
166}
167
169EIGEN_DEVICE_FUNC
170inline const Block<const Derived> topLeftCorner(Index cRows, Index cCols) const
171{
172 return Block<const Derived>(derived(), 0, 0, cRows, cCols);
173}
174
184template<int CRows, int CCols>
185EIGEN_DEVICE_FUNC
186inline Block<Derived, CRows, CCols> topLeftCorner()
187{
188 return Block<Derived, CRows, CCols>(derived(), 0, 0);
189}
190
192template<int CRows, int CCols>
193EIGEN_DEVICE_FUNC
194inline const Block<const Derived, CRows, CCols> topLeftCorner() const
195{
196 return Block<const Derived, CRows, CCols>(derived(), 0, 0);
197}
198
216template<int CRows, int CCols>
217inline Block<Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols)
218{
219 return Block<Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols);
220}
221
223template<int CRows, int CCols>
224inline const Block<const Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols) const
225{
226 return Block<const Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols);
227}
228
229
230
241EIGEN_DEVICE_FUNC
242inline Block<Derived> bottomRightCorner(Index cRows, Index cCols)
243{
244 return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
245}
246
248EIGEN_DEVICE_FUNC
249inline const Block<const Derived> bottomRightCorner(Index cRows, Index cCols) const
250{
251 return Block<const Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
252}
253
263template<int CRows, int CCols>
264EIGEN_DEVICE_FUNC
265inline Block<Derived, CRows, CCols> bottomRightCorner()
266{
267 return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
268}
269
271template<int CRows, int CCols>
272EIGEN_DEVICE_FUNC
273inline const Block<const Derived, CRows, CCols> bottomRightCorner() const
274{
275 return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
276}
277
295template<int CRows, int CCols>
296inline Block<Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols)
297{
298 return Block<Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
299}
300
302template<int CRows, int CCols>
303inline const Block<const Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols) const
304{
305 return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
306}
307
308
309
320EIGEN_DEVICE_FUNC
321inline Block<Derived> bottomLeftCorner(Index cRows, Index cCols)
322{
323 return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
324}
325
327EIGEN_DEVICE_FUNC
328inline const Block<const Derived> bottomLeftCorner(Index cRows, Index cCols) const
329{
330 return Block<const Derived>(derived(), rows() - cRows, 0, cRows, cCols);
331}
332
342template<int CRows, int CCols>
343EIGEN_DEVICE_FUNC
344inline Block<Derived, CRows, CCols> bottomLeftCorner()
345{
346 return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
347}
348
350template<int CRows, int CCols>
351EIGEN_DEVICE_FUNC
352inline const Block<const Derived, CRows, CCols> bottomLeftCorner() const
353{
354 return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, 0);
355}
356
374template<int CRows, int CCols>
375inline Block<Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols)
376{
377 return Block<Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols);
378}
379
381template<int CRows, int CCols>
382inline const Block<const Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols) const
383{
384 return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols);
385}
386
387
388
398EIGEN_DEVICE_FUNC
399inline RowsBlockXpr topRows(Index n)
400{
401 return RowsBlockXpr(derived(), 0, 0, n, cols());
402}
403
405EIGEN_DEVICE_FUNC
406inline ConstRowsBlockXpr topRows(Index n) const
407{
408 return ConstRowsBlockXpr(derived(), 0, 0, n, cols());
409}
410
424template<int N>
425EIGEN_DEVICE_FUNC
426inline typename NRowsBlockXpr<N>::Type topRows(Index n = N)
427{
428 return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
429}
430
432template<int N>
433EIGEN_DEVICE_FUNC
434inline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const
435{
436 return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
437}
438
439
440
450EIGEN_DEVICE_FUNC
451inline RowsBlockXpr bottomRows(Index n)
452{
453 return RowsBlockXpr(derived(), rows() - n, 0, n, cols());
454}
455
457EIGEN_DEVICE_FUNC
458inline ConstRowsBlockXpr bottomRows(Index n) const
459{
460 return ConstRowsBlockXpr(derived(), rows() - n, 0, n, cols());
461}
462
476template<int N>
477EIGEN_DEVICE_FUNC
478inline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N)
479{
480 return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
481}
482
484template<int N>
485EIGEN_DEVICE_FUNC
486inline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const
487{
488 return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
489}
490
491
492
503EIGEN_DEVICE_FUNC
504inline RowsBlockXpr middleRows(Index startRow, Index n)
505{
506 return RowsBlockXpr(derived(), startRow, 0, n, cols());
507}
508
510EIGEN_DEVICE_FUNC
511inline ConstRowsBlockXpr middleRows(Index startRow, Index n) const
512{
513 return ConstRowsBlockXpr(derived(), startRow, 0, n, cols());
514}
515
530template<int N>
531EIGEN_DEVICE_FUNC
532inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N)
533{
534 return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
535}
536
538template<int N>
539EIGEN_DEVICE_FUNC
540inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const
541{
542 return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
543}
544
545
546
556EIGEN_DEVICE_FUNC
557inline ColsBlockXpr leftCols(Index n)
558{
559 return ColsBlockXpr(derived(), 0, 0, rows(), n);
560}
561
563EIGEN_DEVICE_FUNC
564inline ConstColsBlockXpr leftCols(Index n) const
565{
566 return ConstColsBlockXpr(derived(), 0, 0, rows(), n);
567}
568
582template<int N>
583EIGEN_DEVICE_FUNC
584inline typename NColsBlockXpr<N>::Type leftCols(Index n = N)
585{
586 return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
587}
588
590template<int N>
591EIGEN_DEVICE_FUNC
592inline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const
593{
594 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
595}
596
597
598
608EIGEN_DEVICE_FUNC
609inline ColsBlockXpr rightCols(Index n)
610{
611 return ColsBlockXpr(derived(), 0, cols() - n, rows(), n);
612}
613
615EIGEN_DEVICE_FUNC
616inline ConstColsBlockXpr rightCols(Index n) const
617{
618 return ConstColsBlockXpr(derived(), 0, cols() - n, rows(), n);
619}
620
634template<int N>
635EIGEN_DEVICE_FUNC
636inline typename NColsBlockXpr<N>::Type rightCols(Index n = N)
637{
638 return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
639}
640
642template<int N>
643EIGEN_DEVICE_FUNC
644inline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const
645{
646 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
647}
648
649
650
661EIGEN_DEVICE_FUNC
662inline ColsBlockXpr middleCols(Index startCol, Index numCols)
663{
664 return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
665}
666
668EIGEN_DEVICE_FUNC
669inline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const
670{
671 return ConstColsBlockXpr(derived(), 0, startCol, rows(), numCols);
672}
673
688template<int N>
689EIGEN_DEVICE_FUNC
690inline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N)
691{
692 return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
693}
694
696template<int N>
697EIGEN_DEVICE_FUNC
698inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const
699{
700 return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
701}
702
703
704
721template<int BlockRows, int BlockCols>
722EIGEN_DEVICE_FUNC
723inline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol)
724{
725 return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
726}
727
729template<int BlockRows, int BlockCols>
730EIGEN_DEVICE_FUNC
731inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol) const
732{
733 return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
734}
735
755template<int BlockRows, int BlockCols>
756inline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol,
757 Index blockRows, Index blockCols)
758{
759 return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol, blockRows, blockCols);
760}
761
763template<int BlockRows, int BlockCols>
764inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol,
765 Index blockRows, Index blockCols) const
766{
767 return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol, blockRows, blockCols);
768}
769
776EIGEN_DEVICE_FUNC
777inline ColXpr col(Index i)
778{
779 return ColXpr(derived(), i);
780}
781
783EIGEN_DEVICE_FUNC
784inline ConstColXpr col(Index i) const
785{
786 return ConstColXpr(derived(), i);
787}
788
795EIGEN_DEVICE_FUNC
796inline RowXpr row(Index i)
797{
798 return RowXpr(derived(), i);
799}
800
802EIGEN_DEVICE_FUNC
803inline ConstRowXpr row(Index i) const
804{
805 return ConstRowXpr(derived(), i);
806}
807
824EIGEN_DEVICE_FUNC
825inline SegmentReturnType segment(Index start, Index n)
826{
827 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
828 return SegmentReturnType(derived(), start, n);
829}
830
831
833EIGEN_DEVICE_FUNC
834inline ConstSegmentReturnType segment(Index start, Index n) const
835{
836 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
837 return ConstSegmentReturnType(derived(), start, n);
838}
839
855EIGEN_DEVICE_FUNC
856inline SegmentReturnType head(Index n)
857{
858 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
859 return SegmentReturnType(derived(), 0, n);
860}
861
863EIGEN_DEVICE_FUNC
864inline ConstSegmentReturnType head(Index n) const
865{
866 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
867 return ConstSegmentReturnType(derived(), 0, n);
868}
869
885EIGEN_DEVICE_FUNC
886inline SegmentReturnType tail(Index n)
887{
888 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
889 return SegmentReturnType(derived(), this->size() - n, n);
890}
891
893EIGEN_DEVICE_FUNC
894inline ConstSegmentReturnType tail(Index n) const
895{
896 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
897 return ConstSegmentReturnType(derived(), this->size() - n, n);
898}
899
916template<int N>
917EIGEN_DEVICE_FUNC
918inline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N)
919{
920 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
921 return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
922}
923
925template<int N>
926EIGEN_DEVICE_FUNC
927inline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const
928{
929 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
930 return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);
931}
932
948template<int N>
949EIGEN_DEVICE_FUNC
950inline typename FixedSegmentReturnType<N>::Type head(Index n = N)
951{
952 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
953 return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
954}
955
957template<int N>
958EIGEN_DEVICE_FUNC
959inline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const
960{
961 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
962 return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
963}
964
980template<int N>
981EIGEN_DEVICE_FUNC
982inline typename FixedSegmentReturnType<N>::Type tail(Index n = N)
983{
984 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
985 return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
986}
987
989template<int N>
990EIGEN_DEVICE_FUNC
991inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const
992{
993 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
994 return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
995}
Definition BlockMethods.h:36
Definition BlockMethods.h:28
Definition BlockMethods.h:31
Definition BlockMethods.h:35
Definition BlockMethods.h:27
Definition BlockMethods.h:30