File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
src/LinearAlgebra/Decomposition Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ private static function diagonalize(NumericMatrix $S): array
215215 foreach ($ vectors as $ i => $ vector )
216216 {
217217 // Each column should contain 1 non-zero element
218- $ j = self ::isStandardBasisVector ($ vector );
218+ $ j = self ::getStandardBasisIndex ($ vector );
219219
220220 if ($ j === -1 ) {
221221 throw new MatrixException ("S Matrix in SVD is not orthogonal: \n" . (string ) $ S );
@@ -259,15 +259,15 @@ private static function diagonalize(NumericMatrix $S): array
259259 }
260260
261261 /**
262- * Checks that a vector has a single non-zero entry
262+ * Checks that a vector has a single non-zero entry and returns its index
263263 *
264264 * @param Vector $v
265265 *
266266 * @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
270+ private static function getStandardBasisIndex (Vector $ v ): int
271271 {
272272 if ($ v ->l2Norm () === 0 ) {
273273 return false ;
@@ -281,7 +281,7 @@ private static function isStandardBasisVector(Vector $v): int
281281 if (!Arithmetic::almostEqual ($ component , 0 )) {
282282 if ($ index === -1 ) {
283283 $ index = $ i ;
284- } else { // If we already found a non-zero component, then return false
284+ } else { // If we already found a non-zero component, then return -1
285285 return -1 ;
286286 }
287287 }
You can’t perform that action at this time.
0 commit comments