All Classes Namespaces Functions Typedefs Enumerations Pages
index.h
1 /* Copyright (C) 2003-2005 Martin Förg
2 
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact:
18  * martin.o.foerg@googlemail.com
19  *
20  */
21 
22 #ifndef index_h
23 #define index_h
24 
25 #include "matrix.h"
26 
27 namespace fmatvec {
28 
34  class Index {
35  private:
36 
38 
39  int i1, i2;
40 
42 
43  public:
44 
49  inline Index() { i1 = i2 = 0;}
50 
56  inline Index(int i1_) : i1(i1_), i2(i1_) {
57 #ifndef FMATVEC_NO_BOUNDS_CHECK
58  assert(i1>=0);
59 #endif
60  }
61 
68  inline Index(int i1_, int i2_) : i1(i1_), i2(i2_) {
69 #ifndef FMATVEC_NO_BOUNDS_CHECK
70  assert(i1>=0);
71  assert(i2>=i1-1);
72 #endif
73  }
74 
79  int start() const {return i1;}
80 
85  int end() const {return i2;}
86 
91  int size() const {return i2-i1+1;}
92  };
93 
99  bool operator==(const Index &I, const Index &J);
100 
101 }
102 
103 #endif
bool operator==(const Index &I, const Index &J)
Equality operator for indices.
Definition: index.cc:26
Index()
Standard constructor.
Definition: index.h:49
int end() const
Last element.
Definition: index.h:85
int size() const
Size.
Definition: index.h:91
This is an index class for creating submatrices.
Definition: index.h:34
Index(int i1_, int i2_)
Regular constructor.
Definition: index.h:68
int start() const
First element.
Definition: index.h:79
Index(int i1_)
Regular constructor.
Definition: index.h:56

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML