Mercurial > hg > octave-nkf
comparison src/xpow.cc @ 5260:deed800e7bef
[project @ 2005-03-30 23:18:58 by jwe]
author | jwe |
---|---|
date | Wed, 30 Mar 2005 23:18:58 +0000 |
parents | 91a84c9bdadb |
children | 23b37da9fd5b |
comparison
equal
deleted
inserted
replaced
5259:462fd886f33f | 5260:deed800e7bef |
---|---|
68 octave_value | 68 octave_value |
69 xpow (double a, double b) | 69 xpow (double a, double b) |
70 { | 70 { |
71 if (a < 0.0 && static_cast<int> (b) != b) | 71 if (a < 0.0 && static_cast<int> (b) != b) |
72 { | 72 { |
73 // XXX FIXME XXX -- avoid apparent GNU libm bug by converting | |
74 // A and B to complex instead of just A. | |
75 | |
76 Complex atmp (a); | 73 Complex atmp (a); |
77 Complex btmp (b); | 74 |
78 | 75 return std::pow (atmp, b); |
79 return pow (atmp, btmp); | 76 } |
80 } | 77 else |
81 else | 78 return std::pow (a, b); |
82 return pow (a, b); | |
83 } | 79 } |
84 | 80 |
85 // -*- 2 -*- | 81 // -*- 2 -*- |
86 octave_value | 82 octave_value |
87 xpow (double a, const Matrix& b) | 83 xpow (double a, const Matrix& b) |
100 ComplexMatrix Q (b_eig.eigenvectors ()); | 96 ComplexMatrix Q (b_eig.eigenvectors ()); |
101 | 97 |
102 for (int i = 0; i < nr; i++) | 98 for (int i = 0; i < nr; i++) |
103 { | 99 { |
104 Complex elt = lambda (i); | 100 Complex elt = lambda (i); |
105 if (imag (elt) == 0.0) | 101 if (std::imag (elt) == 0.0) |
106 lambda (i) = pow (a, real (elt)); | 102 lambda (i) = std::pow (a, std::real (elt)); |
107 else | 103 else |
108 lambda (i) = pow (a, elt); | 104 lambda (i) = std::pow (a, elt); |
109 } | 105 } |
110 ComplexDiagMatrix D (lambda); | 106 ComplexDiagMatrix D (lambda); |
111 | 107 |
112 retval = ComplexMatrix (Q * D * Q.inverse ()); | 108 retval = ComplexMatrix (Q * D * Q.inverse ()); |
113 } | 109 } |
119 octave_value | 115 octave_value |
120 xpow (double a, const Complex& b) | 116 xpow (double a, const Complex& b) |
121 { | 117 { |
122 Complex result; | 118 Complex result; |
123 Complex atmp (a); | 119 Complex atmp (a); |
124 result = pow (atmp, b); | 120 result = std::pow (atmp, b); |
125 return result; | 121 return result; |
126 } | 122 } |
127 | 123 |
128 // -*- 4 -*- | 124 // -*- 4 -*- |
129 octave_value | 125 octave_value |
143 ComplexMatrix Q (b_eig.eigenvectors ()); | 139 ComplexMatrix Q (b_eig.eigenvectors ()); |
144 | 140 |
145 for (int i = 0; i < nr; i++) | 141 for (int i = 0; i < nr; i++) |
146 { | 142 { |
147 Complex elt = lambda (i); | 143 Complex elt = lambda (i); |
148 if (imag (elt) == 0.0) | 144 if (std::imag (elt) == 0.0) |
149 lambda (i) = pow (a, real (elt)); | 145 lambda (i) = std::pow (a, std::real (elt)); |
150 else | 146 else |
151 lambda (i) = pow (a, elt); | 147 lambda (i) = std::pow (a, elt); |
152 } | 148 } |
153 ComplexDiagMatrix D (lambda); | 149 ComplexDiagMatrix D (lambda); |
154 | 150 |
155 retval = ComplexMatrix (Q * D * Q.inverse ()); | 151 retval = ComplexMatrix (Q * D * Q.inverse ()); |
156 } | 152 } |
224 EIG a_eig (a); | 220 EIG a_eig (a); |
225 ComplexColumnVector lambda (a_eig.eigenvalues ()); | 221 ComplexColumnVector lambda (a_eig.eigenvalues ()); |
226 ComplexMatrix Q (a_eig.eigenvectors ()); | 222 ComplexMatrix Q (a_eig.eigenvectors ()); |
227 | 223 |
228 for (int i = 0; i < nr; i++) | 224 for (int i = 0; i < nr; i++) |
229 lambda (i) = pow (lambda (i), b); | 225 lambda (i) = std::pow (lambda (i), b); |
230 | 226 |
231 ComplexDiagMatrix D (lambda); | 227 ComplexDiagMatrix D (lambda); |
232 | 228 |
233 retval = ComplexMatrix (Q * D * Q.inverse ()); | 229 retval = ComplexMatrix (Q * D * Q.inverse ()); |
234 } | 230 } |
253 EIG a_eig (a); | 249 EIG a_eig (a); |
254 ComplexColumnVector lambda (a_eig.eigenvalues ()); | 250 ComplexColumnVector lambda (a_eig.eigenvalues ()); |
255 ComplexMatrix Q (a_eig.eigenvectors ()); | 251 ComplexMatrix Q (a_eig.eigenvectors ()); |
256 | 252 |
257 for (int i = 0; i < nr; i++) | 253 for (int i = 0; i < nr; i++) |
258 lambda (i) = pow (lambda (i), b); | 254 lambda (i) = std::pow (lambda (i), b); |
259 | 255 |
260 ComplexDiagMatrix D (lambda); | 256 ComplexDiagMatrix D (lambda); |
261 | 257 |
262 retval = ComplexMatrix (Q * D * Q.inverse ()); | 258 retval = ComplexMatrix (Q * D * Q.inverse ()); |
263 } | 259 } |
270 xpow (const Complex& a, double b) | 266 xpow (const Complex& a, double b) |
271 { | 267 { |
272 Complex result; | 268 Complex result; |
273 | 269 |
274 if (xisint (b)) | 270 if (xisint (b)) |
275 result = pow (a, static_cast<int> (b)); | 271 result = std::pow (a, static_cast<int> (b)); |
276 else | 272 else |
277 result = pow (a, b); | 273 result = std::pow (a, b); |
278 | 274 |
279 return result; | 275 return result; |
280 } | 276 } |
281 | 277 |
282 // -*- 8 -*- | 278 // -*- 8 -*- |
297 ComplexMatrix Q (b_eig.eigenvectors ()); | 293 ComplexMatrix Q (b_eig.eigenvectors ()); |
298 | 294 |
299 for (int i = 0; i < nr; i++) | 295 for (int i = 0; i < nr; i++) |
300 { | 296 { |
301 Complex elt = lambda (i); | 297 Complex elt = lambda (i); |
302 if (imag (elt) == 0.0) | 298 if (std::imag (elt) == 0.0) |
303 lambda (i) = pow (a, real (elt)); | 299 lambda (i) = std::pow (a, std::real (elt)); |
304 else | 300 else |
305 lambda (i) = pow (a, elt); | 301 lambda (i) = std::pow (a, elt); |
306 } | 302 } |
307 ComplexDiagMatrix D (lambda); | 303 ComplexDiagMatrix D (lambda); |
308 | 304 |
309 retval = ComplexMatrix (Q * D * Q.inverse ()); | 305 retval = ComplexMatrix (Q * D * Q.inverse ()); |
310 } | 306 } |
315 // -*- 9 -*- | 311 // -*- 9 -*- |
316 octave_value | 312 octave_value |
317 xpow (const Complex& a, const Complex& b) | 313 xpow (const Complex& a, const Complex& b) |
318 { | 314 { |
319 Complex result; | 315 Complex result; |
320 result = pow (a, b); | 316 result = std::pow (a, b); |
321 return result; | 317 return result; |
322 } | 318 } |
323 | 319 |
324 // -*- 10 -*- | 320 // -*- 10 -*- |
325 octave_value | 321 octave_value |
339 ComplexMatrix Q (b_eig.eigenvectors ()); | 335 ComplexMatrix Q (b_eig.eigenvectors ()); |
340 | 336 |
341 for (int i = 0; i < nr; i++) | 337 for (int i = 0; i < nr; i++) |
342 { | 338 { |
343 Complex elt = lambda (i); | 339 Complex elt = lambda (i); |
344 if (imag (elt) == 0.0) | 340 if (std::imag (elt) == 0.0) |
345 lambda (i) = pow (a, real (elt)); | 341 lambda (i) = std::pow (a, std::real (elt)); |
346 else | 342 else |
347 lambda (i) = pow (a, elt); | 343 lambda (i) = std::pow (a, elt); |
348 } | 344 } |
349 ComplexDiagMatrix D (lambda); | 345 ComplexDiagMatrix D (lambda); |
350 | 346 |
351 retval = ComplexMatrix (Q * D * Q.inverse ()); | 347 retval = ComplexMatrix (Q * D * Q.inverse ()); |
352 } | 348 } |
420 EIG a_eig (a); | 416 EIG a_eig (a); |
421 ComplexColumnVector lambda (a_eig.eigenvalues ()); | 417 ComplexColumnVector lambda (a_eig.eigenvalues ()); |
422 ComplexMatrix Q (a_eig.eigenvectors ()); | 418 ComplexMatrix Q (a_eig.eigenvectors ()); |
423 | 419 |
424 for (int i = 0; i < nr; i++) | 420 for (int i = 0; i < nr; i++) |
425 lambda (i) = pow (lambda (i), b); | 421 lambda (i) = std::pow (lambda (i), b); |
426 | 422 |
427 ComplexDiagMatrix D (lambda); | 423 ComplexDiagMatrix D (lambda); |
428 | 424 |
429 retval = ComplexMatrix (Q * D * Q.inverse ()); | 425 retval = ComplexMatrix (Q * D * Q.inverse ()); |
430 } | 426 } |
449 EIG a_eig (a); | 445 EIG a_eig (a); |
450 ComplexColumnVector lambda (a_eig.eigenvalues ()); | 446 ComplexColumnVector lambda (a_eig.eigenvalues ()); |
451 ComplexMatrix Q (a_eig.eigenvectors ()); | 447 ComplexMatrix Q (a_eig.eigenvectors ()); |
452 | 448 |
453 for (int i = 0; i < nr; i++) | 449 for (int i = 0; i < nr; i++) |
454 lambda (i) = pow (lambda (i), b); | 450 lambda (i) = std::pow (lambda (i), b); |
455 | 451 |
456 ComplexDiagMatrix D (lambda); | 452 ComplexDiagMatrix D (lambda); |
457 | 453 |
458 retval = ComplexMatrix (Q * D * Q.inverse ()); | 454 retval = ComplexMatrix (Q * D * Q.inverse ()); |
459 } | 455 } |
507 ComplexMatrix result (nr, nc); | 503 ComplexMatrix result (nr, nc); |
508 for (int j = 0; j < nc; j++) | 504 for (int j = 0; j < nc; j++) |
509 for (int i = 0; i < nr; i++) | 505 for (int i = 0; i < nr; i++) |
510 { | 506 { |
511 OCTAVE_QUIT; | 507 OCTAVE_QUIT; |
512 result (i, j) = pow (atmp, b (i, j)); | 508 result (i, j) = std::pow (atmp, b (i, j)); |
513 } | 509 } |
514 | 510 |
515 retval = result; | 511 retval = result; |
516 } | 512 } |
517 else | 513 else |
519 Matrix result (nr, nc); | 515 Matrix result (nr, nc); |
520 for (int j = 0; j < nc; j++) | 516 for (int j = 0; j < nc; j++) |
521 for (int i = 0; i < nr; i++) | 517 for (int i = 0; i < nr; i++) |
522 { | 518 { |
523 OCTAVE_QUIT; | 519 OCTAVE_QUIT; |
524 result (i, j) = pow (a, b (i, j)); | 520 result (i, j) = std::pow (a, b (i, j)); |
525 } | 521 } |
526 | 522 |
527 retval = result; | 523 retval = result; |
528 } | 524 } |
529 | 525 |
541 Complex atmp (a); | 537 Complex atmp (a); |
542 for (int j = 0; j < nc; j++) | 538 for (int j = 0; j < nc; j++) |
543 for (int i = 0; i < nr; i++) | 539 for (int i = 0; i < nr; i++) |
544 { | 540 { |
545 OCTAVE_QUIT; | 541 OCTAVE_QUIT; |
546 result (i, j) = pow (atmp, b (i, j)); | 542 result (i, j) = std::pow (atmp, b (i, j)); |
547 } | 543 } |
548 | 544 |
549 return result; | 545 return result; |
550 } | 546 } |
551 | 547 |
564 for (int j = 0; j < nc; j++) | 560 for (int j = 0; j < nc; j++) |
565 for (int i = 0; i < nr; i++) | 561 for (int i = 0; i < nr; i++) |
566 { | 562 { |
567 OCTAVE_QUIT; | 563 OCTAVE_QUIT; |
568 | 564 |
569 // XXX FIXME XXX -- avoid apparent GNU libm bug by | |
570 // converting A and B to complex instead of just A. | |
571 | |
572 Complex atmp (a (i, j)); | 565 Complex atmp (a (i, j)); |
573 Complex btmp (b); | 566 |
574 | 567 result (i, j) = std::pow (atmp, b); |
575 result (i, j) = pow (atmp, btmp); | |
576 } | 568 } |
577 | 569 |
578 retval = result; | 570 retval = result; |
579 } | 571 } |
580 else | 572 else |
582 Matrix result (nr, nc); | 574 Matrix result (nr, nc); |
583 for (int j = 0; j < nc; j++) | 575 for (int j = 0; j < nc; j++) |
584 for (int i = 0; i < nr; i++) | 576 for (int i = 0; i < nr; i++) |
585 { | 577 { |
586 OCTAVE_QUIT; | 578 OCTAVE_QUIT; |
587 result (i, j) = pow (a (i, j), b); | 579 result (i, j) = std::pow (a (i, j), b); |
588 } | 580 } |
589 | 581 |
590 retval = result; | 582 retval = result; |
591 } | 583 } |
592 | 584 |
635 for (int i = 0; i < nr; i++) | 627 for (int i = 0; i < nr; i++) |
636 { | 628 { |
637 OCTAVE_QUIT; | 629 OCTAVE_QUIT; |
638 Complex atmp (a (i, j)); | 630 Complex atmp (a (i, j)); |
639 Complex btmp (b (i, j)); | 631 Complex btmp (b (i, j)); |
640 complex_result (i, j) = pow (atmp, btmp); | 632 complex_result (i, j) = std::pow (atmp, btmp); |
641 } | 633 } |
642 | 634 |
643 retval = complex_result; | 635 retval = complex_result; |
644 } | 636 } |
645 else | 637 else |
648 | 640 |
649 for (int j = 0; j < nc; j++) | 641 for (int j = 0; j < nc; j++) |
650 for (int i = 0; i < nr; i++) | 642 for (int i = 0; i < nr; i++) |
651 { | 643 { |
652 OCTAVE_QUIT; | 644 OCTAVE_QUIT; |
653 result (i, j) = pow (a (i, j), b (i, j)); | 645 result (i, j) = std::pow (a (i, j), b (i, j)); |
654 } | 646 } |
655 | 647 |
656 retval = result; | 648 retval = result; |
657 } | 649 } |
658 | 650 |
669 ComplexMatrix result (nr, nc); | 661 ComplexMatrix result (nr, nc); |
670 for (int j = 0; j < nc; j++) | 662 for (int j = 0; j < nc; j++) |
671 for (int i = 0; i < nr; i++) | 663 for (int i = 0; i < nr; i++) |
672 { | 664 { |
673 OCTAVE_QUIT; | 665 OCTAVE_QUIT; |
674 result (i, j) = pow (Complex (a (i, j)), b); | 666 result (i, j) = std::pow (Complex (a (i, j)), b); |
675 } | 667 } |
676 | 668 |
677 return result; | 669 return result; |
678 } | 670 } |
679 | 671 |
696 ComplexMatrix result (nr, nc); | 688 ComplexMatrix result (nr, nc); |
697 for (int j = 0; j < nc; j++) | 689 for (int j = 0; j < nc; j++) |
698 for (int i = 0; i < nr; i++) | 690 for (int i = 0; i < nr; i++) |
699 { | 691 { |
700 OCTAVE_QUIT; | 692 OCTAVE_QUIT; |
701 result (i, j) = pow (Complex (a (i, j)), b (i, j)); | 693 result (i, j) = std::pow (Complex (a (i, j)), b (i, j)); |
702 } | 694 } |
703 | 695 |
704 return result; | 696 return result; |
705 } | 697 } |
706 | 698 |
716 for (int i = 0; i < nr; i++) | 708 for (int i = 0; i < nr; i++) |
717 { | 709 { |
718 OCTAVE_QUIT; | 710 OCTAVE_QUIT; |
719 double btmp = b (i, j); | 711 double btmp = b (i, j); |
720 if (xisint (btmp)) | 712 if (xisint (btmp)) |
721 result (i, j) = pow (a, static_cast<int> (btmp)); | 713 result (i, j) = std::pow (a, static_cast<int> (btmp)); |
722 else | 714 else |
723 result (i, j) = pow (a, btmp); | 715 result (i, j) = std::pow (a, btmp); |
724 } | 716 } |
725 | 717 |
726 return result; | 718 return result; |
727 } | 719 } |
728 | 720 |
736 ComplexMatrix result (nr, nc); | 728 ComplexMatrix result (nr, nc); |
737 for (int j = 0; j < nc; j++) | 729 for (int j = 0; j < nc; j++) |
738 for (int i = 0; i < nr; i++) | 730 for (int i = 0; i < nr; i++) |
739 { | 731 { |
740 OCTAVE_QUIT; | 732 OCTAVE_QUIT; |
741 result (i, j) = pow (a, b (i, j)); | 733 result (i, j) = std::pow (a, b (i, j)); |
742 } | 734 } |
743 | 735 |
744 return result; | 736 return result; |
745 } | 737 } |
746 | 738 |
757 { | 749 { |
758 for (int j = 0; j < nc; j++) | 750 for (int j = 0; j < nc; j++) |
759 for (int i = 0; i < nr; i++) | 751 for (int i = 0; i < nr; i++) |
760 { | 752 { |
761 OCTAVE_QUIT; | 753 OCTAVE_QUIT; |
762 result (i, j) = pow (a (i, j), static_cast<int> (b)); | 754 result (i, j) = std::pow (a (i, j), static_cast<int> (b)); |
763 } | 755 } |
764 } | 756 } |
765 else | 757 else |
766 { | 758 { |
767 for (int j = 0; j < nc; j++) | 759 for (int j = 0; j < nc; j++) |
768 for (int i = 0; i < nr; i++) | 760 for (int i = 0; i < nr; i++) |
769 { | 761 { |
770 OCTAVE_QUIT; | 762 OCTAVE_QUIT; |
771 result (i, j) = pow (a (i, j), b); | 763 result (i, j) = std::pow (a (i, j), b); |
772 } | 764 } |
773 } | 765 } |
774 | 766 |
775 return result; | 767 return result; |
776 } | 768 } |
796 for (int i = 0; i < nr; i++) | 788 for (int i = 0; i < nr; i++) |
797 { | 789 { |
798 OCTAVE_QUIT; | 790 OCTAVE_QUIT; |
799 double btmp = b (i, j); | 791 double btmp = b (i, j); |
800 if (xisint (btmp)) | 792 if (xisint (btmp)) |
801 result (i, j) = pow (a (i, j), static_cast<int> (btmp)); | 793 result (i, j) = std::pow (a (i, j), static_cast<int> (btmp)); |
802 else | 794 else |
803 result (i, j) = pow (a (i, j), btmp); | 795 result (i, j) = std::pow (a (i, j), btmp); |
804 } | 796 } |
805 | 797 |
806 return result; | 798 return result; |
807 } | 799 } |
808 | 800 |
816 ComplexMatrix result (nr, nc); | 808 ComplexMatrix result (nr, nc); |
817 for (int j = 0; j < nc; j++) | 809 for (int j = 0; j < nc; j++) |
818 for (int i = 0; i < nr; i++) | 810 for (int i = 0; i < nr; i++) |
819 { | 811 { |
820 OCTAVE_QUIT; | 812 OCTAVE_QUIT; |
821 result (i, j) = pow (a (i, j), b); | 813 result (i, j) = std::pow (a (i, j), b); |
822 } | 814 } |
823 | 815 |
824 return result; | 816 return result; |
825 } | 817 } |
826 | 818 |
843 ComplexMatrix result (nr, nc); | 835 ComplexMatrix result (nr, nc); |
844 for (int j = 0; j < nc; j++) | 836 for (int j = 0; j < nc; j++) |
845 for (int i = 0; i < nr; i++) | 837 for (int i = 0; i < nr; i++) |
846 { | 838 { |
847 OCTAVE_QUIT; | 839 OCTAVE_QUIT; |
848 result (i, j) = pow (a (i, j), b (i, j)); | 840 result (i, j) = std::pow (a (i, j), b (i, j)); |
849 } | 841 } |
850 | 842 |
851 return result; | 843 return result; |
852 } | 844 } |
853 | 845 |
893 Complex atmp (a); | 885 Complex atmp (a); |
894 ComplexNDArray result (b.dims ()); | 886 ComplexNDArray result (b.dims ()); |
895 for (int i = 0; i < b.length (); i++) | 887 for (int i = 0; i < b.length (); i++) |
896 { | 888 { |
897 OCTAVE_QUIT; | 889 OCTAVE_QUIT; |
898 result(i) = pow (atmp, b(i)); | 890 result(i) = std::pow (atmp, b(i)); |
899 } | 891 } |
900 | 892 |
901 retval = result; | 893 retval = result; |
902 } | 894 } |
903 else | 895 else |
904 { | 896 { |
905 NDArray result (b.dims ()); | 897 NDArray result (b.dims ()); |
906 for (int i = 0; i < b.length (); i++) | 898 for (int i = 0; i < b.length (); i++) |
907 { | 899 { |
908 OCTAVE_QUIT; | 900 OCTAVE_QUIT; |
909 result (i) = pow (a, b(i)); | 901 result (i) = std::pow (a, b(i)); |
910 } | 902 } |
911 | 903 |
912 retval = result; | 904 retval = result; |
913 } | 905 } |
914 | 906 |
922 ComplexNDArray result (b.dims ()); | 914 ComplexNDArray result (b.dims ()); |
923 Complex atmp (a); | 915 Complex atmp (a); |
924 for (int i = 0; i < b.length (); i++) | 916 for (int i = 0; i < b.length (); i++) |
925 { | 917 { |
926 OCTAVE_QUIT; | 918 OCTAVE_QUIT; |
927 result(i) = pow (atmp, b(i)); | 919 result(i) = std::pow (atmp, b(i)); |
928 } | 920 } |
929 | 921 |
930 return result; | 922 return result; |
931 } | 923 } |
932 | 924 |
942 | 934 |
943 for (int i = 0; i < a.length (); i++) | 935 for (int i = 0; i < a.length (); i++) |
944 { | 936 { |
945 OCTAVE_QUIT; | 937 OCTAVE_QUIT; |
946 | 938 |
947 // XXX FIXME XXX -- avoid apparent GNU libm bug by | |
948 // converting A and B to complex instead of just A. | |
949 | |
950 Complex atmp (a (i)); | 939 Complex atmp (a (i)); |
951 Complex btmp (b); | 940 |
952 | 941 result(i) = std::pow (atmp, b); |
953 result(i) = pow (atmp, btmp); | |
954 } | 942 } |
955 | 943 |
956 retval = result; | 944 retval = result; |
957 } | 945 } |
958 else | 946 else |
960 NDArray result (a.dims ()); | 948 NDArray result (a.dims ()); |
961 | 949 |
962 for (int i = 0; i < a.length (); i++) | 950 for (int i = 0; i < a.length (); i++) |
963 { | 951 { |
964 OCTAVE_QUIT; | 952 OCTAVE_QUIT; |
965 result(i) = pow (a(i), b); | 953 result(i) = std::pow (a(i), b); |
966 } | 954 } |
967 | 955 |
968 retval = result; | 956 retval = result; |
969 } | 957 } |
970 | 958 |
1011 for (int i = 0; i < len; i++) | 999 for (int i = 0; i < len; i++) |
1012 { | 1000 { |
1013 OCTAVE_QUIT; | 1001 OCTAVE_QUIT; |
1014 Complex atmp (a(i)); | 1002 Complex atmp (a(i)); |
1015 Complex btmp (b(i)); | 1003 Complex btmp (b(i)); |
1016 complex_result(i) = pow (atmp, btmp); | 1004 complex_result(i) = std::pow (atmp, btmp); |
1017 } | 1005 } |
1018 | 1006 |
1019 retval = complex_result; | 1007 retval = complex_result; |
1020 } | 1008 } |
1021 else | 1009 else |
1023 NDArray result (a_dims); | 1011 NDArray result (a_dims); |
1024 | 1012 |
1025 for (int i = 0; i < len; i++) | 1013 for (int i = 0; i < len; i++) |
1026 { | 1014 { |
1027 OCTAVE_QUIT; | 1015 OCTAVE_QUIT; |
1028 result(i) = pow (a(i), b(i)); | 1016 result(i) = std::pow (a(i), b(i)); |
1029 } | 1017 } |
1030 | 1018 |
1031 retval = result; | 1019 retval = result; |
1032 } | 1020 } |
1033 | 1021 |
1041 ComplexNDArray result (a.dims ()); | 1029 ComplexNDArray result (a.dims ()); |
1042 | 1030 |
1043 for (int i = 0; i < a.length (); i++) | 1031 for (int i = 0; i < a.length (); i++) |
1044 { | 1032 { |
1045 OCTAVE_QUIT; | 1033 OCTAVE_QUIT; |
1046 result(i) = pow (Complex (a(i)), b); | 1034 result(i) = std::pow (Complex (a(i)), b); |
1047 } | 1035 } |
1048 | 1036 |
1049 return result; | 1037 return result; |
1050 } | 1038 } |
1051 | 1039 |
1064 | 1052 |
1065 ComplexNDArray result (a_dims); | 1053 ComplexNDArray result (a_dims); |
1066 for (int i = 0; i < a.length (); i++) | 1054 for (int i = 0; i < a.length (); i++) |
1067 { | 1055 { |
1068 OCTAVE_QUIT; | 1056 OCTAVE_QUIT; |
1069 result(i) = pow (Complex (a(i)), b(i)); | 1057 result(i) = std::pow (Complex (a(i)), b(i)); |
1070 } | 1058 } |
1071 | 1059 |
1072 return result; | 1060 return result; |
1073 } | 1061 } |
1074 | 1062 |
1080 for (int i = 0; i < b.length (); i++) | 1068 for (int i = 0; i < b.length (); i++) |
1081 { | 1069 { |
1082 OCTAVE_QUIT; | 1070 OCTAVE_QUIT; |
1083 double btmp = b(i); | 1071 double btmp = b(i); |
1084 if (xisint (btmp)) | 1072 if (xisint (btmp)) |
1085 result(i) = pow (a, static_cast<int> (btmp)); | 1073 result(i) = std::pow (a, static_cast<int> (btmp)); |
1086 else | 1074 else |
1087 result(i) = pow (a, btmp); | 1075 result(i) = std::pow (a, btmp); |
1088 } | 1076 } |
1089 | 1077 |
1090 return result; | 1078 return result; |
1091 } | 1079 } |
1092 | 1080 |
1096 { | 1084 { |
1097 ComplexNDArray result (b.dims ()); | 1085 ComplexNDArray result (b.dims ()); |
1098 for (int i = 0; i < b.length (); i++) | 1086 for (int i = 0; i < b.length (); i++) |
1099 { | 1087 { |
1100 OCTAVE_QUIT; | 1088 OCTAVE_QUIT; |
1101 result(i) = pow (a, b(i)); | 1089 result(i) = std::pow (a, b(i)); |
1102 } | 1090 } |
1103 | 1091 |
1104 return result; | 1092 return result; |
1105 } | 1093 } |
1106 | 1094 |
1113 if (xisint (b)) | 1101 if (xisint (b)) |
1114 { | 1102 { |
1115 for (int i = 0; i < a.length (); i++) | 1103 for (int i = 0; i < a.length (); i++) |
1116 { | 1104 { |
1117 OCTAVE_QUIT; | 1105 OCTAVE_QUIT; |
1118 result(i) = pow (a(i), static_cast<int> (b)); | 1106 result(i) = std::pow (a(i), static_cast<int> (b)); |
1119 } | 1107 } |
1120 } | 1108 } |
1121 else | 1109 else |
1122 { | 1110 { |
1123 for (int i = 0; i < a.length (); i++) | 1111 for (int i = 0; i < a.length (); i++) |
1124 { | 1112 { |
1125 OCTAVE_QUIT; | 1113 OCTAVE_QUIT; |
1126 result(i) = pow (a(i), b); | 1114 result(i) = std::pow (a(i), b); |
1127 } | 1115 } |
1128 } | 1116 } |
1129 | 1117 |
1130 return result; | 1118 return result; |
1131 } | 1119 } |
1147 for (int i = 0; i < a.length (); i++) | 1135 for (int i = 0; i < a.length (); i++) |
1148 { | 1136 { |
1149 OCTAVE_QUIT; | 1137 OCTAVE_QUIT; |
1150 double btmp = b(i); | 1138 double btmp = b(i); |
1151 if (xisint (btmp)) | 1139 if (xisint (btmp)) |
1152 result(i) = pow (a(i), static_cast<int> (btmp)); | 1140 result(i) = std::pow (a(i), static_cast<int> (btmp)); |
1153 else | 1141 else |
1154 result(i) = pow (a(i), btmp); | 1142 result(i) = std::pow (a(i), btmp); |
1155 } | 1143 } |
1156 | 1144 |
1157 return result; | 1145 return result; |
1158 } | 1146 } |
1159 | 1147 |
1163 { | 1151 { |
1164 ComplexNDArray result (a.dims ()); | 1152 ComplexNDArray result (a.dims ()); |
1165 for (int i = 0; i < a.length (); i++) | 1153 for (int i = 0; i < a.length (); i++) |
1166 { | 1154 { |
1167 OCTAVE_QUIT; | 1155 OCTAVE_QUIT; |
1168 result(i) = pow (a(i), b); | 1156 result(i) = std::pow (a(i), b); |
1169 } | 1157 } |
1170 | 1158 |
1171 return result; | 1159 return result; |
1172 } | 1160 } |
1173 | 1161 |
1186 | 1174 |
1187 ComplexNDArray result (a_dims); | 1175 ComplexNDArray result (a_dims); |
1188 for (int i = 0; i < a.length (); i++) | 1176 for (int i = 0; i < a.length (); i++) |
1189 { | 1177 { |
1190 OCTAVE_QUIT; | 1178 OCTAVE_QUIT; |
1191 result(i) = pow (a(i), b(i)); | 1179 result(i) = std::pow (a(i), b(i)); |
1192 } | 1180 } |
1193 | 1181 |
1194 return result; | 1182 return result; |
1195 } | 1183 } |
1196 | 1184 |