MOAB  4.9.3pre
BlockMethods.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008-2010 Gael Guennebaud <[email protected]>
00005 // Copyright (C) 2006-2010 Benoit Jacob <[email protected]>
00006 //
00007 // This Source Code Form is subject to the terms of the Mozilla
00008 // Public License v. 2.0. If a copy of the MPL was not distributed
00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00010 
00011 #ifndef EIGEN_PARSED_BY_DOXYGEN
00012 
00014 typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr;
00015 typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr;
00017 typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr;
00018 typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr;
00020 typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr;
00021 typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr;
00023 typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr;
00024 typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr;
00026 template<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
00027 template<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
00029 template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
00030 template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
00032 typedef Block<Derived> BlockXpr;
00033 typedef const Block<const Derived> ConstBlockXpr;
00035 template<int Rows, int Cols> struct FixedBlockXpr { typedef Block<Derived,Rows,Cols> Type; };
00036 template<int Rows, int Cols> struct ConstFixedBlockXpr { typedef Block<const Derived,Rows,Cols> Type; };
00037 
00038 typedef VectorBlock<Derived> SegmentReturnType;
00039 typedef const VectorBlock<const Derived> ConstSegmentReturnType;
00040 template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; };
00041 template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; };
00042 
00043 #endif // not EIGEN_PARSED_BY_DOXYGEN
00044 
00061 EIGEN_DEVICE_FUNC
00062 inline BlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols)
00063 {
00064   return BlockXpr(derived(), startRow, startCol, blockRows, blockCols);
00065 }
00066 
00068 EIGEN_DEVICE_FUNC
00069 inline const ConstBlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols) const
00070 {
00071   return ConstBlockXpr(derived(), startRow, startCol, blockRows, blockCols);
00072 }
00073 
00074 
00075 
00076 
00087 EIGEN_DEVICE_FUNC
00088 inline BlockXpr topRightCorner(Index cRows, Index cCols)
00089 {
00090   return BlockXpr(derived(), 0, cols() - cCols, cRows, cCols);
00091 }
00092 
00094 EIGEN_DEVICE_FUNC
00095 inline const ConstBlockXpr topRightCorner(Index cRows, Index cCols) const
00096 {
00097   return ConstBlockXpr(derived(), 0, cols() - cCols, cRows, cCols);
00098 }
00099 
00110 template<int CRows, int CCols>
00111 EIGEN_DEVICE_FUNC
00112 inline typename FixedBlockXpr<CRows,CCols>::Type topRightCorner()
00113 {
00114   return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
00115 }
00116 
00118 template<int CRows, int CCols>
00119 EIGEN_DEVICE_FUNC
00120 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner() const
00121 {
00122   return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - CCols);
00123 }
00124 
00142 template<int CRows, int CCols>
00143 inline typename FixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols)
00144 {
00145   return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);
00146 }
00147 
00149 template<int CRows, int CCols>
00150 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topRightCorner(Index cRows, Index cCols) const
00151 {
00152   return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, cols() - cCols, cRows, cCols);
00153 }
00154 
00155 
00156 
00167 EIGEN_DEVICE_FUNC
00168 inline BlockXpr topLeftCorner(Index cRows, Index cCols)
00169 {
00170   return BlockXpr(derived(), 0, 0, cRows, cCols);
00171 }
00172 
00174 EIGEN_DEVICE_FUNC
00175 inline const ConstBlockXpr topLeftCorner(Index cRows, Index cCols) const
00176 {
00177   return ConstBlockXpr(derived(), 0, 0, cRows, cCols);
00178 }
00179 
00189 template<int CRows, int CCols>
00190 EIGEN_DEVICE_FUNC
00191 inline typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner()
00192 {
00193   return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
00194 }
00195 
00197 template<int CRows, int CCols>
00198 EIGEN_DEVICE_FUNC
00199 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner() const
00200 {
00201   return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0);
00202 }
00203 
00221 template<int CRows, int CCols>
00222 inline typename FixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols)
00223 {
00224   return typename FixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);
00225 }
00226 
00228 template<int CRows, int CCols>
00229 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type topLeftCorner(Index cRows, Index cCols) const
00230 {
00231   return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), 0, 0, cRows, cCols);
00232 }
00233 
00234 
00235 
00246 EIGEN_DEVICE_FUNC
00247 inline BlockXpr bottomRightCorner(Index cRows, Index cCols)
00248 {
00249   return BlockXpr(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
00250 }
00251 
00253 EIGEN_DEVICE_FUNC
00254 inline const ConstBlockXpr bottomRightCorner(Index cRows, Index cCols) const
00255 {
00256   return ConstBlockXpr(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
00257 }
00258 
00268 template<int CRows, int CCols>
00269 EIGEN_DEVICE_FUNC
00270 inline typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner()
00271 {
00272   return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);
00273 }
00274 
00276 template<int CRows, int CCols>
00277 EIGEN_DEVICE_FUNC
00278 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner() const
00279 {
00280   return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, cols() - CCols);
00281 }
00282 
00300 template<int CRows, int CCols>
00301 inline typename FixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols)
00302 {
00303   return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
00304 }
00305 
00307 template<int CRows, int CCols>
00308 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomRightCorner(Index cRows, Index cCols) const
00309 {
00310   return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
00311 }
00312 
00313 
00314 
00325 EIGEN_DEVICE_FUNC
00326 inline BlockXpr bottomLeftCorner(Index cRows, Index cCols)
00327 {
00328   return BlockXpr(derived(), rows() - cRows, 0, cRows, cCols);
00329 }
00330 
00332 EIGEN_DEVICE_FUNC
00333 inline const ConstBlockXpr bottomLeftCorner(Index cRows, Index cCols) const
00334 {
00335   return ConstBlockXpr(derived(), rows() - cRows, 0, cRows, cCols);
00336 }
00337 
00347 template<int CRows, int CCols>
00348 EIGEN_DEVICE_FUNC
00349 inline typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner()
00350 {
00351   return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
00352 }
00353 
00355 template<int CRows, int CCols>
00356 EIGEN_DEVICE_FUNC
00357 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner() const
00358 {
00359   return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - CRows, 0);
00360 }
00361 
00379 template<int CRows, int CCols>
00380 inline typename FixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols)
00381 {
00382   return typename FixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);
00383 }
00384 
00386 template<int CRows, int CCols>
00387 inline const typename ConstFixedBlockXpr<CRows,CCols>::Type bottomLeftCorner(Index cRows, Index cCols) const
00388 {
00389   return typename ConstFixedBlockXpr<CRows,CCols>::Type(derived(), rows() - cRows, 0, cRows, cCols);
00390 }
00391 
00392 
00393 
00403 EIGEN_DEVICE_FUNC
00404 inline RowsBlockXpr topRows(Index n)
00405 {
00406   return RowsBlockXpr(derived(), 0, 0, n, cols());
00407 }
00408 
00410 EIGEN_DEVICE_FUNC
00411 inline ConstRowsBlockXpr topRows(Index n) const
00412 {
00413   return ConstRowsBlockXpr(derived(), 0, 0, n, cols());
00414 }
00415 
00429 template<int N>
00430 EIGEN_DEVICE_FUNC
00431 inline typename NRowsBlockXpr<N>::Type topRows(Index n = N)
00432 {
00433   return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
00434 }
00435 
00437 template<int N>
00438 EIGEN_DEVICE_FUNC
00439 inline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const
00440 {
00441   return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
00442 }
00443 
00444 
00445 
00455 EIGEN_DEVICE_FUNC
00456 inline RowsBlockXpr bottomRows(Index n)
00457 {
00458   return RowsBlockXpr(derived(), rows() - n, 0, n, cols());
00459 }
00460 
00462 EIGEN_DEVICE_FUNC
00463 inline ConstRowsBlockXpr bottomRows(Index n) const
00464 {
00465   return ConstRowsBlockXpr(derived(), rows() - n, 0, n, cols());
00466 }
00467 
00481 template<int N>
00482 EIGEN_DEVICE_FUNC
00483 inline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N)
00484 {
00485   return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
00486 }
00487 
00489 template<int N>
00490 EIGEN_DEVICE_FUNC
00491 inline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const
00492 {
00493   return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
00494 }
00495 
00496 
00497 
00508 EIGEN_DEVICE_FUNC
00509 inline RowsBlockXpr middleRows(Index startRow, Index n)
00510 {
00511   return RowsBlockXpr(derived(), startRow, 0, n, cols());
00512 }
00513 
00515 EIGEN_DEVICE_FUNC
00516 inline ConstRowsBlockXpr middleRows(Index startRow, Index n) const
00517 {
00518   return ConstRowsBlockXpr(derived(), startRow, 0, n, cols());
00519 }
00520 
00535 template<int N>
00536 EIGEN_DEVICE_FUNC
00537 inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N)
00538 {
00539   return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
00540 }
00541 
00543 template<int N>
00544 EIGEN_DEVICE_FUNC
00545 inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const
00546 {
00547   return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
00548 }
00549 
00550 
00551 
00561 EIGEN_DEVICE_FUNC
00562 inline ColsBlockXpr leftCols(Index n)
00563 {
00564   return ColsBlockXpr(derived(), 0, 0, rows(), n);
00565 }
00566 
00568 EIGEN_DEVICE_FUNC
00569 inline ConstColsBlockXpr leftCols(Index n) const
00570 {
00571   return ConstColsBlockXpr(derived(), 0, 0, rows(), n);
00572 }
00573 
00587 template<int N>
00588 EIGEN_DEVICE_FUNC
00589 inline typename NColsBlockXpr<N>::Type leftCols(Index n = N)
00590 {
00591   return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
00592 }
00593 
00595 template<int N>
00596 EIGEN_DEVICE_FUNC
00597 inline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const
00598 {
00599   return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
00600 }
00601 
00602 
00603 
00613 EIGEN_DEVICE_FUNC
00614 inline ColsBlockXpr rightCols(Index n)
00615 {
00616   return ColsBlockXpr(derived(), 0, cols() - n, rows(), n);
00617 }
00618 
00620 EIGEN_DEVICE_FUNC
00621 inline ConstColsBlockXpr rightCols(Index n) const
00622 {
00623   return ConstColsBlockXpr(derived(), 0, cols() - n, rows(), n);
00624 }
00625 
00639 template<int N>
00640 EIGEN_DEVICE_FUNC
00641 inline typename NColsBlockXpr<N>::Type rightCols(Index n = N)
00642 {
00643   return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
00644 }
00645 
00647 template<int N>
00648 EIGEN_DEVICE_FUNC
00649 inline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const
00650 {
00651   return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
00652 }
00653 
00654 
00655 
00666 EIGEN_DEVICE_FUNC
00667 inline ColsBlockXpr middleCols(Index startCol, Index numCols)
00668 {
00669   return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
00670 }
00671 
00673 EIGEN_DEVICE_FUNC
00674 inline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const
00675 {
00676   return ConstColsBlockXpr(derived(), 0, startCol, rows(), numCols);
00677 }
00678 
00693 template<int N>
00694 EIGEN_DEVICE_FUNC
00695 inline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N)
00696 {
00697   return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
00698 }
00699 
00701 template<int N>
00702 EIGEN_DEVICE_FUNC
00703 inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const
00704 {
00705   return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
00706 }
00707 
00708 
00709 
00726 template<int NRows, int NCols>
00727 EIGEN_DEVICE_FUNC
00728 inline typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol)
00729 {
00730   return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
00731 }
00732 
00734 template<int NRows, int NCols>
00735 EIGEN_DEVICE_FUNC
00736 inline const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol) const
00737 {
00738   return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol);
00739 }
00740 
00760 template<int NRows, int NCols>
00761 inline typename FixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol,
00762                                                   Index blockRows, Index blockCols)
00763 {
00764   return typename FixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);
00765 }
00766 
00768 template<int NRows, int NCols>
00769 inline const typename ConstFixedBlockXpr<NRows,NCols>::Type block(Index startRow, Index startCol,
00770                                                               Index blockRows, Index blockCols) const
00771 {
00772   return typename ConstFixedBlockXpr<NRows,NCols>::Type(derived(), startRow, startCol, blockRows, blockCols);
00773 }
00774 
00781 EIGEN_DEVICE_FUNC
00782 inline ColXpr col(Index i)
00783 {
00784   return ColXpr(derived(), i);
00785 }
00786 
00788 EIGEN_DEVICE_FUNC
00789 inline ConstColXpr col(Index i) const
00790 {
00791   return ConstColXpr(derived(), i);
00792 }
00793 
00800 EIGEN_DEVICE_FUNC
00801 inline RowXpr row(Index i)
00802 {
00803   return RowXpr(derived(), i);
00804 }
00805 
00807 EIGEN_DEVICE_FUNC
00808 inline ConstRowXpr row(Index i) const
00809 {
00810   return ConstRowXpr(derived(), i);
00811 }
00812 
00829 EIGEN_DEVICE_FUNC
00830 inline SegmentReturnType segment(Index start, Index n)
00831 {
00832   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00833   return SegmentReturnType(derived(), start, n);
00834 }
00835 
00836 
00838 EIGEN_DEVICE_FUNC
00839 inline ConstSegmentReturnType segment(Index start, Index n) const
00840 {
00841   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00842   return ConstSegmentReturnType(derived(), start, n);
00843 }
00844 
00860 EIGEN_DEVICE_FUNC
00861 inline SegmentReturnType head(Index n)
00862 {
00863   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00864   return SegmentReturnType(derived(), 0, n);
00865 }
00866 
00868 EIGEN_DEVICE_FUNC
00869 inline ConstSegmentReturnType head(Index n) const
00870 {
00871   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00872   return ConstSegmentReturnType(derived(), 0, n);
00873 }
00874 
00890 EIGEN_DEVICE_FUNC
00891 inline SegmentReturnType tail(Index n)
00892 {
00893   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00894   return SegmentReturnType(derived(), this->size() - n, n);
00895 }
00896 
00898 EIGEN_DEVICE_FUNC
00899 inline ConstSegmentReturnType tail(Index n) const
00900 {
00901   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00902   return ConstSegmentReturnType(derived(), this->size() - n, n);
00903 }
00904 
00921 template<int N>
00922 EIGEN_DEVICE_FUNC
00923 inline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N)
00924 {
00925   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00926   return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
00927 }
00928 
00930 template<int N>
00931 EIGEN_DEVICE_FUNC
00932 inline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const
00933 {
00934   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00935   return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);
00936 }
00937 
00953 template<int N>
00954 EIGEN_DEVICE_FUNC
00955 inline typename FixedSegmentReturnType<N>::Type head(Index n = N)
00956 {
00957   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00958   return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
00959 }
00960 
00962 template<int N>
00963 EIGEN_DEVICE_FUNC
00964 inline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const
00965 {
00966   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00967   return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
00968 }
00969 
00985 template<int N>
00986 EIGEN_DEVICE_FUNC
00987 inline typename FixedSegmentReturnType<N>::Type tail(Index n = N)
00988 {
00989   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00990   return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
00991 }
00992 
00994 template<int N>
00995 EIGEN_DEVICE_FUNC
00996 inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const
00997 {
00998   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00999   return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
01000 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines