Eigen  3.2.7
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 <[email protected]>
5 // Copyright (C) 2006-2010 Benoit Jacob <[email protected]>
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 
15 typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr;
16 typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr;
18 typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr;
19 typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr;
21 typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr;
22 typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr;
24 typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr;
25 typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr;
27 template<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
28 template<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
30 template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
31 template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
32 
33 typedef VectorBlock<Derived> SegmentReturnType;
34 typedef const VectorBlock<const Derived> ConstSegmentReturnType;
35 template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; };
36 template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; };
37 
38 #endif // not EIGEN_PARSED_BY_DOXYGEN
39 
56 inline Block<Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols)
57 {
58  return Block<Derived>(derived(), startRow, startCol, blockRows, blockCols);
59 }
60 
62 inline const Block<const Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols) const
63 {
64  return Block<const Derived>(derived(), startRow, startCol, blockRows, blockCols);
65 }
66 
67 
68 
69 
80 inline Block<Derived> topRightCorner(Index cRows, Index cCols)
81 {
82  return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
83 }
84 
86 inline const Block<const Derived> topRightCorner(Index cRows, Index cCols) const
87 {
88  return Block<const Derived>(derived(), 0, cols() - cCols, cRows, cCols);
89 }
90 
101 template<int CRows, int CCols>
102 inline Block<Derived, CRows, CCols> topRightCorner()
103 {
104  return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
105 }
106 
108 template<int CRows, int CCols>
109 inline const Block<const Derived, CRows, CCols> topRightCorner() const
110 {
111  return Block<const Derived, CRows, CCols>(derived(), 0, cols() - CCols);
112 }
113 
131 template<int CRows, int CCols>
132 inline Block<Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols)
133 {
134  return Block<Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols);
135 }
136 
138 template<int CRows, int CCols>
139 inline const Block<const Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols) const
140 {
141  return Block<const Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols);
142 }
143 
144 
145 
156 inline Block<Derived> topLeftCorner(Index cRows, Index cCols)
157 {
158  return Block<Derived>(derived(), 0, 0, cRows, cCols);
159 }
160 
162 inline const Block<const Derived> topLeftCorner(Index cRows, Index cCols) const
163 {
164  return Block<const Derived>(derived(), 0, 0, cRows, cCols);
165 }
166 
176 template<int CRows, int CCols>
177 inline Block<Derived, CRows, CCols> topLeftCorner()
178 {
179  return Block<Derived, CRows, CCols>(derived(), 0, 0);
180 }
181 
183 template<int CRows, int CCols>
184 inline const Block<const Derived, CRows, CCols> topLeftCorner() const
185 {
186  return Block<const Derived, CRows, CCols>(derived(), 0, 0);
187 }
188 
206 template<int CRows, int CCols>
207 inline Block<Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols)
208 {
209  return Block<Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols);
210 }
211 
213 template<int CRows, int CCols>
214 inline const Block<const Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols) const
215 {
216  return Block<const Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols);
217 }
218 
219 
220 
231 inline Block<Derived> bottomRightCorner(Index cRows, Index cCols)
232 {
233  return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
234 }
235 
237 inline const Block<const Derived> bottomRightCorner(Index cRows, Index cCols) const
238 {
239  return Block<const Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
240 }
241 
251 template<int CRows, int CCols>
252 inline Block<Derived, CRows, CCols> bottomRightCorner()
253 {
254  return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
255 }
256 
258 template<int CRows, int CCols>
259 inline const Block<const Derived, CRows, CCols> bottomRightCorner() const
260 {
261  return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
262 }
263 
281 template<int CRows, int CCols>
282 inline Block<Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols)
283 {
284  return Block<Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
285 }
286 
288 template<int CRows, int CCols>
289 inline const Block<const Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols) const
290 {
291  return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
292 }
293 
294 
295 
306 inline Block<Derived> bottomLeftCorner(Index cRows, Index cCols)
307 {
308  return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
309 }
310 
312 inline const Block<const Derived> bottomLeftCorner(Index cRows, Index cCols) const
313 {
314  return Block<const Derived>(derived(), rows() - cRows, 0, cRows, cCols);
315 }
316 
326 template<int CRows, int CCols>
327 inline Block<Derived, CRows, CCols> bottomLeftCorner()
328 {
329  return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
330 }
331 
333 template<int CRows, int CCols>
334 inline const Block<const Derived, CRows, CCols> bottomLeftCorner() const
335 {
336  return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, 0);
337 }
338 
356 template<int CRows, int CCols>
357 inline Block<Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols)
358 {
359  return Block<Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols);
360 }
361 
363 template<int CRows, int CCols>
364 inline const Block<const Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols) const
365 {
366  return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols);
367 }
368 
369 
370 
380 inline RowsBlockXpr topRows(Index n)
381 {
382  return RowsBlockXpr(derived(), 0, 0, n, cols());
383 }
384 
386 inline ConstRowsBlockXpr topRows(Index n) const
387 {
388  return ConstRowsBlockXpr(derived(), 0, 0, n, cols());
389 }
390 
404 template<int N>
405 inline typename NRowsBlockXpr<N>::Type topRows(Index n = N)
406 {
407  return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
408 }
409 
411 template<int N>
412 inline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const
413 {
414  return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
415 }
416 
417 
418 
428 inline RowsBlockXpr bottomRows(Index n)
429 {
430  return RowsBlockXpr(derived(), rows() - n, 0, n, cols());
431 }
432 
434 inline ConstRowsBlockXpr bottomRows(Index n) const
435 {
436  return ConstRowsBlockXpr(derived(), rows() - n, 0, n, cols());
437 }
438 
452 template<int N>
453 inline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N)
454 {
455  return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
456 }
457 
459 template<int N>
460 inline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const
461 {
462  return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
463 }
464 
465 
466 
477 inline RowsBlockXpr middleRows(Index startRow, Index n)
478 {
479  return RowsBlockXpr(derived(), startRow, 0, n, cols());
480 }
481 
483 inline ConstRowsBlockXpr middleRows(Index startRow, Index n) const
484 {
485  return ConstRowsBlockXpr(derived(), startRow, 0, n, cols());
486 }
487 
502 template<int N>
503 inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N)
504 {
505  return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
506 }
507 
509 template<int N>
510 inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const
511 {
512  return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
513 }
514 
515 
516 
526 inline ColsBlockXpr leftCols(Index n)
527 {
528  return ColsBlockXpr(derived(), 0, 0, rows(), n);
529 }
530 
532 inline ConstColsBlockXpr leftCols(Index n) const
533 {
534  return ConstColsBlockXpr(derived(), 0, 0, rows(), n);
535 }
536 
550 template<int N>
551 inline typename NColsBlockXpr<N>::Type leftCols(Index n = N)
552 {
553  return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
554 }
555 
557 template<int N>
558 inline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const
559 {
560  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
561 }
562 
563 
564 
574 inline ColsBlockXpr rightCols(Index n)
575 {
576  return ColsBlockXpr(derived(), 0, cols() - n, rows(), n);
577 }
578 
580 inline ConstColsBlockXpr rightCols(Index n) const
581 {
582  return ConstColsBlockXpr(derived(), 0, cols() - n, rows(), n);
583 }
584 
598 template<int N>
599 inline typename NColsBlockXpr<N>::Type rightCols(Index n = N)
600 {
601  return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
602 }
603 
605 template<int N>
606 inline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const
607 {
608  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
609 }
610 
611 
612 
623 inline ColsBlockXpr middleCols(Index startCol, Index numCols)
624 {
625  return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
626 }
627 
629 inline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const
630 {
631  return ConstColsBlockXpr(derived(), 0, startCol, rows(), numCols);
632 }
633 
648 template<int N>
649 inline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N)
650 {
651  return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
652 }
653 
655 template<int N>
656 inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const
657 {
658  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
659 }
660 
661 
662 
679 template<int BlockRows, int BlockCols>
680 inline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol)
681 {
682  return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
683 }
684 
686 template<int BlockRows, int BlockCols>
687 inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol) const
688 {
689  return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
690 }
691 
711 template<int BlockRows, int BlockCols>
712 inline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol,
713  Index blockRows, Index blockCols)
714 {
715  return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol, blockRows, blockCols);
716 }
717 
719 template<int BlockRows, int BlockCols>
720 inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol,
721  Index blockRows, Index blockCols) const
722 {
723  return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol, blockRows, blockCols);
724 }
725 
732 inline ColXpr col(Index i)
733 {
734  return ColXpr(derived(), i);
735 }
736 
738 inline ConstColXpr col(Index i) const
739 {
740  return ConstColXpr(derived(), i);
741 }
742 
749 inline RowXpr row(Index i)
750 {
751  return RowXpr(derived(), i);
752 }
753 
755 inline ConstRowXpr row(Index i) const
756 {
757  return ConstRowXpr(derived(), i);
758 }
759 
776 inline SegmentReturnType segment(Index start, Index n)
777 {
778  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
779  return SegmentReturnType(derived(), start, n);
780 }
781 
782 
784 inline ConstSegmentReturnType segment(Index start, Index n) const
785 {
786  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
787  return ConstSegmentReturnType(derived(), start, n);
788 }
789 
805 inline SegmentReturnType head(Index n)
806 {
807  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
808  return SegmentReturnType(derived(), 0, n);
809 }
810 
812 inline ConstSegmentReturnType head(Index n) const
813 {
814  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
815  return ConstSegmentReturnType(derived(), 0, n);
816 }
817 
833 inline SegmentReturnType tail(Index n)
834 {
835  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
836  return SegmentReturnType(derived(), this->size() - n, n);
837 }
838 
840 inline ConstSegmentReturnType tail(Index n) const
841 {
842  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
843  return ConstSegmentReturnType(derived(), this->size() - n, n);
844 }
845 
862 template<int N>
863 inline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N)
864 {
865  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
866  return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
867 }
868 
870 template<int N>
871 inline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const
872 {
873  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
874  return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);
875 }
876 
892 template<int N>
893 inline typename FixedSegmentReturnType<N>::Type head(Index n = N)
894 {
895  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
896  return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
897 }
898 
900 template<int N>
901 inline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const
902 {
903  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
904  return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
905 }
906 
922 template<int N>
923 inline typename FixedSegmentReturnType<N>::Type tail(Index n = N)
924 {
925  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
926  return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
927 }
928 
930 template<int N>
931 inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const
932 {
933  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
934  return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
935 }
const int Dynamic
Definition: Constants.h:21