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