fmatvec  0.0.0
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 #include <cassert>
28 
29 namespace fmatvec {
30 
36  template <class Row, class Col> class Range {
37  private:
38  };
39 
45  template <> class Range<Var, Var> {
46  private:
47 
49 
50  int i1, i2;
51 
53 
54  public:
55 
60  inline Range() { i1 = i2 = 0;}
61 
67  inline Range(int i1_) : i1(i1_), i2(i1_) {
68  assert(i1>=0);
69  }
70 
77  inline Range(int i1_, int i2_) : i1(i1_), i2(i2_) {
78  assert(i1>=0);
79  //assert(i2>=i1-1);
80  }
81 
86  int start() const {return i1;}
87 
92  int end() const {return i2;}
93 
98  int size() const {return i2-i1+1;}
99  };
100 
101 
107  template <int I1, int I2> class Range<Fixed<I1>, Fixed<I2>> {
108  private:
109 
110  public:
111 
116  int start() const {return I1;}
117 
122  int end() const {return I2;}
123  };
124 
130  inline bool operator==(const Range<Var,Var> &I, const Range<Var,Var> &J) {
131  if(I.start() == J.start() && I.end() == J.end())
132  return true;
133  else
134  return false;
135  }
136 
137 }
138 
139 #endif
int end() const
Last element.
Definition: range.h:92
Definition: fmatvec.h:39
Definition: types.h:101
int start() const
First element.
Definition: range.h:116
int start() const
First element.
Definition: range.h:86
Range(int i1_, int i2_)
Regular constructor.
Definition: range.h:77
This is an index class for creating submatrices.
Definition: range.h:36
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:1895
int size() const
Size.
Definition: range.h:98
Range()
Standard constructor.
Definition: range.h:60
Range(int i1_)
Regular constructor.
Definition: range.h:67
int end() const
Last element.
Definition: range.h:122
This is an index class for creating submatrices.
Definition: range.h:45