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 #include <cstdlib> |
|
27 |
3503
|
28 #include <iostream> |
3219
|
29 #include <string> |
|
30 |
|
31 #include "mx-base.h" |
|
32 #include "str-vec.h" |
|
33 |
|
34 #include "error.h" |
4649
|
35 #include "oct-obj.h" |
3219
|
36 #include "ov-base.h" |
|
37 #include "ov-typeinfo.h" |
|
38 |
|
39 class Octave_map; |
|
40 |
|
41 class tree_walker; |
|
42 |
|
43 // Real matrix values. |
|
44 |
3223
|
45 template <class MT> |
|
46 class |
3219
|
47 octave_base_matrix : public octave_base_value |
|
48 { |
|
49 public: |
|
50 |
|
51 octave_base_matrix (void) |
|
52 : octave_base_value () { } |
|
53 |
|
54 octave_base_matrix (const MT& m) |
4676
|
55 : octave_base_value (), matrix (m) |
|
56 { |
|
57 if (matrix.ndims () == 0) |
|
58 matrix.resize (dim_vector (0, 0)); |
|
59 } |
3219
|
60 |
|
61 octave_base_matrix (const octave_base_matrix& m) |
|
62 : octave_base_value (), matrix (m.matrix) { } |
|
63 |
|
64 ~octave_base_matrix (void) { } |
|
65 |
3933
|
66 octave_value *clone (void) const { return new octave_base_matrix (*this); } |
|
67 octave_value *empty_clone (void) const { return new octave_base_matrix (); } |
|
68 |
4901
|
69 size_t byte_size (void) const { return matrix.byte_size (); } |
|
70 |
5147
|
71 octave_value squeeze (void) const { return MT (matrix.squeeze ()); } |
4532
|
72 |
4247
|
73 octave_value subsref (const std::string& type, |
4219
|
74 const std::list<octave_value_list>& idx); |
3219
|
75 |
4661
|
76 octave_value_list subsref (const std::string&, |
|
77 const std::list<octave_value_list>&, int) |
4271
|
78 { |
|
79 panic_impossible (); |
|
80 return octave_value_list (); |
|
81 } |
|
82 |
4247
|
83 octave_value subsasgn (const std::string& type, |
4219
|
84 const std::list<octave_value_list>& idx, |
3933
|
85 const octave_value& rhs); |
|
86 |
|
87 octave_value do_index_op (const octave_value_list& idx, int resize_ok); |
|
88 |
|
89 octave_value do_index_op (const octave_value_list& idx) |
|
90 { return do_index_op (idx, 0); } |
3220
|
91 |
3928
|
92 void assign (const octave_value_list& idx, const MT& rhs); |
|
93 |
4513
|
94 dim_vector dims (void) const { return matrix.dims (); } |
|
95 |
4567
|
96 octave_value reshape (const dim_vector& new_dims) const |
|
97 { return MT (matrix.reshape (new_dims)); } |
|
98 |
4593
|
99 octave_value permute (const Array<int>& vec, bool inv = false) const |
|
100 { return MT (matrix.permute (vec, inv)); } |
|
101 |
4915
|
102 octave_value resize (const dim_vector& dv) const |
|
103 { MT retval (matrix); retval.resize (dv); return retval; } |
|
104 |
4017
|
105 octave_value all (int dim = 0) const { return matrix.all (dim); } |
|
106 octave_value any (int dim = 0) const { return matrix.any (dim); } |
3221
|
107 |
|
108 bool is_matrix_type (void) const { return true; } |
|
109 |
|
110 bool is_numeric_type (void) const { return true; } |
|
111 |
3219
|
112 bool is_defined (void) const { return true; } |
|
113 |
|
114 bool is_constant (void) const { return true; } |
|
115 |
3220
|
116 bool is_true (void) const; |
|
117 |
4604
|
118 bool print_as_scalar (void) const; |
3219
|
119 |
3523
|
120 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
3219
|
121 |
3933
|
122 void print_info (std::ostream& os, const std::string& prefix) const; |
|
123 |
3219
|
124 protected: |
|
125 |
|
126 MT matrix; |
|
127 }; |
|
128 |
|
129 #endif |
|
130 |
|
131 /* |
|
132 ;;; Local Variables: *** |
|
133 ;;; mode: C++ *** |
|
134 ;;; End: *** |
|
135 */ |