fmatvec  0.0.0
Fast Matrix/Vector Library
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  assert(i1>=0);
68  }
69 
76  inline Range(int i1_, int i2_) : i1(i1_), i2(i2_) {
77  assert(i1>=0);
78  //assert(i2>=i1-1);
79  }
80 
85  int start() const {return i1;}
86 
91  int end() const {return i2;}
92 
97  int size() const {return i2-i1+1;}
98  };
99 
100 
106  template <int I1, int I2> class Range<Fixed<I1>, Fixed<I2>> {
107  private:
108 
109  public:
110 
115  int start() const {return I1;}
116 
121  int end() const {return I2;}
122  };
123 
129  inline bool operator==(const Range<Var,Var> &I, const Range<Var,Var> &J) {
130  if(I.start() == J.start() && I.end() == J.end())
131  return true;
132  else
133  return false;
134  }
135 
136 }
137 
138 #endif
int end() const
Last element.
Definition: range.h:91
Definition: fmatvec.h:38
Definition: types.h:97
int start() const
First element.
Definition: range.h:115
int start() const
First element.
Definition: range.h:85
Range(int i1_, int i2_)
Regular constructor.
Definition: range.h:76
This is an index class for creating submatrices.
Definition: range.h:35
Namespace fmatvec.
Definition: _memory.cc:28
bool operator==(const Matrix< Type1, Row1, Col1, AT > &A, const Matrix< Type2, Row2, Col2, AT > &B)
Matrix-matrix comparison.
Definition: linear_algebra.h:1512
int size() const
Size.
Definition: range.h:97
Range()
Standard constructor.
Definition: range.h:59
Range(int i1_)
Regular constructor.
Definition: range.h:66
int end() const
Last element.
Definition: range.h:121
This is an index class for creating submatrices.
Definition: range.h:44