1573
|
1 /* |
|
2 |
1882
|
3 Copyright (C) 1996 John W. Eaton |
1573
|
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 |
1687
|
23 #if !defined (octave_chMatrix_int_h) |
|
24 #define octave_chMatrix_int_h 1 |
1573
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 // For FILE... |
|
31 #include <cstdio> |
|
32 |
1728
|
33 #include <string> |
|
34 |
1989
|
35 #include "MArray2.h" |
1573
|
36 |
|
37 #include "mx-defs.h" |
2349
|
38 #include "str-vec.h" |
1573
|
39 |
1728
|
40 class |
|
41 charMatrix : public MArray2<char> |
1573
|
42 { |
|
43 friend class ComplexMatrix; |
|
44 |
|
45 public: |
|
46 |
|
47 charMatrix (void) : MArray2<char> () { } |
|
48 charMatrix (int r, int c) : MArray2<char> (r, c) { } |
|
49 charMatrix (int r, int c, char val) : MArray2<char> (r, c, val) { } |
|
50 charMatrix (const MArray2<char>& a) : MArray2<char> (a) { } |
|
51 charMatrix (const charMatrix& a) : MArray2<char> (a) { } |
|
52 charMatrix (const char *s); |
1731
|
53 charMatrix (const string& s); |
2349
|
54 charMatrix (const string_vector& s); |
1573
|
55 |
|
56 charMatrix& operator = (const charMatrix& a) |
|
57 { |
|
58 MArray2<char>::operator = (a); |
|
59 return *this; |
|
60 } |
|
61 |
2384
|
62 bool operator == (const charMatrix& a) const; |
|
63 bool operator != (const charMatrix& a) const; |
1573
|
64 |
|
65 // destructive insert/delete/reorder operations |
|
66 |
|
67 charMatrix& insert (const char *s, int r, int c); |
|
68 charMatrix& insert (const charMatrix& a, int r, int c); |
|
69 |
1728
|
70 string row_as_string (int r) const; |
1573
|
71 |
|
72 #if 0 |
|
73 Matrix& insert (const RowVector& a, int r, int c); |
|
74 Matrix& insert (const ColumnVector& a, int r, int c); |
|
75 Matrix& insert (const DiagMatrix& a, int r, int c); |
|
76 |
|
77 Matrix& fill (char val); |
|
78 Matrix& fill (char val, int r1, int c1, int r2, int c2); |
|
79 |
|
80 Matrix append (const Matrix& a) const; |
|
81 Matrix append (const RowVector& a) const; |
|
82 Matrix append (const ColumnVector& a) const; |
|
83 Matrix append (const DiagMatrix& a) const; |
|
84 |
|
85 Matrix stack (const Matrix& a) const; |
|
86 Matrix stack (const RowVector& a) const; |
|
87 Matrix stack (const ColumnVector& a) const; |
|
88 Matrix stack (const DiagMatrix& a) const; |
2255
|
89 #endif |
1573
|
90 |
2255
|
91 charMatrix transpose (void) const; |
1573
|
92 |
2255
|
93 #if 0 |
1573
|
94 friend Matrix real (const ComplexMatrix& a); |
|
95 friend Matrix imag (const ComplexMatrix& a); |
|
96 |
|
97 // resize is the destructive equivalent for this one |
|
98 |
|
99 Matrix extract (int r1, int c1, int r2, int c2) const; |
|
100 |
|
101 // extract row or column i. |
|
102 |
|
103 RowVector row (int i) const; |
|
104 RowVector row (char *s) const; |
|
105 |
|
106 ColumnVector column (int i) const; |
|
107 ColumnVector column (char *s) const; |
|
108 |
|
109 Matrix inverse (void) const; |
|
110 Matrix inverse (int& info) const; |
|
111 Matrix inverse (int& info, double& rcond) const; |
|
112 |
|
113 Matrix pseudo_inverse (double tol = 0.0); |
|
114 |
|
115 ComplexMatrix fourier (void) const; |
|
116 ComplexMatrix ifourier (void) const; |
|
117 |
|
118 ComplexMatrix fourier2d (void) const; |
|
119 ComplexMatrix ifourier2d (void) const; |
|
120 |
|
121 DET determinant (void) const; |
|
122 DET determinant (int& info) const; |
|
123 DET determinant (int& info, double& rcond) const; |
|
124 |
|
125 Matrix solve (const Matrix& b) const; |
|
126 Matrix solve (const Matrix& b, int& info) const; |
|
127 Matrix solve (const Matrix& b, int& info, double& rcond) const; |
|
128 |
|
129 ComplexMatrix solve (const ComplexMatrix& b) const; |
|
130 ComplexMatrix solve (const ComplexMatrix& b, int& info) const; |
|
131 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const; |
|
132 |
|
133 ColumnVector solve (const ColumnVector& b) const; |
|
134 ColumnVector solve (const ColumnVector& b, int& info) const; |
|
135 ColumnVector solve (const ColumnVector& b, int& info, double& rcond) const; |
|
136 |
|
137 ComplexColumnVector solve (const ComplexColumnVector& b) const; |
|
138 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; |
|
139 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
140 double& rcond) const; |
|
141 |
|
142 Matrix lssolve (const Matrix& b) const; |
|
143 Matrix lssolve (const Matrix& b, int& info) const; |
|
144 Matrix lssolve (const Matrix& b, int& info, int& rank) const; |
|
145 |
|
146 ComplexMatrix lssolve (const ComplexMatrix& b) const; |
|
147 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; |
|
148 ComplexMatrix lssolve (const ComplexMatrix& b, int& info, |
|
149 int& rank) const; |
|
150 |
|
151 ColumnVector lssolve (const ColumnVector& b) const; |
|
152 ColumnVector lssolve (const ColumnVector& b, int& info) const; |
|
153 ColumnVector lssolve (const ColumnVector& b, int& info, int& rank) const; |
|
154 |
|
155 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; |
|
156 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; |
|
157 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, |
|
158 int& rank) const; |
|
159 |
|
160 Matrix& operator += (const Matrix& a); |
|
161 Matrix& operator -= (const Matrix& a); |
|
162 |
|
163 Matrix& operator += (const DiagMatrix& a); |
|
164 Matrix& operator -= (const DiagMatrix& a); |
|
165 |
|
166 // unary operations |
|
167 |
|
168 Matrix operator ! (void) const; |
|
169 |
|
170 // column vector by row vector -> matrix operations |
|
171 |
|
172 friend Matrix operator * (const ColumnVector& a, const RowVector& a); |
|
173 |
|
174 // diagonal matrix by scalar -> matrix operations |
|
175 |
|
176 friend Matrix operator + (const DiagMatrix& a, double s); |
|
177 friend Matrix operator - (const DiagMatrix& a, double s); |
|
178 |
|
179 // scalar by diagonal matrix -> matrix operations |
|
180 |
|
181 friend Matrix operator + (double s, const DiagMatrix& a); |
|
182 friend Matrix operator - (double s, const DiagMatrix& a); |
|
183 |
|
184 // matrix by diagonal matrix -> matrix operations |
|
185 |
|
186 friend Matrix operator + (const Matrix& a, const DiagMatrix& b); |
|
187 friend Matrix operator - (const Matrix& a, const DiagMatrix& b); |
|
188 friend Matrix operator * (const Matrix& a, const DiagMatrix& b); |
|
189 |
|
190 // diagonal matrix by matrix -> matrix operations |
|
191 |
|
192 friend Matrix operator + (const DiagMatrix& a, const Matrix& b); |
|
193 friend Matrix operator - (const DiagMatrix& a, const Matrix& b); |
|
194 friend Matrix operator * (const DiagMatrix& a, const Matrix& b); |
|
195 |
|
196 // matrix by matrix -> matrix operations |
|
197 |
|
198 friend Matrix operator * (const Matrix& a, const Matrix& b); |
|
199 |
|
200 // other operations |
|
201 |
|
202 friend Matrix map (d_d_Mapper f, const Matrix& a); |
|
203 friend Matrix map (d_c_Mapper f, const ComplexMatrix& a); |
|
204 void map (d_d_Mapper f); |
|
205 |
|
206 Matrix all (void) const; |
|
207 Matrix any (void) const; |
|
208 |
|
209 Matrix cumprod (void) const; |
|
210 Matrix cumsum (void) const; |
|
211 Matrix prod (void) const; |
|
212 Matrix sum (void) const; |
|
213 Matrix sumsq (void) const; |
|
214 |
|
215 ColumnVector diag (void) const; |
|
216 ColumnVector diag (int k) const; |
|
217 |
|
218 ColumnVector row_min (void) const; |
|
219 ColumnVector row_min_loc (void) const; |
|
220 |
|
221 ColumnVector row_max (void) const; |
|
222 ColumnVector row_max_loc (void) const; |
|
223 |
|
224 RowVector column_min (void) const; |
|
225 RowVector column_min_loc (void) const; |
|
226 |
|
227 RowVector column_max (void) const; |
|
228 RowVector column_max_loc (void) const; |
|
229 |
|
230 // i/o |
|
231 |
|
232 friend ostream& operator << (ostream& os, const Matrix& a); |
|
233 friend istream& operator >> (istream& is, Matrix& a); |
|
234 |
|
235 int read (FILE *fptr, const char *type); |
|
236 int write (FILE *fptr, const char *type); |
|
237 #endif |
|
238 |
|
239 private: |
|
240 |
|
241 charMatrix (char *ch, int r, int c) : MArray2<char> (ch, r, c) { } |
|
242 }; |
|
243 |
|
244 #endif |
|
245 |
|
246 /* |
|
247 ;;; Local Variables: *** |
|
248 ;;; mode: C++ *** |
|
249 ;;; End: *** |
|
250 */ |