index.h
00001 /* Copyright (C) 2003-2005  Martin Förg
00002 
00003  * This library is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU Lesser General Public
00005  * License as published by the Free Software Foundation; either
00006  * version 2.1 of the License, or (at your option) any later version.
00007  * 
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Lesser General Public License for more details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public
00014  * License along with this library; if not, write to the Free Software
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00016  *
00017  * Contact:
00018  *   martin.o.foerg@googlemail.com
00019  *
00020  */
00021 
00022 #ifndef index_h
00023 #define index_h
00024 
00025 #include "matrix.h"
00026 
00027 namespace fmatvec {
00028 
00034   class Index {
00035     private:
00036       
00038 
00039     int i1, i2;
00040 
00042 
00043     public:
00044 
00049       inline Index() { i1 = i2 = 0;}
00050 
00056       inline Index(int i1_) : i1(i1_), i2(i1_) { 
00057 #ifndef FMATVEC_NO_BOUNDS_CHECK
00058         assert(i1>=0);
00059 #endif
00060       }
00061 
00068       inline Index(int i1_, int i2_) : i1(i1_), i2(i2_) {
00069 #ifndef FMATVEC_NO_BOUNDS_CHECK
00070         assert(i1>=0);
00071         assert(i2>=i1-1);
00072 #endif
00073       }
00074 
00079       int start() const {return i1;}
00080 
00085       int end() const {return i2;}
00086 
00091       int size() const {return i2-i1+1;}
00092   };
00093 
00099   bool operator==(const Index &I, const Index &J);
00100 
00101 }
00102 
00103 #endif