comparison liboctave/chMatrix.h @ 1573:403c60daa8c7

[project @ 1995-10-19 04:34:20 by jwe] Initial revision
author jwe
date Thu, 19 Oct 1995 04:34:20 +0000
parents
children c5f9b6cea4a8
comparison
equal deleted inserted replaced
1572:0d9e10d10bd7 1573:403c60daa8c7
1 // -*- C++ -*-
2 /*
3
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
5
6 This file is part of Octave.
7
8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
11 later version.
12
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 */
23
24 #if !defined (octave_cMatrix_int_h)
25 #define octave_cMatrix_int_h 1
26
27 #if defined (__GNUG__)
28 #pragma interface
29 #endif
30
31 // For FILE...
32 #include <cstdio>
33
34 #include "MArray.h"
35
36 #include "mx-defs.h"
37
38 class charMatrix : public MArray2<char>
39 {
40 friend class ComplexMatrix;
41
42 public:
43
44 charMatrix (void) : MArray2<char> () { }
45 charMatrix (int r, int c) : MArray2<char> (r, c) { }
46 charMatrix (int r, int c, char val) : MArray2<char> (r, c, val) { }
47 charMatrix (const MArray2<char>& a) : MArray2<char> (a) { }
48 charMatrix (const charMatrix& a) : MArray2<char> (a) { }
49 charMatrix (const char *s);
50
51 charMatrix& operator = (const charMatrix& a)
52 {
53 MArray2<char>::operator = (a);
54 return *this;
55 }
56
57 int operator == (const charMatrix& a) const;
58 int operator != (const charMatrix& a) const;
59
60 // destructive insert/delete/reorder operations
61
62 charMatrix& insert (const char *s, int r, int c);
63 charMatrix& insert (const charMatrix& a, int r, int c);
64
65 char *row_as_string (int r) const;
66
67 #if 0
68 Matrix& insert (const RowVector& a, int r, int c);
69 Matrix& insert (const ColumnVector& a, int r, int c);
70 Matrix& insert (const DiagMatrix& a, int r, int c);
71
72 Matrix& fill (char val);
73 Matrix& fill (char val, int r1, int c1, int r2, int c2);
74
75 Matrix append (const Matrix& a) const;
76 Matrix append (const RowVector& a) const;
77 Matrix append (const ColumnVector& a) const;
78 Matrix append (const DiagMatrix& a) const;
79
80 Matrix stack (const Matrix& a) const;
81 Matrix stack (const RowVector& a) const;
82 Matrix stack (const ColumnVector& a) const;
83 Matrix stack (const DiagMatrix& a) const;
84
85 Matrix transpose (void) const;
86
87 friend Matrix real (const ComplexMatrix& a);
88 friend Matrix imag (const ComplexMatrix& a);
89
90 // resize is the destructive equivalent for this one
91
92 Matrix extract (int r1, int c1, int r2, int c2) const;
93
94 // extract row or column i.
95
96 RowVector row (int i) const;
97 RowVector row (char *s) const;
98
99 ColumnVector column (int i) const;
100 ColumnVector column (char *s) const;
101
102 Matrix inverse (void) const;
103 Matrix inverse (int& info) const;
104 Matrix inverse (int& info, double& rcond) const;
105
106 Matrix pseudo_inverse (double tol = 0.0);
107
108 ComplexMatrix fourier (void) const;
109 ComplexMatrix ifourier (void) const;
110
111 ComplexMatrix fourier2d (void) const;
112 ComplexMatrix ifourier2d (void) const;
113
114 DET determinant (void) const;
115 DET determinant (int& info) const;
116 DET determinant (int& info, double& rcond) const;
117
118 Matrix solve (const Matrix& b) const;
119 Matrix solve (const Matrix& b, int& info) const;
120 Matrix solve (const Matrix& b, int& info, double& rcond) const;
121
122 ComplexMatrix solve (const ComplexMatrix& b) const;
123 ComplexMatrix solve (const ComplexMatrix& b, int& info) const;
124 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const;
125
126 ColumnVector solve (const ColumnVector& b) const;
127 ColumnVector solve (const ColumnVector& b, int& info) const;
128 ColumnVector solve (const ColumnVector& b, int& info, double& rcond) const;
129
130 ComplexColumnVector solve (const ComplexColumnVector& b) const;
131 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const;
132 ComplexColumnVector solve (const ComplexColumnVector& b, int& info,
133 double& rcond) const;
134
135 Matrix lssolve (const Matrix& b) const;
136 Matrix lssolve (const Matrix& b, int& info) const;
137 Matrix lssolve (const Matrix& b, int& info, int& rank) const;
138
139 ComplexMatrix lssolve (const ComplexMatrix& b) const;
140 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const;
141 ComplexMatrix lssolve (const ComplexMatrix& b, int& info,
142 int& rank) const;
143
144 ColumnVector lssolve (const ColumnVector& b) const;
145 ColumnVector lssolve (const ColumnVector& b, int& info) const;
146 ColumnVector lssolve (const ColumnVector& b, int& info, int& rank) const;
147
148 ComplexColumnVector lssolve (const ComplexColumnVector& b) const;
149 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const;
150 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info,
151 int& rank) const;
152
153 Matrix& operator += (const Matrix& a);
154 Matrix& operator -= (const Matrix& a);
155
156 Matrix& operator += (const DiagMatrix& a);
157 Matrix& operator -= (const DiagMatrix& a);
158
159 // unary operations
160
161 Matrix operator ! (void) const;
162
163 // column vector by row vector -> matrix operations
164
165 friend Matrix operator * (const ColumnVector& a, const RowVector& a);
166
167 // diagonal matrix by scalar -> matrix operations
168
169 friend Matrix operator + (const DiagMatrix& a, double s);
170 friend Matrix operator - (const DiagMatrix& a, double s);
171
172 // scalar by diagonal matrix -> matrix operations
173
174 friend Matrix operator + (double s, const DiagMatrix& a);
175 friend Matrix operator - (double s, const DiagMatrix& a);
176
177 // matrix by diagonal matrix -> matrix operations
178
179 friend Matrix operator + (const Matrix& a, const DiagMatrix& b);
180 friend Matrix operator - (const Matrix& a, const DiagMatrix& b);
181 friend Matrix operator * (const Matrix& a, const DiagMatrix& b);
182
183 // diagonal matrix by matrix -> matrix operations
184
185 friend Matrix operator + (const DiagMatrix& a, const Matrix& b);
186 friend Matrix operator - (const DiagMatrix& a, const Matrix& b);
187 friend Matrix operator * (const DiagMatrix& a, const Matrix& b);
188
189 // matrix by matrix -> matrix operations
190
191 friend Matrix operator * (const Matrix& a, const Matrix& b);
192
193 // other operations
194
195 friend Matrix map (d_d_Mapper f, const Matrix& a);
196 friend Matrix map (d_c_Mapper f, const ComplexMatrix& a);
197 void map (d_d_Mapper f);
198
199 Matrix all (void) const;
200 Matrix any (void) const;
201
202 Matrix cumprod (void) const;
203 Matrix cumsum (void) const;
204 Matrix prod (void) const;
205 Matrix sum (void) const;
206 Matrix sumsq (void) const;
207
208 ColumnVector diag (void) const;
209 ColumnVector diag (int k) const;
210
211 ColumnVector row_min (void) const;
212 ColumnVector row_min_loc (void) const;
213
214 ColumnVector row_max (void) const;
215 ColumnVector row_max_loc (void) const;
216
217 RowVector column_min (void) const;
218 RowVector column_min_loc (void) const;
219
220 RowVector column_max (void) const;
221 RowVector column_max_loc (void) const;
222
223 // i/o
224
225 friend ostream& operator << (ostream& os, const Matrix& a);
226 friend istream& operator >> (istream& is, Matrix& a);
227
228 int read (FILE *fptr, const char *type);
229 int write (FILE *fptr, const char *type);
230 #endif
231
232 private:
233
234 charMatrix (char *ch, int r, int c) : MArray2<char> (ch, r, c) { }
235 };
236
237 #endif
238
239 /*
240 ;;; Local Variables: ***
241 ;;; mode: C++ ***
242 ;;; page-delimiter: "^/\\*" ***
243 ;;; End: ***
244 */