Skip to content

Commit 151e4d3

Browse files
committed
SVD: remove union type from helper
Not available in php 7.0
1 parent 4067dd6 commit 151e4d3

File tree

1 file changed

+4
-4
lines changed
  • src/LinearAlgebra/Decomposition

1 file changed

+4
-4
lines changed

src/LinearAlgebra/Decomposition/SVD.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ private static function diagonalize(NumericMatrix $S): array
217217
// Each column should contain 1 non-zero element
218218
$j = self::isStandardBasisVector($vector);
219219

220-
if ($j === false) {
220+
if ($j === -1) {
221221
throw new MatrixException("S Matrix in SVD is not orthogonal:\n" . (string) $S);
222222
}
223223

@@ -263,11 +263,11 @@ private static function diagonalize(NumericMatrix $S): array
263263
*
264264
* @param Vector $v
265265
*
266-
* @return int|false The index of the non-zero entry or false if either:
266+
* @return int The index of the non-zero entry or -1 if either:
267267
* 1. There are multiple non-zero entries
268268
* 2. The vector is a zero vector
269269
*/
270-
private static function isStandardBasisVector(Vector $v): int|false
270+
private static function isStandardBasisVector(Vector $v): int
271271
{
272272
if ($v->l2Norm() === 0) {
273273
return false;
@@ -282,7 +282,7 @@ private static function isStandardBasisVector(Vector $v): int|false
282282
if ($index === -1) {
283283
$index = $i;
284284
} else { // If we already found a non-zero component, then return false
285-
return false;
285+
return -1;
286286
}
287287
}
288288
}

0 commit comments

Comments
 (0)