comparison src/sparse-xpow.cc @ 11586:12df7854fa7c

strip trailing whitespace from source files
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:24:59 -0500
parents fd0a3ac60b0e
children 1bf8c244040a
comparison
equal deleted inserted replaced
11585:1473d0cf86d2 11586:12df7854fa7c
299 299
300 // -*- 3 -*- 300 // -*- 3 -*-
301 octave_value 301 octave_value
302 elem_xpow (const SparseMatrix& a, double b) 302 elem_xpow (const SparseMatrix& a, double b)
303 { 303 {
304 // FIXME What should a .^ 0 give?? Matlab gives a 304 // FIXME What should a .^ 0 give?? Matlab gives a
305 // sparse matrix with same structure as a, which is strictly 305 // sparse matrix with same structure as a, which is strictly
306 // incorrect. Keep compatiability. 306 // incorrect. Keep compatiability.
307 307
308 octave_value retval; 308 octave_value retval;
309 309
324 324
325 for (octave_idx_type j = 0; j < nc; j++) 325 for (octave_idx_type j = 0; j < nc; j++)
326 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 326 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
327 { 327 {
328 octave_quit (); 328 octave_quit ();
329 329
330 Complex atmp (a.data (i)); 330 Complex atmp (a.data (i));
331 331
332 result (a.ridx(i), j) = std::pow (atmp, btmp); 332 result (a.ridx(i), j) = std::pow (atmp, btmp);
333 } 333 }
334 334
335 retval = octave_value (result); 335 retval = octave_value (result);
336 } 336 }
450 for (octave_idx_type j = 0; j < nc; j++) 450 for (octave_idx_type j = 0; j < nc; j++)
451 { 451 {
452 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 452 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
453 { 453 {
454 octave_quit (); 454 octave_quit ();
455 result.xelem(a.ridx(i), j) = std::pow (a.data(i), 455 result.xelem(a.ridx(i), j) = std::pow (a.data(i),
456 b (a.ridx(i), j)); 456 b (a.ridx(i), j));
457 } 457 }
458 } 458 }
459 result.maybe_compress (true); 459 result.maybe_compress (true);
460 retval = result; 460 retval = result;
474 retval = octave_value (NDArray (a.dims (), 1)); 474 retval = octave_value (NDArray (a.dims (), 1));
475 else 475 else
476 { 476 {
477 octave_idx_type nz = a.nnz (); 477 octave_idx_type nz = a.nnz ();
478 SparseComplexMatrix result (a); 478 SparseComplexMatrix result (a);
479 479
480 for (octave_idx_type i = 0; i < nz; i++) 480 for (octave_idx_type i = 0; i < nz; i++)
481 { 481 {
482 octave_quit (); 482 octave_quit ();
483 result.data (i) = std::pow (Complex (a.data (i)), b); 483 result.data (i) = std::pow (Complex (a.data (i)), b);
484 } 484 }
485 485
486 result.maybe_compress (true); 486 result.maybe_compress (true);
487 487
488 retval = result; 488 retval = result;
489 } 489 }
490 490
582 { 582 {
583 for (octave_idx_type j = 0; j < nc; j++) 583 for (octave_idx_type j = 0; j < nc; j++)
584 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 584 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
585 { 585 {
586 octave_quit (); 586 octave_quit ();
587 result (a.ridx(i), j) = 587 result (a.ridx(i), j) =
588 std::pow (a.data (i), static_cast<int> (b)); 588 std::pow (a.data (i), static_cast<int> (b));
589 } 589 }
590 } 590 }
591 else 591 else
592 { 592 {
594 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 594 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
595 { 595 {
596 octave_quit (); 596 octave_quit ();
597 result (a.ridx(i), j) = std::pow (a.data (i), b); 597 result (a.ridx(i), j) = std::pow (a.data (i), b);
598 } 598 }
599 } 599 }
600 600
601 retval = result; 601 retval = result;
602 } 602 }
603 else 603 else
604 { 604 {
605 octave_idx_type nz = a.nnz (); 605 octave_idx_type nz = a.nnz ();
606 606
607 SparseComplexMatrix result (a); 607 SparseComplexMatrix result (a);
608 608
609 if (xisint (b)) 609 if (xisint (b))
610 { 610 {
611 for (octave_idx_type i = 0; i < nz; i++) 611 for (octave_idx_type i = 0; i < nz; i++)
612 { 612 {
613 octave_quit (); 613 octave_quit ();
619 for (octave_idx_type i = 0; i < nz; i++) 619 for (octave_idx_type i = 0; i < nz; i++)
620 { 620 {
621 octave_quit (); 621 octave_quit ();
622 result.data (i) = std::pow (a.data (i), b); 622 result.data (i) = std::pow (a.data (i), b);
623 } 623 }
624 } 624 }
625 625
626 result.maybe_compress (true); 626 result.maybe_compress (true);
627 627
628 retval = result; 628 retval = result;
629 } 629 }
655 octave_quit (); 655 octave_quit ();
656 double btmp = b (a.ridx(i), j); 656 double btmp = b (a.ridx(i), j);
657 Complex tmp; 657 Complex tmp;
658 658
659 if (xisint (btmp)) 659 if (xisint (btmp))
660 result.xelem(a.ridx(i), j) = std::pow (a.data (i), 660 result.xelem(a.ridx(i), j) = std::pow (a.data (i),
661 static_cast<int> (btmp)); 661 static_cast<int> (btmp));
662 else 662 else
663 result.xelem(a.ridx(i), j) = std::pow (a.data (i), btmp); 663 result.xelem(a.ridx(i), j) = std::pow (a.data (i), btmp);
664 } 664 }
665 } 665 }
690 octave_quit (); 690 octave_quit ();
691 result.data (i) = std::pow (a.data (i), b); 691 result.data (i) = std::pow (a.data (i), b);
692 } 692 }
693 693
694 result.maybe_compress (true); 694 result.maybe_compress (true);
695 695
696 retval = result; 696 retval = result;
697 } 697 }
698 698
699 return retval; 699 return retval;
700 } 700 }
714 gripe_nonconformant ("operator .^", nr, nc, b_nr, b_nc); 714 gripe_nonconformant ("operator .^", nr, nc, b_nr, b_nc);
715 return octave_value (); 715 return octave_value ();
716 } 716 }
717 717
718 SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0)); 718 SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0));
719 for (octave_idx_type j = 0; j < nc; j++) 719 for (octave_idx_type j = 0; j < nc; j++)
720 { 720 {
721 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) 721 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
722 { 722 {
723 octave_quit (); 723 octave_quit ();
724 result.xelem(a.ridx(i), j) = std::pow (a.data (i), b (a.ridx(i), j)); 724 result.xelem(a.ridx(i), j) = std::pow (a.data (i), b (a.ridx(i), j));