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 "types.h"
26 #include <cassert>
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
fmatvec::Range< Var, Var >::end
int end() const
Last element.
Definition: range.h:91
fmatvec::Fixed
Definition: fmatvec.h:39
fmatvec::Var
Definition: types.h:101
fmatvec::Range< Fixed< I1 >, Fixed< I2 > >::start
int start() const
First element.
Definition: range.h:115
fmatvec::Range< Var, Var >::start
int start() const
First element.
Definition: range.h:85
fmatvec::Range< Var, Var >::Range
Range(int i1_, int i2_)
Regular constructor.
Definition: range.h:76
fmatvec::Range
This is an index class for creating submatrices.
Definition: range.h:35
fmatvec
Namespace fmatvec.
Definition: _memory.cc:28
fmatvec::operator==
bool operator==(const Matrix< Type1, Row1, Col1, AT > &A, const Matrix< Type2, Row2, Col2, AT > &B)
Matrix-matrix comparison.
Definition: linear_algebra.h:1913
fmatvec::Range< Var, Var >::size
int size() const
Size.
Definition: range.h:97
fmatvec::Range< Var, Var >::Range
Range()
Standard constructor.
Definition: range.h:59
fmatvec::Range< Var, Var >::Range
Range(int i1_)
Regular constructor.
Definition: range.h:66
fmatvec::Range< Fixed< I1 >, Fixed< I2 > >::end
int end() const
Last element.
Definition: range.h:121
fmatvec::Range< Var, Var >
This is an index class for creating submatrices.
Definition: range.h:44