3
|
1 // Range.h -*- C++ -*- |
|
2 /* |
|
3 |
382
|
4 Copyright (C) 1992, 1993, 1994 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 |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
382
|
24 #if !defined (octave_Range_h) |
|
25 #define octave_Range_h 1 |
|
26 |
461
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
382
|
31 extern "C++" { |
3
|
32 |
238
|
33 class istream; |
|
34 class ostream; |
645
|
35 class Matrix; |
3
|
36 |
|
37 class Range |
|
38 { |
|
39 public: |
|
40 Range (void); |
|
41 Range (const Range& r); |
|
42 Range (double b, double l); |
|
43 Range (double b, double l, double i); |
|
44 |
|
45 double base (void) const; |
|
46 double limit (void) const; |
|
47 double inc (void) const; |
|
48 int nelem (void) const; |
|
49 |
645
|
50 Matrix matrix_value (void) const; |
|
51 |
3
|
52 double min (void) const; |
|
53 double max (void) const; |
|
54 |
208
|
55 void sort (void); |
|
56 |
3
|
57 void set_base (double b); |
|
58 void set_limit (double l); |
|
59 void set_inc (double i); |
|
60 |
|
61 friend ostream& operator << (ostream& os, const Range& r); |
|
62 friend istream& operator >> (istream& is, Range& r); |
|
63 |
|
64 void print_range (void); |
|
65 |
|
66 private: |
208
|
67 double rng_base; |
|
68 double rng_limit; |
|
69 double rng_inc; |
|
70 int rng_nelem; |
3
|
71 |
|
72 int nelem_internal (void) const; |
|
73 }; |
|
74 |
208
|
75 inline |
|
76 Range::Range (void) |
|
77 { |
|
78 rng_base = -1; |
|
79 rng_limit = -1; |
|
80 rng_inc = -1; |
|
81 rng_nelem = -1; |
|
82 } |
3
|
83 |
208
|
84 inline |
|
85 Range::Range (const Range& r) |
|
86 { |
|
87 rng_base = r.rng_base; |
|
88 rng_limit = r.rng_limit; |
|
89 rng_inc = r.rng_inc; |
|
90 rng_nelem = r.rng_nelem; |
|
91 } |
3
|
92 |
208
|
93 inline |
|
94 Range::Range (double b, double l) |
|
95 { |
|
96 rng_base = b; |
|
97 rng_limit = l; |
|
98 rng_inc = 1; |
|
99 rng_nelem = nelem_internal (); |
|
100 } |
3
|
101 |
208
|
102 inline |
|
103 Range::Range (double b, double l, double i) |
|
104 { |
|
105 rng_base = b; |
|
106 rng_limit = l; |
|
107 rng_inc = i; |
|
108 rng_nelem = nelem_internal (); |
|
109 } |
3
|
110 |
208
|
111 inline double Range::base (void) const { return rng_base; } |
|
112 inline double Range::limit (void) const { return rng_limit; } |
|
113 inline double Range::inc (void) const { return rng_inc; } |
|
114 inline int Range::nelem (void) const { return rng_nelem; } |
3
|
115 |
208
|
116 inline void Range::set_base (double b) { rng_base = b; } |
|
117 inline void Range::set_limit (double l) { rng_limit = l; } |
|
118 inline void Range::set_inc (double i) { rng_inc = i; } |
3
|
119 |
382
|
120 } // extern "C++" |
|
121 |
3
|
122 #endif |
|
123 |
|
124 /* |
|
125 ;;; Local Variables: *** |
|
126 ;;; mode: C++ *** |
|
127 ;;; page-delimiter: "^/\\*" *** |
|
128 ;;; End: *** |
|
129 */ |