1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #if !defined (octave_Range_h)
24 #define octave_Range_h 1
25
26 #if defined (__GNUG__)
27 #pragma interface
28 #endif
29
30 class istream;
31 class ostream;
32 class Matrix;
33
34 class
35 Range
36 {
37 public:
38
39 Range (void)
40 : rng_base (-1), rng_limit (-1), rng_inc (-1), rng_nelem (-1) { }
41
42 Range (const Range& r)
43 : rng_base (r.rng_base), rng_limit (r.rng_limit), rng_inc (r.rng_inc),
44 rng_nelem (r.rng_nelem) { }
45
46 Range (double b, double l)
47 : rng_base (b), rng_limit (l), rng_inc (1),
48 rng_nelem (nelem_internal ()) { }
49
50 Range (double b, double l, double i)
51 : rng_base (b), rng_limit (l), rng_inc (i),
52 rng_nelem (nelem_internal ()) { }
53
54 double base (void) const { return rng_base; }
55 double limit (void) const { return rng_limit; }
56 double inc (void) const { return rng_inc; }
57 int nelem (void) const { return rng_nelem; }
58
59 bool all_elements_are_ints (void) const;
60
61 Matrix matrix_value (void) const;
62
63 double min (void) const;
64 double max (void) const;
65
66 void sort (void);
67
68 void set_base (double b) { rng_base = b; }
69 void set_limit (double l) { rng_limit = l; }
70 void set_inc (double i) { rng_inc = i; }
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:
78
79 double rng_base;
80 double rng_limit;
81 double rng_inc;
82
83 int rng_nelem;
84
85 int nelem_internal (void) const;
86 };
87
88 extern Range operator - (const Range& r);
89
90 #endif
91
92
93
94
95
96