mirror of
				https://github.com/furyfire/trueskill.git
				synced 2025-11-04 02:02:29 +01:00 
			
		
		
		
	Simplifying some casts
This commit is contained in:
		@@ -130,10 +130,10 @@ class Matrix
 | 
				
			|||||||
            // | a b |
 | 
					            // | a b |
 | 
				
			||||||
            // | c d |
 | 
					            // | c d |
 | 
				
			||||||
            // The determinant is ad - bc
 | 
					            // The determinant is ad - bc
 | 
				
			||||||
            $a = (float)$this->getValue(0, 0);
 | 
					            $a = $this->getValue(0, 0);
 | 
				
			||||||
            $b = (float)$this->getValue(0, 1);
 | 
					            $b = $this->getValue(0, 1);
 | 
				
			||||||
            $c = (float)$this->getValue(1, 0);
 | 
					            $c = $this->getValue(1, 0);
 | 
				
			||||||
            $d = (float)$this->getValue(1, 1);
 | 
					            $d = $this->getValue(1, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return $a * $d - $b * $c;
 | 
					            return $a * $d - $b * $c;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -148,7 +148,7 @@ class Matrix
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // I expand along the first row
 | 
					        // I expand along the first row
 | 
				
			||||||
        for ($currentColumn = 0; $currentColumn < $this->columnCount; ++$currentColumn) {
 | 
					        for ($currentColumn = 0; $currentColumn < $this->columnCount; ++$currentColumn) {
 | 
				
			||||||
            $firstRowColValue = (float)$this->getValue(0, $currentColumn);
 | 
					            $firstRowColValue = $this->getValue(0, $currentColumn);
 | 
				
			||||||
            $cofactor = $this->getCofactor(0, $currentColumn);
 | 
					            $cofactor = $this->getCofactor(0, $currentColumn);
 | 
				
			||||||
            $itemToAdd = $firstRowColValue * $cofactor;
 | 
					            $itemToAdd = $firstRowColValue * $cofactor;
 | 
				
			||||||
            $result += $itemToAdd;
 | 
					            $result += $itemToAdd;
 | 
				
			||||||
@@ -201,7 +201,7 @@ class Matrix
 | 
				
			|||||||
    public function getInverse(): Matrix|SquareMatrix
 | 
					    public function getInverse(): Matrix|SquareMatrix
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (($this->rowCount == 1) && ($this->columnCount == 1)) {
 | 
					        if (($this->rowCount == 1) && ($this->columnCount == 1)) {
 | 
				
			||||||
            return new SquareMatrix(1.0 / (float)$this->getValue(0, 0));
 | 
					            return new SquareMatrix(1.0 / $this->getValue(0, 0));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Take the simple approach:
 | 
					        // Take the simple approach:
 | 
				
			||||||
@@ -240,9 +240,9 @@ class Matrix
 | 
				
			|||||||
        for ($currentRow = 0; $currentRow < $left->getRowCount(); ++$currentRow) {
 | 
					        for ($currentRow = 0; $currentRow < $left->getRowCount(); ++$currentRow) {
 | 
				
			||||||
            for ($currentColumn = 0; $currentColumn < $right->getColumnCount(); ++$currentColumn) {
 | 
					            for ($currentColumn = 0; $currentColumn < $right->getColumnCount(); ++$currentColumn) {
 | 
				
			||||||
                $resultMatrix[$currentRow][$currentColumn] =
 | 
					                $resultMatrix[$currentRow][$currentColumn] =
 | 
				
			||||||
                    (float)$left->getValue($currentRow, $currentColumn)
 | 
					                    $left->getValue($currentRow, $currentColumn)
 | 
				
			||||||
                    +
 | 
					                    +
 | 
				
			||||||
                    (float)$right->getValue($currentRow, $currentColumn);
 | 
					                    $right->getValue($currentRow, $currentColumn);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -268,8 +268,8 @@ class Matrix
 | 
				
			|||||||
                $productValue = 0.0;
 | 
					                $productValue = 0.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for ($vectorIndex = 0; $vectorIndex < $left->getColumnCount(); ++$vectorIndex) {
 | 
					                for ($vectorIndex = 0; $vectorIndex < $left->getColumnCount(); ++$vectorIndex) {
 | 
				
			||||||
                    $leftValue = (float)$left->getValue($currentRow, $vectorIndex);
 | 
					                    $leftValue = $left->getValue($currentRow, $vectorIndex);
 | 
				
			||||||
                    $rightValue = (float)$right->getValue($vectorIndex, $currentColumn);
 | 
					                    $rightValue = $right->getValue($vectorIndex, $currentColumn);
 | 
				
			||||||
                    $vectorIndexProduct = $leftValue * $rightValue;
 | 
					                    $vectorIndexProduct = $leftValue * $rightValue;
 | 
				
			||||||
                    $productValue += $vectorIndexProduct;
 | 
					                    $productValue += $vectorIndexProduct;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -339,8 +339,8 @@ class Matrix
 | 
				
			|||||||
            for ($currentColumn = 0; $currentColumn < $this->columnCount; ++$currentColumn) {
 | 
					            for ($currentColumn = 0; $currentColumn < $this->columnCount; ++$currentColumn) {
 | 
				
			||||||
                $delta =
 | 
					                $delta =
 | 
				
			||||||
                    abs(
 | 
					                    abs(
 | 
				
			||||||
                        (float)$this->getValue($currentRow, $currentColumn) -
 | 
					                        $this->getValue($currentRow, $currentColumn) -
 | 
				
			||||||
                        (float)$otherMatrix->getValue($currentRow, $currentColumn)
 | 
					                        $otherMatrix->getValue($currentRow, $currentColumn)
 | 
				
			||||||
                    );
 | 
					                    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if ($delta > self::ERROR_TOLERANCE) {
 | 
					                if ($delta > self::ERROR_TOLERANCE) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -112,7 +112,7 @@ final class GaussianWeightedSumFactor extends GaussianFactor
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            $currentWeights[$currentDestinationWeightIndex] = $finalWeight;
 | 
					            $currentWeights[$currentDestinationWeightIndex] = $finalWeight;
 | 
				
			||||||
            $currentWeightsSquared[$currentDestinationWeightIndex] = BasicMath::square($finalWeight);
 | 
					            $currentWeightsSquared[$currentDestinationWeightIndex] = BasicMath::square($finalWeight);
 | 
				
			||||||
            $variableIndices[count($variableWeights)] = 0;
 | 
					            $variableIndices[count($variableWeights)] = 0.0;
 | 
				
			||||||
            $this->varIndexOrdersForWeights[] = $variableIndices;
 | 
					            $this->varIndexOrdersForWeights[] = $variableIndices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->weights[$weightsIndex] = $currentWeights;
 | 
					            $this->weights[$weightsIndex] = $currentWeights;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user