517
|
1 // oct-obj.cc -*- C++ -*- |
|
2 /* |
|
3 |
|
4 Copyright (C) 1994 John W. Eaton |
|
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 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
|
26 #endif |
|
27 |
|
28 #if defined (__GNUG__) |
|
29 #pragma implementation |
|
30 #endif |
|
31 |
|
32 #include "Array.h" |
|
33 #include "mx-base.h" |
|
34 #include "Range.h" |
|
35 |
|
36 #include "tree-const.h" |
|
37 #include "oct-obj.h" |
|
38 |
|
39 // We can't put these functions in oct-obj.h without including |
|
40 // tree-const.h there too, and that causes trouble... |
|
41 |
|
42 Octave_object::Octave_object (double d) |
|
43 : Array<tree_constant> (1, tree_constant (d)) { } |
|
44 |
|
45 Octave_object::Octave_object (const Matrix& m) |
|
46 : Array<tree_constant> (1, tree_constant (m)) { } |
|
47 |
|
48 Octave_object::Octave_object (const DiagMatrix& d) |
|
49 : Array<tree_constant> (1, tree_constant (d)) { } |
|
50 |
526
|
51 Octave_object::Octave_object (const RowVector& v, int pcv) |
517
|
52 : Array<tree_constant> (1, tree_constant (v, pcv)) { } |
|
53 |
526
|
54 Octave_object::Octave_object (const ColumnVector& v, int pcv) |
517
|
55 : Array<tree_constant> (1, tree_constant (v, pcv)) { } |
|
56 |
|
57 Octave_object::Octave_object (const Complex& c) |
|
58 : Array<tree_constant> (1, tree_constant (c)) { } |
|
59 |
|
60 Octave_object::Octave_object (const ComplexMatrix& m) |
|
61 : Array<tree_constant> (1, tree_constant (m)) { } |
|
62 |
|
63 Octave_object::Octave_object (const ComplexDiagMatrix& d) |
|
64 : Array<tree_constant> (1, tree_constant (d)) { } |
|
65 |
526
|
66 Octave_object::Octave_object (const ComplexRowVector& v, int pcv) |
517
|
67 : Array<tree_constant> (1, tree_constant (v, pcv)) { } |
|
68 |
526
|
69 Octave_object::Octave_object (const ComplexColumnVector& v, int pcv) |
517
|
70 : Array<tree_constant> (1, tree_constant (v, pcv)) { } |
|
71 |
|
72 Octave_object::Octave_object (const char *s) |
|
73 : Array<tree_constant> (1, tree_constant (s)) { } |
|
74 |
|
75 Octave_object::Octave_object (double base, double limit, double inc) |
|
76 : Array<tree_constant> (1, tree_constant (base, limit, inc)) { } |
|
77 |
|
78 Octave_object::Octave_object (const Range& r) |
|
79 : Array<tree_constant> (1, tree_constant (r)) { } |
|
80 |
|
81 tree_constant& |
|
82 Octave_object::operator () (int n) |
|
83 { |
|
84 maybe_resize (n); |
|
85 return Array<tree_constant>::operator () (n); |
|
86 } |
|
87 |
|
88 tree_constant |
|
89 Octave_object::operator () (int n) const |
|
90 { |
|
91 return Array<tree_constant>::operator () (n); |
|
92 } |
|
93 |
|
94 tree_constant& |
|
95 Octave_object::elem (int n) |
|
96 { |
|
97 maybe_resize (n); |
|
98 return Array<tree_constant>::elem (n); |
|
99 } |
|
100 |
|
101 tree_constant |
|
102 Octave_object::elem (int n) const |
|
103 { |
|
104 return Array<tree_constant>::operator () (n); |
|
105 } |
|
106 |
|
107 void |
|
108 Octave_object::maybe_resize (int n) |
|
109 { |
|
110 if (n >= length ()) |
|
111 resize (n + 1, Matrix ()); |
|
112 } |
|
113 |
|
114 /* |
|
115 ;;; Local Variables: *** |
|
116 ;;; mode: C++ *** |
|
117 ;;; page-delimiter: "^/\\*" *** |
|
118 ;;; End: *** |
|
119 */ |