5164
|
1 /* |
|
2 |
|
3 Copyright (C) 2004 David Bateman |
|
4 Copyright (C) 1998-2004 Andy Adler |
|
5 |
|
6 Octave is free software; you can redistribute it and/or modify it |
|
7 under the terms of the GNU General Public License as published by the |
|
8 Free Software Foundation; either version 2, or (at your option) any |
|
9 later version. |
|
10 |
|
11 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 for more details. |
|
15 |
|
16 You should have received a copy of the GNU General Public License |
5307
|
17 along with this program; see the file COPYING. If not, write to the |
|
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
19 Boston, MA 02110-1301, USA. |
5164
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include <cassert> |
|
28 |
|
29 #include "Array-util.h" |
|
30 #include "oct-cmplx.h" |
|
31 #include "quit.h" |
|
32 #include "error.h" |
|
33 |
|
34 #include "dSparse.h" |
|
35 #include "CSparse.h" |
|
36 #include "oct-spparms.h" |
|
37 #include "sparse-xdiv.h" |
|
38 |
|
39 static inline bool |
5275
|
40 result_ok (octave_idx_type info) |
5164
|
41 { |
|
42 #ifdef HAVE_LSSOLVE |
|
43 return (info != -2 && info != -1); |
|
44 #else |
|
45 // If the matrix is singular, who cares as we don't have QR based solver yet |
|
46 return (info != -1); |
|
47 #endif |
|
48 } |
|
49 |
|
50 static void |
|
51 solve_singularity_warning (double rcond) |
|
52 { |
|
53 warning ("matrix singular to machine precision, rcond = %g", rcond); |
|
54 warning ("attempting to find minimum norm solution"); |
|
55 } |
|
56 |
|
57 template <class T1, class T2> |
|
58 bool |
|
59 mx_leftdiv_conform (const T1& a, const T2& b) |
|
60 { |
5275
|
61 octave_idx_type a_nr = a.rows (); |
|
62 octave_idx_type b_nr = b.rows (); |
5164
|
63 |
|
64 if (a_nr != b_nr) |
|
65 { |
5275
|
66 octave_idx_type a_nc = a.cols (); |
|
67 octave_idx_type b_nc = b.cols (); |
5164
|
68 |
|
69 gripe_nonconformant ("operator \\", a_nr, a_nc, b_nr, b_nc); |
|
70 return false; |
|
71 } |
|
72 |
|
73 return true; |
|
74 } |
|
75 |
|
76 #define INSTANTIATE_MX_LEFTDIV_CONFORM(T1, T2) \ |
|
77 template bool mx_leftdiv_conform (const T1&, const T2&) |
|
78 |
|
79 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, SparseMatrix); |
|
80 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, SparseComplexMatrix); |
|
81 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, SparseMatrix); |
|
82 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, SparseComplexMatrix); |
|
83 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, Matrix); |
|
84 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, ComplexMatrix); |
|
85 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, Matrix); |
|
86 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, ComplexMatrix); |
|
87 |
|
88 template <class T1, class T2> |
|
89 bool |
|
90 mx_div_conform (const T1& a, const T2& b) |
|
91 { |
5275
|
92 octave_idx_type a_nc = a.cols (); |
|
93 octave_idx_type b_nc = b.cols (); |
5164
|
94 |
|
95 if (a_nc != b_nc) |
|
96 { |
5275
|
97 octave_idx_type a_nr = a.rows (); |
|
98 octave_idx_type b_nr = b.rows (); |
5164
|
99 |
|
100 gripe_nonconformant ("operator /", a_nr, a_nc, b_nr, b_nc); |
|
101 return false; |
|
102 } |
|
103 |
|
104 return true; |
|
105 } |
|
106 |
|
107 #define INSTANTIATE_MX_DIV_CONFORM(T1, T2) \ |
|
108 template bool mx_div_conform (const T1&, const T2&) |
|
109 |
|
110 INSTANTIATE_MX_DIV_CONFORM (SparseMatrix, SparseMatrix); |
|
111 INSTANTIATE_MX_DIV_CONFORM (SparseMatrix, SparseComplexMatrix); |
|
112 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, SparseMatrix); |
|
113 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, SparseComplexMatrix); |
|
114 INSTANTIATE_MX_DIV_CONFORM (Matrix, SparseMatrix); |
|
115 INSTANTIATE_MX_DIV_CONFORM (Matrix, SparseComplexMatrix); |
|
116 INSTANTIATE_MX_DIV_CONFORM (ComplexMatrix, SparseMatrix); |
|
117 INSTANTIATE_MX_DIV_CONFORM (ComplexMatrix, SparseComplexMatrix); |
|
118 |
|
119 // Right division functions. |
|
120 // |
|
121 // op2 / op1: m cm sm scm |
|
122 // +-- +---+----+----+----+ |
|
123 // sparse matrix | 1 | 3 | 5 | 7 | |
|
124 // +---+----+----+----+ |
|
125 // sparse complex_matrix | 2 | 4 | 6 | 8 | |
|
126 // +---+----+----+----+ |
|
127 |
|
128 // -*- 1 -*- |
|
129 Matrix |
5322
|
130 xdiv (const Matrix& a, const SparseMatrix& b, SparseType &typ) |
5164
|
131 { |
|
132 if (! mx_div_conform (a, b)) |
|
133 return Matrix (); |
|
134 |
|
135 Matrix atmp = a.transpose (); |
|
136 SparseMatrix btmp = b.transpose (); |
5322
|
137 SparseType btyp = typ.transpose (); |
5164
|
138 |
5275
|
139 octave_idx_type info; |
5164
|
140 if (btmp.rows () == btmp.columns ()) |
|
141 { |
|
142 double rcond = 0.0; |
|
143 |
5322
|
144 Matrix result = btmp.solve (btyp, atmp, info, rcond, |
5164
|
145 solve_singularity_warning); |
|
146 |
|
147 if (result_ok (info)) |
5322
|
148 { |
|
149 typ = btyp.transpose (); |
|
150 return Matrix (result.transpose ()); |
|
151 } |
5164
|
152 } |
|
153 |
5275
|
154 octave_idx_type rank; |
5164
|
155 Matrix result = btmp.lssolve (atmp, info, rank); |
5322
|
156 typ = btyp.transpose (); |
5164
|
157 |
|
158 return result.transpose (); |
|
159 } |
|
160 |
|
161 // -*- 2 -*- |
|
162 ComplexMatrix |
5322
|
163 xdiv (const Matrix& a, const SparseComplexMatrix& b, SparseType &typ) |
5164
|
164 { |
|
165 if (! mx_div_conform (a, b)) |
|
166 return ComplexMatrix (); |
|
167 |
|
168 Matrix atmp = a.transpose (); |
|
169 SparseComplexMatrix btmp = b.hermitian (); |
5322
|
170 SparseType btyp = typ.transpose (); |
5164
|
171 |
5275
|
172 octave_idx_type info; |
5164
|
173 if (btmp.rows () == btmp.columns ()) |
|
174 { |
|
175 double rcond = 0.0; |
|
176 |
|
177 ComplexMatrix result |
5322
|
178 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); |
5164
|
179 |
|
180 if (result_ok (info)) |
5322
|
181 { |
|
182 typ = btyp.transpose (); |
|
183 return result.hermitian (); |
|
184 } |
5164
|
185 } |
|
186 |
5275
|
187 octave_idx_type rank; |
5164
|
188 ComplexMatrix result = btmp.lssolve (atmp, info, rank); |
5322
|
189 typ = btyp.transpose (); |
5164
|
190 |
|
191 return result.hermitian (); |
|
192 } |
|
193 |
|
194 // -*- 3 -*- |
|
195 ComplexMatrix |
5322
|
196 xdiv (const ComplexMatrix& a, const SparseMatrix& b, SparseType &typ) |
5164
|
197 { |
|
198 if (! mx_div_conform (a, b)) |
|
199 return ComplexMatrix (); |
|
200 |
|
201 ComplexMatrix atmp = a.hermitian (); |
|
202 SparseMatrix btmp = b.transpose (); |
5322
|
203 SparseType btyp = typ.transpose (); |
5164
|
204 |
5275
|
205 octave_idx_type info; |
5164
|
206 if (btmp.rows () == btmp.columns ()) |
|
207 { |
|
208 double rcond = 0.0; |
|
209 |
|
210 ComplexMatrix result |
5322
|
211 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); |
5164
|
212 |
|
213 if (result_ok (info)) |
5322
|
214 { |
|
215 typ = btyp.transpose (); |
|
216 return result.hermitian (); |
|
217 } |
5164
|
218 } |
|
219 |
5275
|
220 octave_idx_type rank; |
5164
|
221 ComplexMatrix result = btmp.lssolve (atmp, info, rank); |
5322
|
222 typ = btyp.transpose (); |
5164
|
223 |
|
224 return result.hermitian (); |
|
225 } |
|
226 |
|
227 // -*- 4 -*- |
|
228 ComplexMatrix |
5322
|
229 xdiv (const ComplexMatrix& a, const SparseComplexMatrix& b, SparseType &typ) |
5164
|
230 { |
|
231 if (! mx_div_conform (a, b)) |
|
232 return ComplexMatrix (); |
|
233 |
|
234 ComplexMatrix atmp = a.hermitian (); |
|
235 SparseComplexMatrix btmp = b.hermitian (); |
5322
|
236 SparseType btyp = typ.transpose (); |
5164
|
237 |
5275
|
238 octave_idx_type info; |
5164
|
239 if (btmp.rows () == btmp.columns ()) |
|
240 { |
|
241 double rcond = 0.0; |
|
242 |
|
243 ComplexMatrix result |
5322
|
244 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); |
5164
|
245 |
|
246 if (result_ok (info)) |
5322
|
247 { |
|
248 typ = btyp.transpose (); |
|
249 return result.hermitian (); |
|
250 } |
5164
|
251 } |
|
252 |
5275
|
253 octave_idx_type rank; |
5164
|
254 ComplexMatrix result = btmp.lssolve (atmp, info, rank); |
5322
|
255 typ = btyp.transpose (); |
5164
|
256 |
|
257 return result.hermitian (); |
|
258 } |
|
259 |
|
260 // -*- 5 -*- |
|
261 SparseMatrix |
5322
|
262 xdiv (const SparseMatrix& a, const SparseMatrix& b, SparseType &typ) |
5164
|
263 { |
|
264 if (! mx_div_conform (a, b)) |
|
265 return SparseMatrix (); |
|
266 |
|
267 SparseMatrix atmp = a.transpose (); |
|
268 SparseMatrix btmp = b.transpose (); |
5322
|
269 SparseType btyp = typ.transpose (); |
5164
|
270 |
5275
|
271 octave_idx_type info; |
5164
|
272 if (btmp.rows () == btmp.columns ()) |
|
273 { |
|
274 double rcond = 0.0; |
|
275 |
5322
|
276 SparseMatrix result = btmp.solve (btyp, atmp, info, rcond, |
5164
|
277 solve_singularity_warning); |
|
278 |
|
279 if (result_ok (info)) |
5322
|
280 { |
|
281 typ = btyp.transpose (); |
|
282 return SparseMatrix (result.transpose ()); |
|
283 } |
5164
|
284 } |
|
285 |
5275
|
286 octave_idx_type rank; |
5164
|
287 SparseMatrix result = btmp.lssolve (atmp, info, rank); |
5322
|
288 typ = btyp.transpose (); |
5164
|
289 |
|
290 return result.transpose (); |
|
291 } |
|
292 |
|
293 // -*- 6 -*- |
|
294 SparseComplexMatrix |
5322
|
295 xdiv (const SparseMatrix& a, const SparseComplexMatrix& b, SparseType &typ) |
5164
|
296 { |
|
297 if (! mx_div_conform (a, b)) |
|
298 return SparseComplexMatrix (); |
|
299 |
|
300 SparseMatrix atmp = a.transpose (); |
|
301 SparseComplexMatrix btmp = b.hermitian (); |
5322
|
302 SparseType btyp = typ.transpose (); |
5164
|
303 |
5275
|
304 octave_idx_type info; |
5164
|
305 if (btmp.rows () == btmp.columns ()) |
|
306 { |
|
307 double rcond = 0.0; |
|
308 |
|
309 SparseComplexMatrix result |
5322
|
310 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); |
5164
|
311 |
|
312 if (result_ok (info)) |
5322
|
313 { |
|
314 typ = btyp.transpose (); |
|
315 return result.hermitian (); |
|
316 } |
5164
|
317 } |
|
318 |
5275
|
319 octave_idx_type rank; |
5164
|
320 SparseComplexMatrix result = btmp.lssolve (atmp, info, rank); |
5322
|
321 typ = btyp.transpose (); |
5164
|
322 |
|
323 return result.hermitian (); |
|
324 } |
|
325 |
|
326 // -*- 7 -*- |
|
327 SparseComplexMatrix |
5322
|
328 xdiv (const SparseComplexMatrix& a, const SparseMatrix& b, SparseType &typ) |
5164
|
329 { |
|
330 if (! mx_div_conform (a, b)) |
|
331 return SparseComplexMatrix (); |
|
332 |
|
333 SparseComplexMatrix atmp = a.hermitian (); |
|
334 SparseMatrix btmp = b.transpose (); |
5322
|
335 SparseType btyp = typ.transpose (); |
5164
|
336 |
5275
|
337 octave_idx_type info; |
5164
|
338 if (btmp.rows () == btmp.columns ()) |
|
339 { |
|
340 double rcond = 0.0; |
|
341 |
|
342 SparseComplexMatrix result |
5322
|
343 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); |
5164
|
344 |
|
345 if (result_ok (info)) |
5322
|
346 { |
|
347 typ = btyp.transpose (); |
|
348 return result.hermitian (); |
|
349 } |
5164
|
350 } |
|
351 |
5275
|
352 octave_idx_type rank; |
5164
|
353 SparseComplexMatrix result = btmp.lssolve (atmp, info, rank); |
5322
|
354 typ = btyp.transpose (); |
5164
|
355 |
|
356 return result.hermitian (); |
|
357 } |
|
358 |
|
359 // -*- 8 -*- |
|
360 SparseComplexMatrix |
5322
|
361 xdiv (const SparseComplexMatrix& a, const SparseComplexMatrix& b, SparseType &typ) |
5164
|
362 { |
|
363 if (! mx_div_conform (a, b)) |
|
364 return SparseComplexMatrix (); |
|
365 |
|
366 SparseComplexMatrix atmp = a.hermitian (); |
|
367 SparseComplexMatrix btmp = b.hermitian (); |
5322
|
368 SparseType btyp = typ.transpose (); |
5164
|
369 |
5275
|
370 octave_idx_type info; |
5164
|
371 if (btmp.rows () == btmp.columns ()) |
|
372 { |
|
373 double rcond = 0.0; |
|
374 |
|
375 SparseComplexMatrix result |
5322
|
376 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); |
5164
|
377 |
|
378 if (result_ok (info)) |
5322
|
379 { |
|
380 typ = btyp.transpose (); |
|
381 return result.hermitian (); |
|
382 } |
5164
|
383 } |
|
384 |
5275
|
385 octave_idx_type rank; |
5164
|
386 SparseComplexMatrix result = btmp.lssolve (atmp, info, rank); |
5322
|
387 typ = btyp.transpose (); |
5164
|
388 |
|
389 return result.hermitian (); |
|
390 } |
|
391 |
|
392 // Funny element by element division operations. |
|
393 // |
|
394 // op2 \ op1: s cs |
|
395 // +-- +---+----+ |
|
396 // matrix | 1 | 3 | |
|
397 // +---+----+ |
|
398 // complex_matrix | 2 | 4 | |
|
399 // +---+----+ |
|
400 |
|
401 Matrix |
|
402 x_el_div (double a, const SparseMatrix& b) |
|
403 { |
5275
|
404 octave_idx_type nr = b.rows (); |
|
405 octave_idx_type nc = b.cols (); |
5164
|
406 |
|
407 Matrix result; |
|
408 if (a == 0.) |
|
409 result = Matrix (nr, nc, octave_NaN); |
|
410 else if (a > 0.) |
|
411 result = Matrix (nr, nc, octave_Inf); |
|
412 else |
|
413 result = Matrix (nr, nc, -octave_Inf); |
|
414 |
|
415 |
5275
|
416 for (octave_idx_type j = 0; j < nc; j++) |
|
417 for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++) |
5164
|
418 { |
|
419 OCTAVE_QUIT; |
|
420 result.elem (b.ridx(i), j) = a / b.data (i); |
|
421 } |
|
422 |
|
423 return result; |
|
424 } |
|
425 |
|
426 ComplexMatrix |
|
427 x_el_div (double a, const SparseComplexMatrix& b) |
|
428 { |
5275
|
429 octave_idx_type nr = b.rows (); |
|
430 octave_idx_type nc = b.cols (); |
5164
|
431 |
|
432 ComplexMatrix result (nr, nc, Complex(octave_NaN, octave_NaN)); |
|
433 |
5275
|
434 for (octave_idx_type j = 0; j < nc; j++) |
|
435 for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++) |
5164
|
436 { |
|
437 OCTAVE_QUIT; |
|
438 result.elem (b.ridx(i), j) = a / b.data (i); |
|
439 } |
|
440 |
|
441 return result; |
|
442 } |
|
443 |
|
444 ComplexMatrix |
|
445 x_el_div (const Complex a, const SparseMatrix& b) |
|
446 { |
5275
|
447 octave_idx_type nr = b.rows (); |
|
448 octave_idx_type nc = b.cols (); |
5164
|
449 |
|
450 ComplexMatrix result (nr, nc, (a / 0.0)); |
|
451 |
5275
|
452 for (octave_idx_type j = 0; j < nc; j++) |
|
453 for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++) |
5164
|
454 { |
|
455 OCTAVE_QUIT; |
|
456 result.elem (b.ridx(i), j) = a / b.data (i); |
|
457 } |
|
458 |
|
459 return result; |
|
460 } |
|
461 |
|
462 ComplexMatrix |
|
463 x_el_div (const Complex a, const SparseComplexMatrix& b) |
|
464 { |
5275
|
465 octave_idx_type nr = b.rows (); |
|
466 octave_idx_type nc = b.cols (); |
5164
|
467 |
|
468 ComplexMatrix result (nr, nc, (a / 0.0)); |
|
469 |
5275
|
470 for (octave_idx_type j = 0; j < nc; j++) |
|
471 for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++) |
5164
|
472 { |
|
473 OCTAVE_QUIT; |
|
474 result.elem (b.ridx(i), j) = a / b.data (i); |
|
475 } |
|
476 |
|
477 return result; |
|
478 } |
|
479 |
|
480 // Left division functions. |
|
481 // |
|
482 // op2 \ op1: m cm |
|
483 // +-- +---+----+ |
|
484 // matrix | 1 | 5 | |
|
485 // +---+----+ |
|
486 // complex_matrix | 2 | 6 | |
|
487 // +---+----+ |
|
488 // sparse matrix | 3 | 7 | |
|
489 // +---+----+ |
|
490 // sparse complex_matrix | 4 | 8 | |
|
491 // +---+----+ |
|
492 |
|
493 // -*- 1 -*- |
|
494 Matrix |
5322
|
495 xleftdiv (const SparseMatrix& a, const Matrix& b, SparseType &typ) |
5164
|
496 { |
|
497 if (! mx_leftdiv_conform (a, b)) |
|
498 return Matrix (); |
|
499 |
5275
|
500 octave_idx_type info; |
5164
|
501 if (a.rows () == a.columns ()) |
|
502 { |
|
503 double rcond = 0.0; |
|
504 |
|
505 Matrix result |
5322
|
506 = a.solve (typ, b, info, rcond, solve_singularity_warning); |
5164
|
507 |
|
508 if (result_ok (info)) |
|
509 return result; |
|
510 } |
|
511 |
5275
|
512 octave_idx_type rank; |
5164
|
513 return a.lssolve (b, info, rank); |
|
514 } |
|
515 |
|
516 // -*- 2 -*- |
|
517 ComplexMatrix |
5322
|
518 xleftdiv (const SparseMatrix& a, const ComplexMatrix& b, SparseType &typ) |
5164
|
519 { |
|
520 if (! mx_leftdiv_conform (a, b)) |
|
521 return ComplexMatrix (); |
|
522 |
5275
|
523 octave_idx_type info; |
5164
|
524 if (a.rows () == a.columns ()) |
|
525 { |
|
526 double rcond = 0.0; |
|
527 |
|
528 ComplexMatrix result |
5322
|
529 = a.solve (typ, b, info, rcond, solve_singularity_warning); |
5164
|
530 |
|
531 if (result_ok (info)) |
|
532 return result; |
|
533 } |
|
534 |
5275
|
535 octave_idx_type rank; |
5164
|
536 return a.lssolve (b, info, rank); |
|
537 } |
|
538 |
|
539 // -*- 3 -*- |
|
540 SparseMatrix |
5322
|
541 xleftdiv (const SparseMatrix& a, const SparseMatrix& b, SparseType &typ) |
5164
|
542 { |
|
543 if (! mx_leftdiv_conform (a, b)) |
|
544 return SparseMatrix (); |
|
545 |
5275
|
546 octave_idx_type info; |
5164
|
547 if (a.rows () == a.columns ()) |
|
548 { |
|
549 double rcond = 0.0; |
|
550 |
|
551 SparseMatrix result |
5322
|
552 = a.solve (typ, b, info, rcond, solve_singularity_warning); |
5164
|
553 |
|
554 if (result_ok (info)) |
|
555 return result; |
|
556 } |
|
557 |
5275
|
558 octave_idx_type rank; |
5164
|
559 return a.lssolve (b, info, rank); |
|
560 } |
|
561 |
|
562 // -*- 4 -*- |
|
563 SparseComplexMatrix |
5322
|
564 xleftdiv (const SparseMatrix& a, const SparseComplexMatrix& b, SparseType &typ) |
5164
|
565 { |
|
566 if (! mx_leftdiv_conform (a, b)) |
|
567 return SparseComplexMatrix (); |
|
568 |
5275
|
569 octave_idx_type info; |
5164
|
570 if (a.rows () == a.columns ()) |
|
571 { |
|
572 double rcond = 0.0; |
|
573 |
|
574 SparseComplexMatrix result |
5322
|
575 = a.solve (typ, b, info, rcond, solve_singularity_warning); |
5164
|
576 |
|
577 if (result_ok (info)) |
|
578 return result; |
|
579 } |
|
580 |
5275
|
581 octave_idx_type rank; |
5164
|
582 return a.lssolve (b, info, rank); |
|
583 } |
|
584 |
|
585 // -*- 5 -*- |
|
586 ComplexMatrix |
5322
|
587 xleftdiv (const SparseComplexMatrix& a, const Matrix& b, SparseType &typ) |
5164
|
588 { |
|
589 if (! mx_leftdiv_conform (a, b)) |
|
590 return ComplexMatrix (); |
|
591 |
5275
|
592 octave_idx_type info; |
5164
|
593 if (a.rows () == a.columns ()) |
|
594 { |
|
595 double rcond = 0.0; |
|
596 |
|
597 ComplexMatrix result |
5322
|
598 = a.solve (typ, b, info, rcond, solve_singularity_warning); |
5164
|
599 |
|
600 if (result_ok (info)) |
|
601 return result; |
|
602 } |
|
603 |
5275
|
604 octave_idx_type rank; |
5164
|
605 return a.lssolve (b, info, rank); |
|
606 } |
|
607 |
|
608 // -*- 6 -*- |
|
609 ComplexMatrix |
5322
|
610 xleftdiv (const SparseComplexMatrix& a, const ComplexMatrix& b, SparseType &typ) |
5164
|
611 { |
|
612 if (! mx_leftdiv_conform (a, b)) |
|
613 return ComplexMatrix (); |
|
614 |
5275
|
615 octave_idx_type info; |
5164
|
616 if (a.rows () == a.columns ()) |
|
617 { |
|
618 double rcond = 0.0; |
|
619 |
|
620 ComplexMatrix result |
5322
|
621 = a.solve (typ, b, info, rcond, solve_singularity_warning); |
5164
|
622 |
|
623 if (result_ok (info)) |
|
624 return result; |
|
625 } |
|
626 |
5275
|
627 octave_idx_type rank; |
5164
|
628 return a.lssolve (b, info, rank); |
|
629 } |
|
630 |
|
631 // -*- 7 -*- |
|
632 SparseComplexMatrix |
5322
|
633 xleftdiv (const SparseComplexMatrix& a, const SparseMatrix& b, SparseType &typ) |
5164
|
634 { |
|
635 if (! mx_leftdiv_conform (a, b)) |
|
636 return SparseComplexMatrix (); |
|
637 |
5275
|
638 octave_idx_type info; |
5164
|
639 if (a.rows () == a.columns ()) |
|
640 { |
|
641 double rcond = 0.0; |
|
642 |
|
643 SparseComplexMatrix result |
5322
|
644 = a.solve (typ, b, info, rcond, solve_singularity_warning); |
5164
|
645 |
|
646 if (result_ok (info)) |
|
647 return result; |
|
648 } |
|
649 |
5275
|
650 octave_idx_type rank; |
5164
|
651 return a.lssolve (b, info, rank); |
|
652 } |
|
653 |
|
654 // -*- 8 -*- |
|
655 SparseComplexMatrix |
5322
|
656 xleftdiv (const SparseComplexMatrix& a, const SparseComplexMatrix& b, |
|
657 SparseType &typ) |
5164
|
658 { |
|
659 if (! mx_leftdiv_conform (a, b)) |
|
660 return SparseComplexMatrix (); |
|
661 |
5275
|
662 octave_idx_type info; |
5164
|
663 if (a.rows () == a.columns ()) |
|
664 { |
|
665 double rcond = 0.0; |
|
666 |
|
667 SparseComplexMatrix result |
5322
|
668 = a.solve (typ, b, info, rcond, solve_singularity_warning); |
5164
|
669 |
|
670 if (result_ok (info)) |
|
671 return result; |
|
672 } |
|
673 |
5275
|
674 octave_idx_type rank; |
5164
|
675 return a.lssolve (b, info, rank); |
|
676 } |
|
677 |
|
678 /* |
|
679 ;;; Local Variables: *** |
|
680 ;;; mode: C++ *** |
|
681 ;;; End: *** |
|
682 */ |