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
215
215
foreach ($ vectors as $ i => $ vector )
216
216
{
217
217
// Each column should contain 1 non-zero element
218
- $ j = self ::isStandardBasisVector ($ vector );
218
+ $ j = self ::getStandardBasisIndex ($ vector );
219
219
220
220
if ($ j === -1 ) {
221
221
throw new MatrixException ("S Matrix in SVD is not orthogonal: \n" . (string ) $ S );
@@ -259,15 +259,15 @@ private static function diagonalize(NumericMatrix $S): array
259
259
}
260
260
261
261
/**
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
263
263
*
264
264
* @param Vector $v
265
265
*
266
266
* @return int The index of the non-zero entry or -1 if either:
267
267
* 1. There are multiple non-zero entries
268
268
* 2. The vector is a zero vector
269
269
*/
270
- private static function isStandardBasisVector (Vector $ v ): int
270
+ private static function getStandardBasisIndex (Vector $ v ): int
271
271
{
272
272
if ($ v ->l2Norm () === 0 ) {
273
273
return false ;
@@ -281,7 +281,7 @@ private static function isStandardBasisVector(Vector $v): int
281
281
if (!Arithmetic::almostEqual ($ component , 0 )) {
282
282
if ($ index === -1 ) {
283
283
$ 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
285
285
return -1 ;
286
286
}
287
287
}
You can’t perform that action at this time.
0 commit comments