comparison src/sparse-xdiv.cc @ 5322:22994a5730f9

[project @ 2005-04-29 13:04:24 by dbateman]
author dbateman
date Fri, 29 Apr 2005 13:04:25 +0000
parents 4c8a2e4e0717
children 9761b7d24e9e
comparison
equal deleted inserted replaced
5321:84b72a402b86 5322:22994a5730f9
125 // sparse complex_matrix | 2 | 4 | 6 | 8 | 125 // sparse complex_matrix | 2 | 4 | 6 | 8 |
126 // +---+----+----+----+ 126 // +---+----+----+----+
127 127
128 // -*- 1 -*- 128 // -*- 1 -*-
129 Matrix 129 Matrix
130 xdiv (const Matrix& a, const SparseMatrix& b) 130 xdiv (const Matrix& a, const SparseMatrix& b, SparseType &typ)
131 { 131 {
132 if (! mx_div_conform (a, b)) 132 if (! mx_div_conform (a, b))
133 return Matrix (); 133 return Matrix ();
134 134
135 Matrix atmp = a.transpose (); 135 Matrix atmp = a.transpose ();
136 SparseMatrix btmp = b.transpose (); 136 SparseMatrix btmp = b.transpose ();
137 137 SparseType btyp = typ.transpose ();
138 octave_idx_type info; 138
139 if (btmp.rows () == btmp.columns ()) 139 octave_idx_type info;
140 { 140 if (btmp.rows () == btmp.columns ())
141 double rcond = 0.0; 141 {
142 142 double rcond = 0.0;
143 Matrix result = btmp.solve (atmp, info, rcond, 143
144 Matrix result = btmp.solve (btyp, atmp, info, rcond,
144 solve_singularity_warning); 145 solve_singularity_warning);
145 146
146 if (result_ok (info)) 147 if (result_ok (info))
147 return Matrix (result.transpose ()); 148 {
149 typ = btyp.transpose ();
150 return Matrix (result.transpose ());
151 }
148 } 152 }
149 153
150 octave_idx_type rank; 154 octave_idx_type rank;
151 Matrix result = btmp.lssolve (atmp, info, rank); 155 Matrix result = btmp.lssolve (atmp, info, rank);
156 typ = btyp.transpose ();
152 157
153 return result.transpose (); 158 return result.transpose ();
154 } 159 }
155 160
156 // -*- 2 -*- 161 // -*- 2 -*-
157 ComplexMatrix 162 ComplexMatrix
158 xdiv (const Matrix& a, const SparseComplexMatrix& b) 163 xdiv (const Matrix& a, const SparseComplexMatrix& b, SparseType &typ)
159 { 164 {
160 if (! mx_div_conform (a, b)) 165 if (! mx_div_conform (a, b))
161 return ComplexMatrix (); 166 return ComplexMatrix ();
162 167
163 Matrix atmp = a.transpose (); 168 Matrix atmp = a.transpose ();
164 SparseComplexMatrix btmp = b.hermitian (); 169 SparseComplexMatrix btmp = b.hermitian ();
170 SparseType btyp = typ.transpose ();
165 171
166 octave_idx_type info; 172 octave_idx_type info;
167 if (btmp.rows () == btmp.columns ()) 173 if (btmp.rows () == btmp.columns ())
168 { 174 {
169 double rcond = 0.0; 175 double rcond = 0.0;
170 176
171 ComplexMatrix result 177 ComplexMatrix result
172 = btmp.solve (atmp, info, rcond, solve_singularity_warning); 178 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
173 179
174 if (result_ok (info)) 180 if (result_ok (info))
175 return result.hermitian (); 181 {
182 typ = btyp.transpose ();
183 return result.hermitian ();
184 }
176 } 185 }
177 186
178 octave_idx_type rank; 187 octave_idx_type rank;
179 ComplexMatrix result = btmp.lssolve (atmp, info, rank); 188 ComplexMatrix result = btmp.lssolve (atmp, info, rank);
189 typ = btyp.transpose ();
180 190
181 return result.hermitian (); 191 return result.hermitian ();
182 } 192 }
183 193
184 // -*- 3 -*- 194 // -*- 3 -*-
185 ComplexMatrix 195 ComplexMatrix
186 xdiv (const ComplexMatrix& a, const SparseMatrix& b) 196 xdiv (const ComplexMatrix& a, const SparseMatrix& b, SparseType &typ)
187 { 197 {
188 if (! mx_div_conform (a, b)) 198 if (! mx_div_conform (a, b))
189 return ComplexMatrix (); 199 return ComplexMatrix ();
190 200
191 ComplexMatrix atmp = a.hermitian (); 201 ComplexMatrix atmp = a.hermitian ();
192 SparseMatrix btmp = b.transpose (); 202 SparseMatrix btmp = b.transpose ();
203 SparseType btyp = typ.transpose ();
193 204
194 octave_idx_type info; 205 octave_idx_type info;
195 if (btmp.rows () == btmp.columns ()) 206 if (btmp.rows () == btmp.columns ())
196 { 207 {
197 double rcond = 0.0; 208 double rcond = 0.0;
198 209
199 ComplexMatrix result 210 ComplexMatrix result
200 = btmp.solve (atmp, info, rcond, solve_singularity_warning); 211 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
201 212
202 if (result_ok (info)) 213 if (result_ok (info))
203 return result.hermitian (); 214 {
215 typ = btyp.transpose ();
216 return result.hermitian ();
217 }
204 } 218 }
205 219
206 octave_idx_type rank; 220 octave_idx_type rank;
207 ComplexMatrix result = btmp.lssolve (atmp, info, rank); 221 ComplexMatrix result = btmp.lssolve (atmp, info, rank);
222 typ = btyp.transpose ();
208 223
209 return result.hermitian (); 224 return result.hermitian ();
210 } 225 }
211 226
212 // -*- 4 -*- 227 // -*- 4 -*-
213 ComplexMatrix 228 ComplexMatrix
214 xdiv (const ComplexMatrix& a, const SparseComplexMatrix& b) 229 xdiv (const ComplexMatrix& a, const SparseComplexMatrix& b, SparseType &typ)
215 { 230 {
216 if (! mx_div_conform (a, b)) 231 if (! mx_div_conform (a, b))
217 return ComplexMatrix (); 232 return ComplexMatrix ();
218 233
219 ComplexMatrix atmp = a.hermitian (); 234 ComplexMatrix atmp = a.hermitian ();
220 SparseComplexMatrix btmp = b.hermitian (); 235 SparseComplexMatrix btmp = b.hermitian ();
236 SparseType btyp = typ.transpose ();
221 237
222 octave_idx_type info; 238 octave_idx_type info;
223 if (btmp.rows () == btmp.columns ()) 239 if (btmp.rows () == btmp.columns ())
224 { 240 {
225 double rcond = 0.0; 241 double rcond = 0.0;
226 242
227 ComplexMatrix result 243 ComplexMatrix result
228 = btmp.solve (atmp, info, rcond, solve_singularity_warning); 244 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
229 245
230 if (result_ok (info)) 246 if (result_ok (info))
231 return result.hermitian (); 247 {
248 typ = btyp.transpose ();
249 return result.hermitian ();
250 }
232 } 251 }
233 252
234 octave_idx_type rank; 253 octave_idx_type rank;
235 ComplexMatrix result = btmp.lssolve (atmp, info, rank); 254 ComplexMatrix result = btmp.lssolve (atmp, info, rank);
255 typ = btyp.transpose ();
236 256
237 return result.hermitian (); 257 return result.hermitian ();
238 } 258 }
239 259
240 // -*- 5 -*- 260 // -*- 5 -*-
241 SparseMatrix 261 SparseMatrix
242 xdiv (const SparseMatrix& a, const SparseMatrix& b) 262 xdiv (const SparseMatrix& a, const SparseMatrix& b, SparseType &typ)
243 { 263 {
244 if (! mx_div_conform (a, b)) 264 if (! mx_div_conform (a, b))
245 return SparseMatrix (); 265 return SparseMatrix ();
246 266
247 SparseMatrix atmp = a.transpose (); 267 SparseMatrix atmp = a.transpose ();
248 SparseMatrix btmp = b.transpose (); 268 SparseMatrix btmp = b.transpose ();
249 269 SparseType btyp = typ.transpose ();
250 octave_idx_type info; 270
251 if (btmp.rows () == btmp.columns ()) 271 octave_idx_type info;
252 { 272 if (btmp.rows () == btmp.columns ())
253 double rcond = 0.0; 273 {
254 274 double rcond = 0.0;
255 SparseMatrix result = btmp.solve (atmp, info, rcond, 275
276 SparseMatrix result = btmp.solve (btyp, atmp, info, rcond,
256 solve_singularity_warning); 277 solve_singularity_warning);
257 278
258 if (result_ok (info)) 279 if (result_ok (info))
259 return SparseMatrix (result.transpose ()); 280 {
281 typ = btyp.transpose ();
282 return SparseMatrix (result.transpose ());
283 }
260 } 284 }
261 285
262 octave_idx_type rank; 286 octave_idx_type rank;
263 SparseMatrix result = btmp.lssolve (atmp, info, rank); 287 SparseMatrix result = btmp.lssolve (atmp, info, rank);
288 typ = btyp.transpose ();
264 289
265 return result.transpose (); 290 return result.transpose ();
266 } 291 }
267 292
268 // -*- 6 -*- 293 // -*- 6 -*-
269 SparseComplexMatrix 294 SparseComplexMatrix
270 xdiv (const SparseMatrix& a, const SparseComplexMatrix& b) 295 xdiv (const SparseMatrix& a, const SparseComplexMatrix& b, SparseType &typ)
271 { 296 {
272 if (! mx_div_conform (a, b)) 297 if (! mx_div_conform (a, b))
273 return SparseComplexMatrix (); 298 return SparseComplexMatrix ();
274 299
275 SparseMatrix atmp = a.transpose (); 300 SparseMatrix atmp = a.transpose ();
276 SparseComplexMatrix btmp = b.hermitian (); 301 SparseComplexMatrix btmp = b.hermitian ();
302 SparseType btyp = typ.transpose ();
277 303
278 octave_idx_type info; 304 octave_idx_type info;
279 if (btmp.rows () == btmp.columns ()) 305 if (btmp.rows () == btmp.columns ())
280 { 306 {
281 double rcond = 0.0; 307 double rcond = 0.0;
282 308
283 SparseComplexMatrix result 309 SparseComplexMatrix result
284 = btmp.solve (atmp, info, rcond, solve_singularity_warning); 310 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
285 311
286 if (result_ok (info)) 312 if (result_ok (info))
287 return result.hermitian (); 313 {
314 typ = btyp.transpose ();
315 return result.hermitian ();
316 }
288 } 317 }
289 318
290 octave_idx_type rank; 319 octave_idx_type rank;
291 SparseComplexMatrix result = btmp.lssolve (atmp, info, rank); 320 SparseComplexMatrix result = btmp.lssolve (atmp, info, rank);
321 typ = btyp.transpose ();
292 322
293 return result.hermitian (); 323 return result.hermitian ();
294 } 324 }
295 325
296 // -*- 7 -*- 326 // -*- 7 -*-
297 SparseComplexMatrix 327 SparseComplexMatrix
298 xdiv (const SparseComplexMatrix& a, const SparseMatrix& b) 328 xdiv (const SparseComplexMatrix& a, const SparseMatrix& b, SparseType &typ)
299 { 329 {
300 if (! mx_div_conform (a, b)) 330 if (! mx_div_conform (a, b))
301 return SparseComplexMatrix (); 331 return SparseComplexMatrix ();
302 332
303 SparseComplexMatrix atmp = a.hermitian (); 333 SparseComplexMatrix atmp = a.hermitian ();
304 SparseMatrix btmp = b.transpose (); 334 SparseMatrix btmp = b.transpose ();
335 SparseType btyp = typ.transpose ();
305 336
306 octave_idx_type info; 337 octave_idx_type info;
307 if (btmp.rows () == btmp.columns ()) 338 if (btmp.rows () == btmp.columns ())
308 { 339 {
309 double rcond = 0.0; 340 double rcond = 0.0;
310 341
311 SparseComplexMatrix result 342 SparseComplexMatrix result
312 = btmp.solve (atmp, info, rcond, solve_singularity_warning); 343 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
313 344
314 if (result_ok (info)) 345 if (result_ok (info))
315 return result.hermitian (); 346 {
347 typ = btyp.transpose ();
348 return result.hermitian ();
349 }
316 } 350 }
317 351
318 octave_idx_type rank; 352 octave_idx_type rank;
319 SparseComplexMatrix result = btmp.lssolve (atmp, info, rank); 353 SparseComplexMatrix result = btmp.lssolve (atmp, info, rank);
354 typ = btyp.transpose ();
320 355
321 return result.hermitian (); 356 return result.hermitian ();
322 } 357 }
323 358
324 // -*- 8 -*- 359 // -*- 8 -*-
325 SparseComplexMatrix 360 SparseComplexMatrix
326 xdiv (const SparseComplexMatrix& a, const SparseComplexMatrix& b) 361 xdiv (const SparseComplexMatrix& a, const SparseComplexMatrix& b, SparseType &typ)
327 { 362 {
328 if (! mx_div_conform (a, b)) 363 if (! mx_div_conform (a, b))
329 return SparseComplexMatrix (); 364 return SparseComplexMatrix ();
330 365
331 SparseComplexMatrix atmp = a.hermitian (); 366 SparseComplexMatrix atmp = a.hermitian ();
332 SparseComplexMatrix btmp = b.hermitian (); 367 SparseComplexMatrix btmp = b.hermitian ();
368 SparseType btyp = typ.transpose ();
333 369
334 octave_idx_type info; 370 octave_idx_type info;
335 if (btmp.rows () == btmp.columns ()) 371 if (btmp.rows () == btmp.columns ())
336 { 372 {
337 double rcond = 0.0; 373 double rcond = 0.0;
338 374
339 SparseComplexMatrix result 375 SparseComplexMatrix result
340 = btmp.solve (atmp, info, rcond, solve_singularity_warning); 376 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning);
341 377
342 if (result_ok (info)) 378 if (result_ok (info))
343 return result.hermitian (); 379 {
380 typ = btyp.transpose ();
381 return result.hermitian ();
382 }
344 } 383 }
345 384
346 octave_idx_type rank; 385 octave_idx_type rank;
347 SparseComplexMatrix result = btmp.lssolve (atmp, info, rank); 386 SparseComplexMatrix result = btmp.lssolve (atmp, info, rank);
387 typ = btyp.transpose ();
348 388
349 return result.hermitian (); 389 return result.hermitian ();
350 } 390 }
351 391
352 // Funny element by element division operations. 392 // Funny element by element division operations.
450 // sparse complex_matrix | 4 | 8 | 490 // sparse complex_matrix | 4 | 8 |
451 // +---+----+ 491 // +---+----+
452 492
453 // -*- 1 -*- 493 // -*- 1 -*-
454 Matrix 494 Matrix
455 xleftdiv (const SparseMatrix& a, const Matrix& b) 495 xleftdiv (const SparseMatrix& a, const Matrix& b, SparseType &typ)
456 { 496 {
457 if (! mx_leftdiv_conform (a, b)) 497 if (! mx_leftdiv_conform (a, b))
458 return Matrix (); 498 return Matrix ();
459 499
460 octave_idx_type info; 500 octave_idx_type info;
461 if (a.rows () == a.columns ()) 501 if (a.rows () == a.columns ())
462 { 502 {
463 double rcond = 0.0; 503 double rcond = 0.0;
464 504
465 Matrix result 505 Matrix result
466 = a.solve (b, info, rcond, solve_singularity_warning); 506 = a.solve (typ, b, info, rcond, solve_singularity_warning);
467 507
468 if (result_ok (info)) 508 if (result_ok (info))
469 return result; 509 return result;
470 } 510 }
471 511
473 return a.lssolve (b, info, rank); 513 return a.lssolve (b, info, rank);
474 } 514 }
475 515
476 // -*- 2 -*- 516 // -*- 2 -*-
477 ComplexMatrix 517 ComplexMatrix
478 xleftdiv (const SparseMatrix& a, const ComplexMatrix& b) 518 xleftdiv (const SparseMatrix& a, const ComplexMatrix& b, SparseType &typ)
479 { 519 {
480 if (! mx_leftdiv_conform (a, b)) 520 if (! mx_leftdiv_conform (a, b))
481 return ComplexMatrix (); 521 return ComplexMatrix ();
482 522
483 octave_idx_type info; 523 octave_idx_type info;
484 if (a.rows () == a.columns ()) 524 if (a.rows () == a.columns ())
485 { 525 {
486 double rcond = 0.0; 526 double rcond = 0.0;
487 527
488 ComplexMatrix result 528 ComplexMatrix result
489 = a.solve (b, info, rcond, solve_singularity_warning); 529 = a.solve (typ, b, info, rcond, solve_singularity_warning);
490 530
491 if (result_ok (info)) 531 if (result_ok (info))
492 return result; 532 return result;
493 } 533 }
494 534
496 return a.lssolve (b, info, rank); 536 return a.lssolve (b, info, rank);
497 } 537 }
498 538
499 // -*- 3 -*- 539 // -*- 3 -*-
500 SparseMatrix 540 SparseMatrix
501 xleftdiv (const SparseMatrix& a, const SparseMatrix& b) 541 xleftdiv (const SparseMatrix& a, const SparseMatrix& b, SparseType &typ)
502 { 542 {
503 if (! mx_leftdiv_conform (a, b)) 543 if (! mx_leftdiv_conform (a, b))
504 return SparseMatrix (); 544 return SparseMatrix ();
505 545
506 octave_idx_type info; 546 octave_idx_type info;
507 if (a.rows () == a.columns ()) 547 if (a.rows () == a.columns ())
508 { 548 {
509 double rcond = 0.0; 549 double rcond = 0.0;
510 550
511 SparseMatrix result 551 SparseMatrix result
512 = a.solve (b, info, rcond, solve_singularity_warning); 552 = a.solve (typ, b, info, rcond, solve_singularity_warning);
513 553
514 if (result_ok (info)) 554 if (result_ok (info))
515 return result; 555 return result;
516 } 556 }
517 557
519 return a.lssolve (b, info, rank); 559 return a.lssolve (b, info, rank);
520 } 560 }
521 561
522 // -*- 4 -*- 562 // -*- 4 -*-
523 SparseComplexMatrix 563 SparseComplexMatrix
524 xleftdiv (const SparseMatrix& a, const SparseComplexMatrix& b) 564 xleftdiv (const SparseMatrix& a, const SparseComplexMatrix& b, SparseType &typ)
525 { 565 {
526 if (! mx_leftdiv_conform (a, b)) 566 if (! mx_leftdiv_conform (a, b))
527 return SparseComplexMatrix (); 567 return SparseComplexMatrix ();
528 568
529 octave_idx_type info; 569 octave_idx_type info;
530 if (a.rows () == a.columns ()) 570 if (a.rows () == a.columns ())
531 { 571 {
532 double rcond = 0.0; 572 double rcond = 0.0;
533 573
534 SparseComplexMatrix result 574 SparseComplexMatrix result
535 = a.solve (b, info, rcond, solve_singularity_warning); 575 = a.solve (typ, b, info, rcond, solve_singularity_warning);
536 576
537 if (result_ok (info)) 577 if (result_ok (info))
538 return result; 578 return result;
539 } 579 }
540 580
542 return a.lssolve (b, info, rank); 582 return a.lssolve (b, info, rank);
543 } 583 }
544 584
545 // -*- 5 -*- 585 // -*- 5 -*-
546 ComplexMatrix 586 ComplexMatrix
547 xleftdiv (const SparseComplexMatrix& a, const Matrix& b) 587 xleftdiv (const SparseComplexMatrix& a, const Matrix& b, SparseType &typ)
548 { 588 {
549 if (! mx_leftdiv_conform (a, b)) 589 if (! mx_leftdiv_conform (a, b))
550 return ComplexMatrix (); 590 return ComplexMatrix ();
551 591
552 octave_idx_type info; 592 octave_idx_type info;
553 if (a.rows () == a.columns ()) 593 if (a.rows () == a.columns ())
554 { 594 {
555 double rcond = 0.0; 595 double rcond = 0.0;
556 596
557 ComplexMatrix result 597 ComplexMatrix result
558 = a.solve (b, info, rcond, solve_singularity_warning); 598 = a.solve (typ, b, info, rcond, solve_singularity_warning);
559 599
560 if (result_ok (info)) 600 if (result_ok (info))
561 return result; 601 return result;
562 } 602 }
563 603
565 return a.lssolve (b, info, rank); 605 return a.lssolve (b, info, rank);
566 } 606 }
567 607
568 // -*- 6 -*- 608 // -*- 6 -*-
569 ComplexMatrix 609 ComplexMatrix
570 xleftdiv (const SparseComplexMatrix& a, const ComplexMatrix& b) 610 xleftdiv (const SparseComplexMatrix& a, const ComplexMatrix& b, SparseType &typ)
571 { 611 {
572 if (! mx_leftdiv_conform (a, b)) 612 if (! mx_leftdiv_conform (a, b))
573 return ComplexMatrix (); 613 return ComplexMatrix ();
574 614
575 octave_idx_type info; 615 octave_idx_type info;
576 if (a.rows () == a.columns ()) 616 if (a.rows () == a.columns ())
577 { 617 {
578 double rcond = 0.0; 618 double rcond = 0.0;
579 619
580 ComplexMatrix result 620 ComplexMatrix result
581 = a.solve (b, info, rcond, solve_singularity_warning); 621 = a.solve (typ, b, info, rcond, solve_singularity_warning);
582 622
583 if (result_ok (info)) 623 if (result_ok (info))
584 return result; 624 return result;
585 } 625 }
586 626
588 return a.lssolve (b, info, rank); 628 return a.lssolve (b, info, rank);
589 } 629 }
590 630
591 // -*- 7 -*- 631 // -*- 7 -*-
592 SparseComplexMatrix 632 SparseComplexMatrix
593 xleftdiv (const SparseComplexMatrix& a, const SparseMatrix& b) 633 xleftdiv (const SparseComplexMatrix& a, const SparseMatrix& b, SparseType &typ)
594 { 634 {
595 if (! mx_leftdiv_conform (a, b)) 635 if (! mx_leftdiv_conform (a, b))
596 return SparseComplexMatrix (); 636 return SparseComplexMatrix ();
597 637
598 octave_idx_type info; 638 octave_idx_type info;
599 if (a.rows () == a.columns ()) 639 if (a.rows () == a.columns ())
600 { 640 {
601 double rcond = 0.0; 641 double rcond = 0.0;
602 642
603 SparseComplexMatrix result 643 SparseComplexMatrix result
604 = a.solve (b, info, rcond, solve_singularity_warning); 644 = a.solve (typ, b, info, rcond, solve_singularity_warning);
605 645
606 if (result_ok (info)) 646 if (result_ok (info))
607 return result; 647 return result;
608 } 648 }
609 649
611 return a.lssolve (b, info, rank); 651 return a.lssolve (b, info, rank);
612 } 652 }
613 653
614 // -*- 8 -*- 654 // -*- 8 -*-
615 SparseComplexMatrix 655 SparseComplexMatrix
616 xleftdiv (const SparseComplexMatrix& a, const SparseComplexMatrix& b) 656 xleftdiv (const SparseComplexMatrix& a, const SparseComplexMatrix& b,
657 SparseType &typ)
617 { 658 {
618 if (! mx_leftdiv_conform (a, b)) 659 if (! mx_leftdiv_conform (a, b))
619 return SparseComplexMatrix (); 660 return SparseComplexMatrix ();
620 661
621 octave_idx_type info; 662 octave_idx_type info;
622 if (a.rows () == a.columns ()) 663 if (a.rows () == a.columns ())
623 { 664 {
624 double rcond = 0.0; 665 double rcond = 0.0;
625 666
626 SparseComplexMatrix result 667 SparseComplexMatrix result
627 = a.solve (b, info, rcond, solve_singularity_warning); 668 = a.solve (typ, b, info, rcond, solve_singularity_warning);
628 669
629 if (result_ok (info)) 670 if (result_ok (info))
630 return result; 671 return result;
631 } 672 }
632 673