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