comparison liboctave/dMatrix.h @ 7788:45f5faba05a2

Add the rcond function
author David Bateman <dbateman@free.fr>
date Wed, 14 May 2008 18:09:56 +0200
parents 36594d5bbe13
children 82be108cc558
comparison
equal deleted inserted replaced
7787:6b521b1e3631 7788:45f5faba05a2
35 OCTAVE_API 35 OCTAVE_API
36 Matrix : public MArray2<double> 36 Matrix : public MArray2<double>
37 { 37 {
38 public: 38 public:
39 39
40 typedef void (*solve_singularity_handler) (double rcond); 40 typedef void (*solve_singularity_handler) (double rcon);
41 41
42 Matrix (void) : MArray2<double> () { } 42 Matrix (void) : MArray2<double> () { }
43 43
44 Matrix (octave_idx_type r, octave_idx_type c) : MArray2<double> (r, c) { } 44 Matrix (octave_idx_type r, octave_idx_type c) : MArray2<double> (r, c) { }
45 45
110 RowVector row (octave_idx_type i) const; 110 RowVector row (octave_idx_type i) const;
111 111
112 ColumnVector column (octave_idx_type i) const; 112 ColumnVector column (octave_idx_type i) const;
113 113
114 private: 114 private:
115 Matrix tinverse (MatrixType &mattype, octave_idx_type& info, double& rcond, 115 Matrix tinverse (MatrixType &mattype, octave_idx_type& info, double& rcon,
116 int force, int calc_cond) const; 116 int force, int calc_cond) const;
117 117
118 Matrix finverse (MatrixType &mattype, octave_idx_type& info, double& rcond, 118 Matrix finverse (MatrixType &mattype, octave_idx_type& info, double& rcon,
119 int force, int calc_cond) const; 119 int force, int calc_cond) const;
120 120
121 public: 121 public:
122 Matrix inverse (void) const; 122 Matrix inverse (void) const;
123 Matrix inverse (octave_idx_type& info) const; 123 Matrix inverse (octave_idx_type& info) const;
124 Matrix inverse (octave_idx_type& info, double& rcond, int force = 0, 124 Matrix inverse (octave_idx_type& info, double& rcon, int force = 0,
125 int calc_cond = 1) const; 125 int calc_cond = 1) const;
126 126
127 Matrix inverse (MatrixType &mattype) const; 127 Matrix inverse (MatrixType &mattype) const;
128 Matrix inverse (MatrixType &mattype, octave_idx_type& info) const; 128 Matrix inverse (MatrixType &mattype, octave_idx_type& info) const;
129 Matrix inverse (MatrixType &mattype, octave_idx_type& info, double& rcond, 129 Matrix inverse (MatrixType &mattype, octave_idx_type& info, double& rcon,
130 int force = 0, int calc_cond = 1) const; 130 int force = 0, int calc_cond = 1) const;
131 131
132 Matrix pseudo_inverse (double tol = 0.0) const; 132 Matrix pseudo_inverse (double tol = 0.0) const;
133 133
134 ComplexMatrix fourier (void) const; 134 ComplexMatrix fourier (void) const;
137 ComplexMatrix fourier2d (void) const; 137 ComplexMatrix fourier2d (void) const;
138 ComplexMatrix ifourier2d (void) const; 138 ComplexMatrix ifourier2d (void) const;
139 139
140 DET determinant (void) const; 140 DET determinant (void) const;
141 DET determinant (octave_idx_type& info) const; 141 DET determinant (octave_idx_type& info) const;
142 DET determinant (octave_idx_type& info, double& rcond, int calc_cond = 1) const; 142 DET determinant (octave_idx_type& info, double& rcon, int calc_cond = 1) const;
143
144 double rcond (void) const;
145 double rcond (MatrixType &mattype) const;
143 146
144 private: 147 private:
145 // Upper triangular matrix solvers 148 // Upper triangular matrix solvers
146 Matrix utsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, 149 Matrix utsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info,
147 double& rcond, solve_singularity_handler sing_handler, 150 double& rcon, solve_singularity_handler sing_handler,
148 bool calc_cond = false) const; 151 bool calc_cond = false) const;
149 152
150 // Lower triangular matrix solvers 153 // Lower triangular matrix solvers
151 Matrix ltsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, 154 Matrix ltsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info,
152 double& rcond, solve_singularity_handler sing_handler, 155 double& rcon, solve_singularity_handler sing_handler,
153 bool calc_cond = false) const; 156 bool calc_cond = false) const;
154 157
155 // Full matrix solvers (lu/cholesky) 158 // Full matrix solvers (lu/cholesky)
156 Matrix fsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info, 159 Matrix fsolve (MatrixType &typ, const Matrix& b, octave_idx_type& info,
157 double& rcond, solve_singularity_handler sing_handler, 160 double& rcon, solve_singularity_handler sing_handler,
158 bool calc_cond = false) const; 161 bool calc_cond = false) const;
159 162
160 public: 163 public:
161 // Generic interface to solver with no probing of type 164 // Generic interface to solver with no probing of type
162 Matrix solve (MatrixType &typ, const Matrix& b) const; 165 Matrix solve (MatrixType &typ, const Matrix& b) const;
163 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info) const; 166 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info) const;
164 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info, 167 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info,
165 double& rcond) const; 168 double& rcon) const;
166 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info, 169 Matrix solve (MatrixType &typ, const Matrix& b, octave_idx_type& info,
167 double& rcond, solve_singularity_handler sing_handler, 170 double& rcon, solve_singularity_handler sing_handler,
168 bool singular_fallback = true) const; 171 bool singular_fallback = true) const;
169 172
170 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b) const; 173 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b) const;
171 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, 174 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b,
172 octave_idx_type& info) const; 175 octave_idx_type& info) const;
173 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, 176 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b,
174 octave_idx_type& info, double& rcond) const; 177 octave_idx_type& info, double& rcon) const;
175 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b, 178 ComplexMatrix solve (MatrixType &typ, const ComplexMatrix& b,
176 octave_idx_type& info, double& rcond, 179 octave_idx_type& info, double& rcon,
177 solve_singularity_handler sing_handler, 180 solve_singularity_handler sing_handler,
178 bool singular_fallback = true) const; 181 bool singular_fallback = true) const;
179 182
180 ColumnVector solve (MatrixType &typ, const ColumnVector& b) const; 183 ColumnVector solve (MatrixType &typ, const ColumnVector& b) const;
181 ColumnVector solve (MatrixType &typ, const ColumnVector& b, 184 ColumnVector solve (MatrixType &typ, const ColumnVector& b,
182 octave_idx_type& info) const; 185 octave_idx_type& info) const;
183 ColumnVector solve (MatrixType &typ, const ColumnVector& b, 186 ColumnVector solve (MatrixType &typ, const ColumnVector& b,
184 octave_idx_type& info, double& rcond) const; 187 octave_idx_type& info, double& rcon) const;
185 ColumnVector solve (MatrixType &typ, const ColumnVector& b, 188 ColumnVector solve (MatrixType &typ, const ColumnVector& b,
186 octave_idx_type& info, double& rcond, 189 octave_idx_type& info, double& rcon,
187 solve_singularity_handler sing_handler) const; 190 solve_singularity_handler sing_handler) const;
188 191
189 ComplexColumnVector solve (MatrixType &typ, 192 ComplexColumnVector solve (MatrixType &typ,
190 const ComplexColumnVector& b) const; 193 const ComplexColumnVector& b) const;
191 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, 194 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b,
192 octave_idx_type& info) const; 195 octave_idx_type& info) const;
193 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, 196 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b,
194 octave_idx_type& info, double& rcond) const; 197 octave_idx_type& info, double& rcon) const;
195 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b, 198 ComplexColumnVector solve (MatrixType &typ, const ComplexColumnVector& b,
196 octave_idx_type& info, double& rcond, 199 octave_idx_type& info, double& rcon,
197 solve_singularity_handler sing_handler) const; 200 solve_singularity_handler sing_handler) const;
198 201
199 // Generic interface to solver with probing of type 202 // Generic interface to solver with probing of type
200 Matrix solve (const Matrix& b) const; 203 Matrix solve (const Matrix& b) const;
201 Matrix solve (const Matrix& b, octave_idx_type& info) const; 204 Matrix solve (const Matrix& b, octave_idx_type& info) const;
202 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcond) const; 205 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcon) const;
203 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcond, 206 Matrix solve (const Matrix& b, octave_idx_type& info, double& rcon,
204 solve_singularity_handler sing_handler) const; 207 solve_singularity_handler sing_handler) const;
205 208
206 ComplexMatrix solve (const ComplexMatrix& b) const; 209 ComplexMatrix solve (const ComplexMatrix& b) const;
207 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info) const; 210 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info) const;
208 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, double& rcond) const; 211 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, double& rcon) const;
209 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, double& rcond, 212 ComplexMatrix solve (const ComplexMatrix& b, octave_idx_type& info, double& rcon,
210 solve_singularity_handler sing_handler) const; 213 solve_singularity_handler sing_handler) const;
211 214
212 ColumnVector solve (const ColumnVector& b) const; 215 ColumnVector solve (const ColumnVector& b) const;
213 ColumnVector solve (const ColumnVector& b, octave_idx_type& info) const; 216 ColumnVector solve (const ColumnVector& b, octave_idx_type& info) const;
214 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcond) const; 217 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcon) const;
215 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcond, 218 ColumnVector solve (const ColumnVector& b, octave_idx_type& info, double& rcon,
216 solve_singularity_handler sing_handler) const; 219 solve_singularity_handler sing_handler) const;
217 220
218 ComplexColumnVector solve (const ComplexColumnVector& b) const; 221 ComplexColumnVector solve (const ComplexColumnVector& b) const;
219 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info) const; 222 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info) const;
220 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info, 223 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info,
221 double& rcond) const; 224 double& rcon) const;
222 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info, 225 ComplexColumnVector solve (const ComplexColumnVector& b, octave_idx_type& info,
223 double& rcond, 226 double& rcon,
224 solve_singularity_handler sing_handler) const; 227 solve_singularity_handler sing_handler) const;
225 228
226 // Singular solvers 229 // Singular solvers
227 Matrix lssolve (const Matrix& b) const; 230 Matrix lssolve (const Matrix& b) const;
228 Matrix lssolve (const Matrix& b, octave_idx_type& info) const; 231 Matrix lssolve (const Matrix& b, octave_idx_type& info) const;
229 Matrix lssolve (const Matrix& b, octave_idx_type& info, 232 Matrix lssolve (const Matrix& b, octave_idx_type& info,
230 octave_idx_type& rank) const; 233 octave_idx_type& rank) const;
231 Matrix lssolve (const Matrix& b, octave_idx_type& info, 234 Matrix lssolve (const Matrix& b, octave_idx_type& info,
232 octave_idx_type& rank, double& rcond) const; 235 octave_idx_type& rank, double& rcon) const;
233 236
234 ComplexMatrix lssolve (const ComplexMatrix& b) const; 237 ComplexMatrix lssolve (const ComplexMatrix& b) const;
235 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info) const; 238 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info) const;
236 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info, 239 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info,
237 octave_idx_type& rank) const; 240 octave_idx_type& rank) const;
238 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info, 241 ComplexMatrix lssolve (const ComplexMatrix& b, octave_idx_type& info,
239 octave_idx_type& rank, double &rcond) const; 242 octave_idx_type& rank, double &rcon) const;
240 243
241 ColumnVector lssolve (const ColumnVector& b) const; 244 ColumnVector lssolve (const ColumnVector& b) const;
242 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info) const; 245 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info) const;
243 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info, 246 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info,
244 octave_idx_type& rank) const; 247 octave_idx_type& rank) const;
245 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info, 248 ColumnVector lssolve (const ColumnVector& b, octave_idx_type& info,
246 octave_idx_type& rank, double& rcond) const; 249 octave_idx_type& rank, double& rcon) const;
247 250
248 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; 251 ComplexColumnVector lssolve (const ComplexColumnVector& b) const;
249 ComplexColumnVector lssolve (const ComplexColumnVector& b, 252 ComplexColumnVector lssolve (const ComplexColumnVector& b,
250 octave_idx_type& info) const; 253 octave_idx_type& info) const;
251 ComplexColumnVector lssolve (const ComplexColumnVector& b, 254 ComplexColumnVector lssolve (const ComplexColumnVector& b,
252 octave_idx_type& info, 255 octave_idx_type& info,
253 octave_idx_type& rank) const; 256 octave_idx_type& rank) const;
254 ComplexColumnVector lssolve (const ComplexColumnVector& b, 257 ComplexColumnVector lssolve (const ComplexColumnVector& b,
255 octave_idx_type& info, 258 octave_idx_type& info,
256 octave_idx_type& rank, double& rcond) const; 259 octave_idx_type& rank, double& rcon) const;
257 260
258 Matrix expm (void) const; 261 Matrix expm (void) const;
259 262
260 Matrix& operator += (const DiagMatrix& a); 263 Matrix& operator += (const DiagMatrix& a);
261 Matrix& operator -= (const DiagMatrix& a); 264 Matrix& operator -= (const DiagMatrix& a);