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