All Classes Namespaces Functions Typedefs Enumerations Pages
range.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 range_h
23 #define range_h
24 
25 //#include "matrix.h"
26 #include "types.h"
27 
28 namespace fmatvec {
29 
35  template <class Row, class Col> class Range {
36  private:
37  };
38 
44  template <> class Range<Var, Var> {
45  private:
46 
48 
49  int i1, i2;
50 
52 
53  public:
54 
59  inline Range() { i1 = i2 = 0;}
60 
66  inline Range(int i1_) : i1(i1_), i2(i1_) {
67 #ifndef FMATVEC_NO_BOUNDS_CHECK
68  assert(i1>=0);
69 #endif
70  }
71 
78  inline Range(int i1_, int i2_) : i1(i1_), i2(i2_) {
79 #ifndef FMATVEC_NO_BOUNDS_CHECK
80  assert(i1>=0);
81  assert(i2>=i1-1);
82 #endif
83  }
84 
89  int start() const {return i1;}
90 
95  int end() const {return i2;}
96 
101  int size() const {return i2-i1+1;}
102  };
103 
104 
110  template <int I1, int I2> class Range<Fixed<I1>, Fixed<I2> > {
111  private:
112 
113  public:
114 
119  int start() const {return I1;}
120 
125  int end() const {return I2;}
126  };
127 
133  inline bool operator==(const Range<Var,Var> &I, const Range<Var,Var> &J) {
134  if(I.start() == J.start() && I.end() == J.end())
135  return true;
136  else
137  return false;
138  }
139 
140  typedef Range<Var,Var> Index;
141 
142 }
143 
144 #endif
Definition: types.h:68
Definition: types.h:65
bool operator==(const Index &I, const Index &J)
Equality operator for indices.
Definition: index.cc:26
int end() const
Last element.
Definition: range.h:125
int start() const
First element.
Definition: range.h:119
Range(int i1_, int i2_)
Regular constructor.
Definition: range.h:78
This is an index class for creating submatrices.
Definition: range.h:35
int size() const
Size.
Definition: range.h:101
Range()
Standard constructor.
Definition: range.h:59
int end() const
Last element.
Definition: range.h:95
Range(int i1_)
Regular constructor.
Definition: range.h:66
This is an index class for creating submatrices.
Definition: range.h:44
int start() const
First element.
Definition: range.h:89

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML