Skip to content

Commit

Permalink
Rename SVD->isStandardBasisVector
Browse files Browse the repository at this point in the history
to getStandardBasisIndex
  • Loading branch information
Aweptimum committed Oct 27, 2023
1 parent e871855 commit 0845a30
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/LinearAlgebra/Decomposition/SVD.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private static function diagonalize(NumericMatrix $S): array
foreach ($vectors as $i => $vector)
{
// Each column should contain 1 non-zero element
$j = self::isStandardBasisVector($vector);
$j = self::getStandardBasisIndex($vector);

if ($j === -1) {
throw new MatrixException("S Matrix in SVD is not orthogonal:\n" . (string) $S);
Expand Down Expand Up @@ -259,15 +259,15 @@ private static function diagonalize(NumericMatrix $S): array
}

/**
* Checks that a vector has a single non-zero entry
* Checks that a vector has a single non-zero entry and returns its index
*
* @param Vector $v
*
* @return int The index of the non-zero entry or -1 if either:
* 1. There are multiple non-zero entries
* 2. The vector is a zero vector
*/
private static function isStandardBasisVector(Vector $v): int
private static function getStandardBasisIndex(Vector $v): int
{
if ($v->l2Norm() === 0) {
return false;

Check failure on line 273 in src/LinearAlgebra/Decomposition/SVD.php

View workflow job for this annotation

GitHub Actions / Static Analysis (7.2)

Method MathPHP\LinearAlgebra\Decomposition\SVD::getStandardBasisIndex() should return int but returns false.
Expand All @@ -281,7 +281,7 @@ private static function isStandardBasisVector(Vector $v): int
if (!Arithmetic::almostEqual($component, 0)) {
if ($index === -1) {
$index = $i;
} else { // If we already found a non-zero component, then return false
} else { // If we already found a non-zero component, then return -1
return -1;
}
}
Expand Down

0 comments on commit 0845a30

Please sign in to comment.