3
|
1 // Range.h -*- C++ -*- |
|
2 /* |
|
3 |
1860
|
4 Copyright (C) 1996 John W. Eaton |
3
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
3
|
21 |
|
22 */ |
|
23 |
382
|
24 #if !defined (octave_Range_h) |
|
25 #define octave_Range_h 1 |
|
26 |
1296
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
3
|
30 |
238
|
31 class istream; |
|
32 class ostream; |
645
|
33 class Matrix; |
3
|
34 |
1860
|
35 class |
|
36 Range |
3
|
37 { |
|
38 public: |
1860
|
39 |
1528
|
40 Range (void) |
1860
|
41 : rng_base (-1), rng_limit (-1), rng_inc (-1), rng_nelem (-1) { } |
1528
|
42 |
|
43 Range (const Range& r) |
1860
|
44 : rng_base (r.rng_base), rng_limit (r.rng_limit), rng_inc (r.rng_inc), |
|
45 rng_nelem (r.rng_nelem) { } |
3
|
46 |
1528
|
47 Range (double b, double l) |
1860
|
48 : rng_base (b), rng_limit (l), rng_inc (1), |
|
49 rng_nelem (nelem_internal ()) { } |
1528
|
50 |
|
51 Range (double b, double l, double i) |
1860
|
52 : rng_base (b), rng_limit (l), rng_inc (i), |
|
53 rng_nelem (nelem_internal ()) { } |
1528
|
54 |
|
55 double base (void) const { return rng_base; } |
|
56 double limit (void) const { return rng_limit; } |
|
57 double inc (void) const { return rng_inc; } |
|
58 int nelem (void) const { return rng_nelem; } |
3
|
59 |
645
|
60 Matrix matrix_value (void) const; |
|
61 |
3
|
62 double min (void) const; |
|
63 double max (void) const; |
|
64 |
208
|
65 void sort (void); |
|
66 |
1528
|
67 void set_base (double b) { rng_base = b; } |
|
68 void set_limit (double l) { rng_limit = l; } |
|
69 void set_inc (double i) { rng_inc = i; } |
|
70 |
3
|
71 |
|
72 friend ostream& operator << (ostream& os, const Range& r); |
|
73 friend istream& operator >> (istream& is, Range& r); |
|
74 |
|
75 void print_range (void); |
|
76 |
|
77 private: |
1860
|
78 |
208
|
79 double rng_base; |
|
80 double rng_limit; |
|
81 double rng_inc; |
1860
|
82 |
208
|
83 int rng_nelem; |
3
|
84 |
|
85 int nelem_internal (void) const; |
|
86 }; |
|
87 |
|
88 #endif |
|
89 |
|
90 /* |
|
91 ;;; Local Variables: *** |
|
92 ;;; mode: C++ *** |
|
93 ;;; page-delimiter: "^/\\*" *** |
|
94 ;;; End: *** |
|
95 */ |