@@ -61,7 +61,7 @@ private static function subArraysAreEqualSize(array $subArrays): bool
6161 * @param int $size How many rows and columns the identity matrix should have
6262 * @return self
6363 */
64- public static function identity (int $ size ): self
64+ final public static function identity (int $ size ): self
6565 {
6666 $ literal = [];
6767
@@ -81,31 +81,31 @@ public static function identity(int $size): self
8181 * @param int $column
8282 * @return float
8383 */
84- public function get ($ row , $ column ): float
84+ final public function get ($ row , $ column ): float
8585 {
8686 return $ this ->internal [$ row ][$ column ];
8787 }
8888
8989 /**
9090 * @return boolean
9191 */
92- public function isSquare (): bool
92+ final public function isSquare (): bool
9393 {
9494 return $ this ->getColumnCount () === $ this ->getRowCount ();
9595 }
9696
9797 /**
9898 * @return int
9999 */
100- public function getColumnCount (): int
100+ final public function getColumnCount (): int
101101 {
102102 return count ($ this ->internal [0 ]);
103103 }
104104
105105 /**
106106 * @return int
107107 */
108- public function getRowCount (): int
108+ final public function getRowCount (): int
109109 {
110110 return count ($ this ->internal );
111111 }
@@ -114,7 +114,7 @@ public function getRowCount(): int
114114 * @param Matrix $matrix
115115 * @return boolean
116116 */
117- public function equals (Matrix $ matrix ): bool
117+ final public function equals (Matrix $ matrix ): bool
118118 {
119119 return $ this ->internal === $ matrix ->internal ;
120120 }
@@ -138,7 +138,7 @@ public function toArray(): array
138138 * @param callable $callback
139139 * @return self
140140 */
141- public function map (callable $ callback ): self
141+ final public function map (callable $ callback ): self
142142 {
143143 $ literal = [];
144144
@@ -160,7 +160,7 @@ public function map(callable $callback): self
160160 * @return self
161161 * @throws MatrixException
162162 */
163- public function addMatrix (self $ value ): self
163+ final public function addMatrix (self $ value ): self
164164 {
165165 $ this ->checkEqualSize ($ value );
166166
@@ -184,7 +184,7 @@ private function checkEqualSize(self $matrix)
184184 * @param float $value
185185 * @return self
186186 */
187- public function addScalar (float $ value ): self
187+ final public function addScalar (float $ value ): self
188188 {
189189 return $ this ->map (function (float $ element ) use ($ value ) {
190190 return $ element + $ value ;
@@ -196,7 +196,7 @@ public function addScalar(float $value): self
196196 * @return self
197197 * @throws MatrixException
198198 */
199- public function subtractMatrix (self $ value ): self
199+ final public function subtractMatrix (self $ value ): self
200200 {
201201 $ this ->checkEqualSize ($ value );
202202
@@ -209,7 +209,7 @@ public function subtractMatrix(self $value): self
209209 * @param float $value
210210 * @return self
211211 */
212- public function subtractScalar (float $ value ): self
212+ final public function subtractScalar (float $ value ): self
213213 {
214214 return $ this ->map (function (float $ element ) use ($ value ) {
215215 return $ element - $ value ;
@@ -221,7 +221,7 @@ public function subtractScalar(float $value): self
221221 * @return self
222222 * @throws MatrixException
223223 */
224- public function multiplyMatrix (self $ value ): self
224+ final public function multiplyMatrix (self $ value ): self
225225 {
226226 if ($ this ->getColumnCount () !== $ value ->getRowCount ()) {
227227 throw new MatrixException ('Cannot multiply matrices of these sizes. ' );
@@ -252,7 +252,7 @@ public function multiplyMatrix(self $value): self
252252 * @param float $value
253253 * @return self
254254 */
255- public function multiplyScalar (float $ value ): self
255+ final public function multiplyScalar (float $ value ): self
256256 {
257257 return $ this ->map (function (float $ element ) use ($ value ) {
258258 return $ element * $ value ;
@@ -265,7 +265,7 @@ public function multiplyScalar(float $value): self
265265 * @return self
266266 * @throws MatrixException
267267 */
268- public function divideScalar (float $ value ): self
268+ final public function divideScalar (float $ value ): self
269269 {
270270 if ($ value == 0 ) {
271271 throw new MatrixException ("Zero can not be denominator. " );
@@ -282,7 +282,7 @@ public function divideScalar(float $value): self
282282 * @throws MatrixException
283283 * @link https://en.wikipedia.org/wiki/Hadamard_product_%28matrices%29
284284 */
285- public function entrywise (self $ value ): self
285+ final public function entrywise (self $ value ): self
286286 {
287287 $ this ->checkEqualSize ($ value );
288288
@@ -295,7 +295,7 @@ public function entrywise(self $value): self
295295 * @return self
296296 * @throws MatrixException
297297 */
298- public function adjugate (): self
298+ final public function adjugate (): self
299299 {
300300 $ this ->checkSquare ();
301301
@@ -316,7 +316,7 @@ private function checkSquare()
316316 * @return self
317317 * @throws MatrixException
318318 */
319- public function inverse (): self
319+ final public function inverse (): self
320320 {
321321 $ this ->checkSquare ();
322322
@@ -401,7 +401,7 @@ private function recursiveSolveInverse(self $source): self
401401 * @param int|null $length
402402 * @return self
403403 */
404- public function sliceRows (int $ offset , int $ length = null ): self
404+ final public function sliceRows (int $ offset , int $ length = null ): self
405405 {
406406 return new static (array_slice ($ this ->toArray (), $ offset , $ length ));
407407 }
@@ -411,7 +411,7 @@ public function sliceRows(int $offset, int $length = null): self
411411 * @param int|null $length
412412 * @return self
413413 */
414- public function sliceColumns (int $ offset , int $ length = null ): self
414+ final public function sliceColumns (int $ offset , int $ length = null ): self
415415 {
416416 return new static (array_map (function (array $ row ) use ($ offset , $ length ) {
417417 return array_slice ($ row , $ offset , $ length );
@@ -425,7 +425,7 @@ public function sliceColumns(int $offset, int $length = null): self
425425 * @return Matrix
426426 * @throws MatrixException
427427 */
428- public function spliceRows (int $ offset , int $ length = null , array $ replacement = null ): self
428+ final public function spliceRows (int $ offset , int $ length = null , array $ replacement = null ): self
429429 {
430430 if ($ replacement ) {
431431 if ($ this ->getColumnCount () !== count ($ replacement [0 ])) {
@@ -457,7 +457,7 @@ public function spliceRows(int $offset, int $length = null, array $replacement =
457457 * @return Matrix
458458 * @throws MatrixException
459459 */
460- public function spliceColumns (int $ offset , int $ length = null , array $ replacement = null ): self
460+ final public function spliceColumns (int $ offset , int $ length = null , array $ replacement = null ): self
461461 {
462462 if ($ replacement ) {
463463 if ($ this ->getRowCount () !== count ($ replacement )) {
@@ -489,7 +489,7 @@ public function spliceColumns(int $offset, int $length = null, array $replacemen
489489 /**
490490 * @return float
491491 */
492- public function determinant (): float
492+ final public function determinant (): float
493493 {
494494 $ this ->checkSquare ();
495495
@@ -517,7 +517,7 @@ public function determinant(): float
517517 * @param bool $unitriangular True to have ones along the diagonal. False to include parent matrix values, instead.
518518 * @return self
519519 */
520- public function upper (bool $ unitriangular ): self
520+ final public function upper (bool $ unitriangular ): self
521521 {
522522 return $ this ->map (function (float $ element , int $ i , int $ j ) use ($ unitriangular ) {
523523 if ($ unitriangular && $ i === $ j ) {
@@ -532,7 +532,7 @@ public function upper(bool $unitriangular): self
532532 * @param bool $unitriangular True to have ones along the diagonal. False to include parent matrix values, instead.
533533 * @return self
534534 */
535- public function lower (bool $ unitriangular ): self
535+ final public function lower (bool $ unitriangular ): self
536536 {
537537 return $ this ->map (function (float $ element , int $ i , int $ j ) use ($ unitriangular ) {
538538 if ($ unitriangular && $ i === $ j ) {
@@ -548,7 +548,7 @@ public function lower(bool $unitriangular): self
548548 * @return self
549549 * @throws MatrixException
550550 */
551- public function concatenateBottom (self $ other ): self
551+ final public function concatenateBottom (self $ other ): self
552552 {
553553 return $ this ->spliceRows ($ this ->getRowCount (), 0 , $ other ->toArray ());
554554 }
@@ -558,15 +558,15 @@ public function concatenateBottom(self $other): self
558558 * @return self
559559 * @throws MatrixException
560560 */
561- public function concatenateRight (self $ other ): self
561+ final public function concatenateRight (self $ other ): self
562562 {
563563 return $ this ->spliceColumns ($ this ->getColumnCount (), 0 , $ other ->toArray ());
564564 }
565565
566566 /**
567567 * @return self
568568 */
569- public function diagonal (): self
569+ final public function diagonal (): self
570570 {
571571 return $ this ->map (function (float $ element , int $ i , int $ j ) {
572572 return $ i === $ j ? $ element : 0 ;
@@ -577,7 +577,7 @@ public function diagonal(): self
577577 * @return float
578578 * @throws MatrixException
579579 */
580- public function trace (): float
580+ final public function trace (): float
581581 {
582582 $ this ->checkSquare ();
583583
@@ -593,7 +593,7 @@ public function trace(): float
593593 /**
594594 * @return self
595595 */
596- public function transpose (): self
596+ final public function transpose (): self
597597 {
598598 $ literal = [];
599599
0 commit comments