Block.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-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
00006 //
00007 // Eigen is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public
00009 // License as published by the Free Software Foundation; either
00010 // version 3 of the License, or (at your option) any later version.
00011 //
00012 // Alternatively, you can redistribute it and/or
00013 // modify it under the terms of the GNU General Public License as
00014 // published by the Free Software Foundation; either version 2 of
00015 // the License, or (at your option) any later version.
00016 //
00017 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00018 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00019 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00020 // GNU General Public License for more details.
00021 //
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License and a copy of the GNU General Public License along with
00024 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00025 
00026 #ifndef EIGEN_BLOCK2_H
00027 #define EIGEN_BLOCK2_H
00028 
00045 template<typename Derived>
00046 inline Block<Derived> DenseBase<Derived>
00047   ::corner(CornerType type, Index cRows, Index cCols)
00048 {
00049   switch(type)
00050   {
00051     default:
00052       eigen_assert(false && "Bad corner type.");
00053     case TopLeft:
00054       return Block<Derived>(derived(), 0, 0, cRows, cCols);
00055     case TopRight:
00056       return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
00057     case BottomLeft:
00058       return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
00059     case BottomRight:
00060       return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
00061   }
00062 }
00063 
00065 template<typename Derived>
00066 inline const Block<Derived>
00067 DenseBase<Derived>::corner(CornerType type, Index cRows, Index cCols) const
00068 {
00069   switch(type)
00070   {
00071     default:
00072       eigen_assert(false && "Bad corner type.");
00073     case TopLeft:
00074       return Block<Derived>(derived(), 0, 0, cRows, cCols);
00075     case TopRight:
00076       return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
00077     case BottomLeft:
00078       return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
00079     case BottomRight:
00080       return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
00081   }
00082 }
00083 
00096 template<typename Derived>
00097 template<int CRows, int CCols>
00098 inline Block<Derived, CRows, CCols>
00099 DenseBase<Derived>::corner(CornerType type)
00100 {
00101   switch(type)
00102   {
00103     default:
00104       eigen_assert(false && "Bad corner type.");
00105     case TopLeft:
00106       return Block<Derived, CRows, CCols>(derived(), 0, 0);
00107     case TopRight:
00108       return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
00109     case BottomLeft:
00110       return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
00111     case BottomRight:
00112       return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
00113   }
00114 }
00115 
00117 template<typename Derived>
00118 template<int CRows, int CCols>
00119 inline const Block<Derived, CRows, CCols>
00120 DenseBase<Derived>::corner(CornerType type) const
00121 {
00122   switch(type)
00123   {
00124     default:
00125       eigen_assert(false && "Bad corner type.");
00126     case TopLeft:
00127       return Block<Derived, CRows, CCols>(derived(), 0, 0);
00128     case TopRight:
00129       return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
00130     case BottomLeft:
00131       return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
00132     case BottomRight:
00133       return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
00134   }
00135 }
00136 
00137 #endif // EIGEN_BLOCK2_H


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:30:48