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 |
3503
|
32 #include <iostream> |
3219
|
33 #include <string> |
|
34 |
|
35 #include "mx-base.h" |
|
36 #include "str-vec.h" |
|
37 |
|
38 #include "error.h" |
|
39 #include "ov-base.h" |
|
40 #include "ov-typeinfo.h" |
|
41 |
|
42 class Octave_map; |
|
43 class octave_value_list; |
|
44 |
|
45 class tree_walker; |
|
46 |
|
47 // Real matrix values. |
|
48 |
3223
|
49 template <class MT> |
|
50 class |
3219
|
51 octave_base_matrix : public octave_base_value |
|
52 { |
|
53 public: |
|
54 |
|
55 octave_base_matrix (void) |
|
56 : octave_base_value () { } |
|
57 |
|
58 octave_base_matrix (const MT& m) |
|
59 : octave_base_value (), matrix (m) { } |
|
60 |
|
61 octave_base_matrix (const octave_base_matrix& m) |
|
62 : octave_base_value (), matrix (m.matrix) { } |
|
63 |
|
64 ~octave_base_matrix (void) { } |
|
65 |
|
66 octave_value *clone (void) { return new octave_base_matrix (*this); } |
|
67 |
3220
|
68 octave_value do_index_op (const octave_value_list& idx); |
|
69 |
3219
|
70 int rows (void) const { return matrix.rows (); } |
|
71 int columns (void) const { return matrix.columns (); } |
|
72 |
|
73 int length (void) const |
|
74 { |
|
75 int r = rows (); |
|
76 int c = columns (); |
|
77 |
3472
|
78 return (r == 0 || c == 0) ? 0 : ((r > c) ? r : c); |
3219
|
79 } |
|
80 |
3221
|
81 octave_value all (void) const { return matrix.all (); } |
|
82 octave_value any (void) const { return matrix.any (); } |
|
83 |
|
84 bool is_matrix_type (void) const { return true; } |
|
85 |
|
86 bool is_numeric_type (void) const { return true; } |
|
87 |
3219
|
88 bool is_defined (void) const { return true; } |
|
89 |
|
90 bool is_constant (void) const { return true; } |
|
91 |
3220
|
92 bool is_true (void) const; |
|
93 |
3219
|
94 virtual bool print_as_scalar (void) const; |
|
95 |
|
96 void print (ostream& os, bool pr_as_read_syntax = false) const; |
|
97 |
|
98 void print_raw (ostream& os, bool pr_as_read_syntax = false) const; |
|
99 |
|
100 bool print_name_tag (ostream& os, const string& name) const; |
|
101 |
|
102 protected: |
|
103 |
|
104 MT matrix; |
|
105 }; |
|
106 |
|
107 #endif |
|
108 |
|
109 /* |
|
110 ;;; Local Variables: *** |
|
111 ;;; mode: C++ *** |
|
112 ;;; End: *** |
|
113 */ |