@@ -128,12 +128,13 @@ public function getEigenvectors(): array
128128 $ vectors = new Matrix ($ vectors );
129129 $ vectors = array_map (function ($ vect ) {
130130 $ sum = 0 ;
131- for ($ i = 0 ; $ i < count ($ vect ); ++$ i ) {
131+ $ count = count ($ vect );
132+ for ($ i = 0 ; $ i < $ count ; ++$ i ) {
132133 $ sum += $ vect [$ i ] ** 2 ;
133134 }
134135
135- $ sum = sqrt ( $ sum ) ;
136- for ($ i = 0 ; $ i < count ( $ vect ) ; ++$ i ) {
136+ $ sum **= .5 ;
137+ for ($ i = 0 ; $ i < $ count ; ++$ i ) {
137138 $ vect [$ i ] /= $ sum ;
138139 }
139140
@@ -208,11 +209,11 @@ private function tred2(): void
208209 // Generate Householder vector.
209210 for ($ k = 0 ; $ k < $ i ; ++$ k ) {
210211 $ this ->d [$ k ] /= $ scale ;
211- $ h += pow ( $ this ->d [$ k ], 2 ) ;
212+ $ h += $ this ->d [$ k ] ** 2 ;
212213 }
213214
214215 $ f = $ this ->d [$ i_ ];
215- $ g = sqrt ( $ h ) ;
216+ $ g = $ h ** .5 ;
216217 if ($ f > 0 ) {
217218 $ g = -$ g ;
218219 }
@@ -320,7 +321,7 @@ private function tql2(): void
320321 $ this ->e [$ this ->n - 1 ] = 0.0 ;
321322 $ f = 0.0 ;
322323 $ tst1 = 0.0 ;
323- $ eps = pow ( 2.0 , -52.0 ) ;
324+ $ eps = 2.0 ** -52.0 ;
324325
325326 for ($ l = 0 ; $ l < $ this ->n ; ++$ l ) {
326327 // Find small subdiagonal element
@@ -443,7 +444,7 @@ private function orthes(): void
443444 $ h += $ this ->ort [$ i ] * $ this ->ort [$ i ];
444445 }
445446
446- $ g = sqrt ( $ h ) ;
447+ $ g = $ h ** .5 ;
447448 if ($ this ->ort [$ m ] > 0 ) {
448449 $ g *= -1 ;
449450 }
@@ -548,7 +549,7 @@ private function hqr2(): void
548549 $ n = $ nn - 1 ;
549550 $ low = 0 ;
550551 $ high = $ nn - 1 ;
551- $ eps = pow ( 2.0 , -52.0 ) ;
552+ $ eps = 2.0 ** -52.0 ;
552553 $ exshift = 0.0 ;
553554 $ p = $ q = $ r = $ s = $ z = 0 ;
554555 // Store roots isolated by balanc and compute matrix norm
@@ -596,7 +597,7 @@ private function hqr2(): void
596597 $ w = $ this ->H [$ n ][$ n - 1 ] * $ this ->H [$ n - 1 ][$ n ];
597598 $ p = ($ this ->H [$ n - 1 ][$ n - 1 ] - $ this ->H [$ n ][$ n ]) / 2.0 ;
598599 $ q = $ p * $ p + $ w ;
599- $ z = sqrt ( abs ($ q )) ;
600+ $ z = abs ($ q ) ** .5 ;
600601 $ this ->H [$ n ][$ n ] += $ exshift ;
601602 $ this ->H [$ n - 1 ][$ n - 1 ] += $ exshift ;
602603 $ x = $ this ->H [$ n ][$ n ];
@@ -620,7 +621,7 @@ private function hqr2(): void
620621 $ s = abs ($ x ) + abs ($ z );
621622 $ p = $ x / $ s ;
622623 $ q = $ z / $ s ;
623- $ r = sqrt ($ p * $ p + $ q * $ q );
624+ $ r = ($ p * $ p + $ q * $ q ) ** .5 ;
624625 $ p /= $ r ;
625626 $ q /= $ r ;
626627 // Row modification
@@ -682,7 +683,7 @@ private function hqr2(): void
682683 $ s = ($ y - $ x ) / 2.0 ;
683684 $ s *= $ s + $ w ;
684685 if ($ s > 0 ) {
685- $ s = sqrt ( $ s ) ;
686+ $ s **= .5 ;
686687 if ($ y < $ x ) {
687688 $ s = -$ s ;
688689 }
@@ -750,7 +751,7 @@ private function hqr2(): void
750751 break ;
751752 }
752753
753- $ s = sqrt ($ p * $ p + $ q * $ q + $ r * $ r );
754+ $ s = ($ p * $ p + $ q * $ q + $ r * $ r ) ** .5 ;
754755 if ($ p < 0 ) {
755756 $ s = -$ s ;
756757 }
0 commit comments