3219
|
1 /* |
|
2 |
|
3 Copyright (C) 1998 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_base_matrix_h) |
|
24 #define octave_base_matrix_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
|
32 #include <string> |
|
33 |
|
34 class ostream; |
|
35 |
|
36 #include "mx-base.h" |
|
37 #include "str-vec.h" |
|
38 |
|
39 #include "error.h" |
|
40 #include "ov-base.h" |
|
41 #include "ov-typeinfo.h" |
|
42 |
|
43 class Octave_map; |
|
44 class octave_value_list; |
|
45 |
|
46 class tree_walker; |
|
47 |
|
48 // Real matrix values. |
|
49 |
3223
|
50 template <class MT> |
|
51 class |
3219
|
52 octave_base_matrix : public octave_base_value |
|
53 { |
|
54 public: |
|
55 |
|
56 octave_base_matrix (void) |
|
57 : octave_base_value () { } |
|
58 |
|
59 octave_base_matrix (const MT& m) |
|
60 : octave_base_value (), matrix (m) { } |
|
61 |
|
62 octave_base_matrix (const octave_base_matrix& m) |
|
63 : octave_base_value (), matrix (m.matrix) { } |
|
64 |
|
65 ~octave_base_matrix (void) { } |
|
66 |
|
67 octave_value *clone (void) { return new octave_base_matrix (*this); } |
|
68 |
3220
|
69 octave_value do_index_op (const octave_value_list& idx); |
|
70 |
3219
|
71 int rows (void) const { return matrix.rows (); } |
|
72 int columns (void) const { return matrix.columns (); } |
|
73 |
|
74 int length (void) const |
|
75 { |
|
76 int r = rows (); |
|
77 int c = columns (); |
|
78 |
|
79 return r > c ? r : c; |
|
80 } |
|
81 |
3221
|
82 octave_value all (void) const { return matrix.all (); } |
|
83 octave_value any (void) const { return matrix.any (); } |
|
84 |
|
85 bool is_matrix_type (void) const { return true; } |
|
86 |
|
87 bool is_numeric_type (void) const { return true; } |
|
88 |
3219
|
89 bool is_defined (void) const { return true; } |
|
90 |
|
91 bool is_constant (void) const { return true; } |
|
92 |
3220
|
93 bool is_true (void) const; |
|
94 |
3219
|
95 virtual bool print_as_scalar (void) const; |
|
96 |
|
97 void print (ostream& os, bool pr_as_read_syntax = false) const; |
|
98 |
|
99 void print_raw (ostream& os, bool pr_as_read_syntax = false) const; |
|
100 |
|
101 bool print_name_tag (ostream& os, const string& name) const; |
|
102 |
|
103 protected: |
|
104 |
|
105 MT matrix; |
|
106 }; |
|
107 |
|
108 #endif |
|
109 |
|
110 /* |
|
111 ;;; Local Variables: *** |
|
112 ;;; mode: C++ *** |
|
113 ;;; End: *** |
|
114 */ |