Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2017-10-29 10:24:22 +00:00
parent 97d7bda3c6
commit 270f42a41c
17 changed files with 105 additions and 105 deletions

View File

@ -29,7 +29,7 @@ class Depreciation
public static function getArithmeticProgressivDepreciationRate(float $start, int $duration) : float
{
return $start / ($duration * ($duration+1) / 2);
return $start / ($duration * ($duration + 1) / 2);
}
public static function getArithmeticProgressivDepreciationInT(float $start, int $duration, int $t) : float
@ -44,7 +44,7 @@ class Depreciation
public static function getGeometicProgressivDepreciationRate(float $start, float $residual, int $duration) : float
{
return (1-pow($residual / $start, 1 / $duration));
return (1 - pow($residual / $start, 1 / $duration));
}
public static function getGeometicDegressivDepreciationInT(float $start, float $residual, int $duration, int $t) : float

View File

@ -35,7 +35,7 @@ class ExponentialSmoothing
public function __construct(array $data)
{
$this->data = $data;
$this->data = $data;
}
public function getRMSE() : float
@ -86,7 +86,7 @@ class ExponentialSmoothing
if ($this->rmse < $bestError) {
$bestError = $this->rmse;
$forecast = $tempForecast;
$forecast = $tempForecast;
}
}
}
@ -137,14 +137,14 @@ class ExponentialSmoothing
$alpha = 0.00;
while ($alpha < 1) {
$error = [];
$error = [];
$tempForecast = [];
for ($i = 1; $i < $dataLength; $i++) {
$level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) + (1 - $alpha) * $level[$i-1];
$level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) + (1 - $alpha) * $level[$i - 1];
$tempForecast[$i] = $level[$i];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
}
$tempRMSE = Error::getRootMeanSquaredError($error);
@ -172,8 +172,8 @@ class ExponentialSmoothing
$forecast = [];
$seasonal = [];
for ($i = 1; $i < $cycle+1; $i++) {
$seasonal[$i] = $this->data[$i-1] - $level[0];
for ($i = 1; $i < $cycle + 1; $i++) {
$seasonal[$i] = $this->data[$i - 1] - $level[0];
}
$alpha = 0.00;
@ -182,17 +182,17 @@ class ExponentialSmoothing
while ($gamma < 1) {
$gamma_ = $gamma * (1 - $alpha);
$error = [];
$error = [];
$tempForecast = [];
for ($i = 1; $i < $dataLength; $i++) {
$hm = (int) floor(($i-1) % $cycle) + 1;
$hm = (int) floor(($i - 1) % $cycle) + 1;
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i-1];
$seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $level[$i-1]) + (1 - $gamma_) * $seasonal[$i];
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i - 1];
$seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $level[$i - 1]) + (1 - $gamma_) * $seasonal[$i];
$tempForecast[$i] = $level[$i] + $seasonal[$i+$hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
$tempForecast[$i] = $level[$i] + $seasonal[$i + $hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
}
$tempRMSE = Error::getRootMeanSquaredError($error);
@ -223,7 +223,7 @@ class ExponentialSmoothing
$forecast = [];
$seasonal = [];
for ($i = 1; $i < $cycle+1; $i++) {
for ($i = 1; $i < $cycle + 1; $i++) {
$seasonal[$i] = $this->data[$i] / $level[0];
}
@ -233,17 +233,17 @@ class ExponentialSmoothing
while ($gamma < 1) {
$gamma_ = $gamma * (1 - $alpha);
$error = [];
$error = [];
$tempForecast = [];
for ($i = 1; $i < $dataLength; $i++) {
$hm = (int) floor(($i-1) % $cycle) + 1;
$hm = (int) floor(($i - 1) % $cycle) + 1;
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i-1];
$seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $level[$i-1]) + (1 - $gamma_) * $seasonal[$i];
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i - 1];
$seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $level[$i - 1]) + (1 - $gamma_) * $seasonal[$i];
$tempForecast[$i] = $level[$i] + $seasonal[$i+$hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
$tempForecast[$i] = $level[$i] + $seasonal[$i + $hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
}
$tempRMSE = Error::getRootMeanSquaredError($error);
@ -279,15 +279,15 @@ class ExponentialSmoothing
$beta = 0.00;
while ($beta < 1) {
$error = [];
$error = [];
$tempForecast = [];
for ($i = 1; $i < $dataLength; $i++) {
$level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) + (1 - $alpha) * ($level[$i-1] + $damping * $trend[$i-1]);
$trend[$i] = $beta * ($level[$i] - $level[$i-1]) + (1 - $beta) * $damping * $trend[$i-1];
$level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) + (1 - $alpha) * ($level[$i - 1] + $damping * $trend[$i - 1]);
$trend[$i] = $beta * ($level[$i] - $level[$i - 1]) + (1 - $beta) * $damping * $trend[$i - 1];
$tempForecast[$i] = $level[$i] + $this->dampingSum($damping, $i) * $trend[$i];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
}
$tempRMSE = Error::getRootMeanSquaredError($error);
@ -320,14 +320,14 @@ class ExponentialSmoothing
$seasonal = [];
$sum = 0;
for ($i = 1; $i < $cycle+1; $i++) {
for ($i = 1; $i < $cycle + 1; $i++) {
$sum += ($this->data[$cycle] - $this->data[$i]) / $cycle;
}
$trend[0] *= $sum;
for ($i = 1; $i < $cycle+1; $i++) {
$seasonal[$i] = $this->data[$i-1] - $level[0];
for ($i = 1; $i < $cycle + 1; $i++) {
$seasonal[$i] = $this->data[$i - 1] - $level[0];
}
$alpha = 0.00;
@ -339,18 +339,18 @@ class ExponentialSmoothing
while ($gamma < 1) {
$gamma_ = $gamma * (1 - $alpha);
$error = [];
$error = [];
$tempForecast = [];
for ($i = 1; $i < $dataLength; $i++) {
$hm = (int) floor(($i-1) % $cycle) + 1;
$hm = (int) floor(($i - 1) % $cycle) + 1;
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $seasonal[$i]) + (1 - $alpha) * ($level[$i-1] + $damping * $trend[$i-1]);
$trend[$i] = $beta * ($level[$i] - $level[$i-1]) + (1 - $beta) * $damping * $trend[$i-1];
$seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $level[$i-1]) + (1 - $gamma_) * $seasonal[$i];
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $seasonal[$i]) + (1 - $alpha) * ($level[$i - 1] + $damping * $trend[$i - 1]);
$trend[$i] = $beta * ($level[$i] - $level[$i - 1]) + (1 - $beta) * $damping * $trend[$i - 1];
$seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $level[$i - 1]) + (1 - $gamma_) * $seasonal[$i];
$tempForecast[$i] = $level[$i] + $this->dampingSum($damping, $i) * $trend[$i] + $seasonal[$i+$hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
$tempForecast[$i] = $level[$i] + $this->dampingSum($damping, $i) * $trend[$i] + $seasonal[$i + $hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
}
$tempRMSE = Error::getRootMeanSquaredError($error);
@ -387,13 +387,13 @@ class ExponentialSmoothing
$gamma_ = $gamma * (1 - $alpha);
$sum = 0;
for ($i = 1; $i < $cycle+1; $i++) {
for ($i = 1; $i < $cycle + 1; $i++) {
$sum += ($this->data[$cycle] - $this->data[$i]) / $cycle;
}
$trend[0] *= $sum;
for ($i = 1; $i < $cycle+1; $i++) {
for ($i = 1; $i < $cycle + 1; $i++) {
$seasonal[$i] = $this->data[$i] / $level[0];
}
@ -406,18 +406,18 @@ class ExponentialSmoothing
while ($gamma < 1) {
$gamma_ = $gamma * (1 - $alpha);
$error = [];
$error = [];
$tempForecast = [];
for ($i = 1; $i < $dataLength; $i++) {
$hm = (int) floor(($i-1) % $cycle) + 1;
$hm = (int) floor(($i - 1) % $cycle) + 1;
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $seasonal[$i]) + (1 - $alpha) * ($level[$i-1] + $damping * $trend[$i-1]);
$trend[$i] = $beta * ($level[$i] - $level[$i-1]) + (1 - $beta) * $damping * $trend[$i-1];
$seasonal[$i+$cycle] = $gamma_*($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / ($level[$i-1] + $damping * $trend[$i-1]) + (1 - $gamma_) * $seasonal[$i];
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $seasonal[$i]) + (1 - $alpha) * ($level[$i - 1] + $damping * $trend[$i - 1]);
$trend[$i] = $beta * ($level[$i] - $level[$i - 1]) + (1 - $beta) * $damping * $trend[$i - 1];
$seasonal[$i + $cycle] = $gamma_ * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / ($level[$i - 1] + $damping * $trend[$i - 1]) + (1 - $gamma_) * $seasonal[$i];
$tempForecast[] = ($level[$i] + $this->dampingSum($damping, $i) * $trend[$i-1]) * $seasonal[$i+$hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
$tempForecast[] = ($level[$i] + $this->dampingSum($damping, $i) * $trend[$i - 1]) * $seasonal[$i + $hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
}
$tempRMSE = Error::getRootMeanSquaredError($error);
@ -456,15 +456,15 @@ class ExponentialSmoothing
$beta = 0.00;
while ($beta < 1) {
$error = [];
$error = [];
$tempForecast = [];
for ($i = 1; $i < $dataLength; $i++) {
$level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) + (1 - $alpha) * $level[$i-1] * pow($trend[$i-1], $damping);
$trend[$i] = $beta * ($level[$i] / $level[$i-1]) + (1 - $beta) * pow($trend[$i-1], $damping);
$level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) + (1 - $alpha) * $level[$i - 1] * pow($trend[$i - 1], $damping);
$trend[$i] = $beta * ($level[$i] / $level[$i - 1]) + (1 - $beta) * pow($trend[$i - 1], $damping);
$tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i));
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
}
$tempRMSE = Error::getRootMeanSquaredError($error);
@ -496,14 +496,14 @@ class ExponentialSmoothing
$seasonal = [];
$sum = 0;
for ($i = 1; $i < $cycle+1; $i++) {
for ($i = 1; $i < $cycle + 1; $i++) {
$sum += ($this->data[$cycle] - $this->data[$i]) / $cycle;
}
$trend[0] *= $sum;
for ($i = 1; $i < $cycle+1; $i++) {
$seasonal[$i] = $this->data[$i-1] - $level[0];
for ($i = 1; $i < $cycle + 1; $i++) {
$seasonal[$i] = $this->data[$i - 1] - $level[0];
}
$alpha = 0.00;
@ -515,18 +515,18 @@ class ExponentialSmoothing
while ($gamma < 1) {
$gamma_ = $gamma * (1 - $alpha);
$error = [];
$error = [];
$tempForecast = [];
for ($i = 1; $i < $dataLength; $i++) {
$hm = (int) floor(($i-1) % $cycle) + 1;
$hm = (int) floor(($i - 1) % $cycle) + 1;
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i-1] * pow($trend[$i-1], $damping);
$trend[$i] = $beta * ($level[$i] / $level[$i-1]) + (1 - $beta) * pow($trend[$i-1], $damping);
$seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $level[$i-1] * pow($trend[$i-1], $damping)) + (1 - $gamma_) * $seasonal[$i];
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i - 1] * pow($trend[$i - 1], $damping);
$trend[$i] = $beta * ($level[$i] / $level[$i - 1]) + (1 - $beta) * pow($trend[$i - 1], $damping);
$seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $level[$i - 1] * pow($trend[$i - 1], $damping)) + (1 - $gamma_) * $seasonal[$i];
$tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) + $seasonal[$i+$hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
$tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) + $seasonal[$i + $hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
}
$tempRMSE = Error::getRootMeanSquaredError($error);
@ -562,13 +562,13 @@ class ExponentialSmoothing
$seasonal = [];
$sum = 0;
for ($i = 1; $i < $cycle+1; $i++) {
for ($i = 1; $i < $cycle + 1; $i++) {
$sum += ($this->data[$cycle] - $this->data[$i]) / $cycle;
}
$trend[0] *= $sum;
for ($i = 1; $i < $cycle+1; $i++) {
for ($i = 1; $i < $cycle + 1; $i++) {
$seasonal[$i] = $this->data[$i] / $level[0];
}
@ -581,18 +581,18 @@ class ExponentialSmoothing
while ($gamma < 1) {
$gamma_ = $gamma * (1 - $alpha);
$error = [];
$error = [];
$tempForecast = [];
for ($i = 1; $i < $dataLength; $i++) {
$hm = (int) floor(($i-1) % $cycle) + 1;
$hm = (int) floor(($i - 1) % $cycle) + 1;
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i-1] * pow($trend[$i-1], $damping);
$trend[$i] = $beta * ($level[$i] / $level[$i-1]) + (1 - $beta) * pow($trend[$i-1], $damping);
$seasonal[$i+$cycle] = $gamma_*($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / ($level[$i-1] * pow($trend[$i-1], $damping)) + (1 - $gamma_) * $seasonal[$i];
$level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i - 1] * pow($trend[$i - 1], $damping);
$trend[$i] = $beta * ($level[$i] / $level[$i - 1]) + (1 - $beta) * pow($trend[$i - 1], $damping);
$seasonal[$i + $cycle] = $gamma_ * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / ($level[$i - 1] * pow($trend[$i - 1], $damping)) + (1 - $gamma_) * $seasonal[$i];
$tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) * $seasonal[$i+$hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
$tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) * $seasonal[$i + $hm];
$error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0;
}
$tempRMSE = Error::getRootMeanSquaredError($error);

View File

@ -42,7 +42,7 @@ class Metrics {
*/
public static function abcScore(int $a, int $b, int $c) : int
{
return (int) sqrt($a*$a+$b*$b+$c*$c);
return (int) sqrt($a * $a + $b * $b + $c * $c);
}
/**

View File

@ -45,7 +45,7 @@ class MarketShareEstimation {
{
$sum = 0.0;
for ($i = 0; $i < $participants; $i++) {
$sum += 1 / pow($i+1, $modifier);
$sum += 1 / pow($i + 1, $modifier);
}
return (int) round(pow(1 / ($marketShare * $sum), 1 / $modifier));
@ -68,7 +68,7 @@ class MarketShareEstimation {
{
$sum = 0.0;
for ($i = 0; $i < $participants; $i++) {
$sum += 1 / pow($i+1, $modifier);
$sum += 1 / pow($i + 1, $modifier);
}
return (1 / pow($rank, $modifier)) / $sum;

View File

@ -262,9 +262,9 @@ class FileCache implements CacheInterface
private function getExpire(string $raw) : int
{
$expireStart = strpos($raw, self::DELIM);
$expireEnd = strpos($raw, self::DELIM, $expireStart+1);
$expireEnd = strpos($raw, self::DELIM, $expireStart + 1);
return (int) substr($raw, $expireStart+1, $expireEnd - ($expireStart+1));
return (int) substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1));
}
/**
@ -294,8 +294,8 @@ class FileCache implements CacheInterface
$type = $raw[0];
$expireStart = strpos($raw, self::DELIM);
$expireEnd = strpos($raw, self::DELIM, $expireStart+1);
$cacheExpire = substr($raw, $expireStart+1, $expireEnd - ($expireStart+1));
$expireEnd = strpos($raw, self::DELIM, $expireStart + 1);
$cacheExpire = substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1));
if ($cacheExpire >= 0 && $created + $cacheExpire < $now) {
$this->delete($key);
@ -324,7 +324,7 @@ class FileCache implements CacheInterface
case CacheType::_SERIALIZABLE:
case CacheType::_JSONSERIALIZABLE:
$namespaceStart = strpos($raw, self::DELIM, $expireEnd);
$namespaceEnd = strpos($raw, self::DELIM, $namespaceStart+1);
$namespaceEnd = strpos($raw, self::DELIM, $namespaceStart + 1);
$namespace = substr($raw, $namespaceStart, $namespaceEnd);
$value = $namespace::unserialize(substr($raw, $namespaceEnd + 1));
@ -357,8 +357,8 @@ class FileCache implements CacheInterface
$now = time();
$raw = file_get_contents($path);
$expireStart = strpos($raw, self::DELIM);
$expireEnd = strpos($raw, self::DELIM, $expireStart+1);
$cacheExpire = substr($raw, $expireStart+1, $expireEnd - ($expireStart+1));
$expireEnd = strpos($raw, self::DELIM, $expireStart + 1);
$cacheExpire = substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1));
if ($cacheExpire >= 0 && $created + $cacheExpire > $now) {
File::delete($path);

View File

@ -377,7 +377,7 @@ class DataMapperAbstract implements DataMapperInterface
{
self::extend(__CLASS__);
$objId = self::createModelArray($obj);
$objId = self::createModelArray($obj);
settype($objId, static::$columns[static::$primaryField]['type']);
$obj[static::$columns[static::$primaryField]['internal']] = $objId;

View File

@ -37,6 +37,6 @@ class InvalidConnectionConfigException extends \InvalidArgumentException
*/
public function __construct(string $message = '', int $code = 0, \Exception $previous = null)
{
parent::__construct('Missing config value for "'. $message .'".', $code, $previous);
parent::__construct('Missing config value for "' . $message . '".', $code, $previous);
}
}

View File

@ -55,7 +55,7 @@ final class MonotoneChain
}
// Upper hull
for ($i = $n - 2, $t = $k+1; $i >= 0; $i--) {
for ($i = $n - 2, $t = $k + 1; $i >= 0; $i--) {
while ($k >= $t && self::cross($result[$k - 2], $result[$k - 1], $points[$i]) <= 0) {
$k--;
}
@ -65,7 +65,7 @@ final class MonotoneChain
ksort($result);
return array_slice($result, 0, $k-1);
return array_slice($result, 0, $k - 1);
}
return $points;

View File

@ -157,7 +157,7 @@ class Polygon implements D2ShapeInterface
}
// Inside or ontop?
$countIntersect = 0;
$countIntersect = 0;
$polygon_count = count($polygon);
// todo: return based on highest possibility not by first match

View File

@ -46,7 +46,7 @@ class CholeskyDecomposition
}
}
for ($k = $i+1; $k < $this->m; ++$k) {
for ($k = $i + 1; $k < $this->m; ++$k) {
$this->L[$i][$k] = 0.0;
}
}

View File

@ -48,7 +48,7 @@ class LUDecomposition
for ($i = 0; $i < $this->m; ++$i) {
$LUrowi = $this->LU[$i];
// Most of the time is spent in the following dot product.
$kmax = min($i,$j);
$kmax = min($i, $j);
$s = 0.0;
for ($k = 0; $k < $kmax; ++$k) {
$s += $LUrowi[$k] * $LUcolj[$k];
@ -57,7 +57,7 @@ class LUDecomposition
}
// Find pivot and exchange if necessary.
$p = $j;
for ($i = $j+1; $i < $this->m; ++$i) {
for ($i = $j + 1; $i < $this->m; ++$i) {
if (abs($LUcolj[$i]) > abs($LUcolj[$p])) {
$p = $i;
}
@ -75,7 +75,7 @@ class LUDecomposition
}
// Compute multipliers.
if (($j < $this->m) && ($this->LU[$j][$j] != 0.0)) {
for ($i = $j+1; $i < $this->m; ++$i) {
for ($i = $j + 1; $i < $this->m; ++$i) {
$this->LU[$i][$j] /= $this->LU[$j][$j];
}
}
@ -159,11 +159,11 @@ class LUDecomposition
}
$nx = $B->getM();
$X = $B->getMatrix($this->piv, 0, $nx-1);
$X = $B->getMatrix($this->piv, 0, $nx - 1);
// Solve L*Y = B(piv,:)
for ($k = 0; $k < $this->n; ++$k) {
for ($i = $k+1; $i < $this->n; ++$i) {
for ($i = $k + 1; $i < $this->n; ++$i) {
for ($j = 0; $j < $nx; ++$j) {
$X->A[$i][$j] -= $X->A[$k][$j] * $this->LU[$i][$k];
}
@ -171,7 +171,7 @@ class LUDecomposition
}
// Solve U*X = Y;
for ($k = $this->n-1; $k >= 0; --$k) {
for ($k = $this->n - 1; $k >= 0; --$k) {
for ($j = 0; $j < $nx; ++$j) {
$X->A[$k][$j] /= $this->LU[$k][$k];
}

View File

@ -51,13 +51,13 @@ class QRDecomposition
$this->QR[$k][$k] += 1.0;
// Apply transformation to remaining columns.
for ($j = $k+1; $j < $this->n; ++$j) {
for ($j = $k + 1; $j < $this->n; ++$j) {
$s = 0.0;
for ($i = $k; $i < $this->m; ++$i) {
$s += $this->QR[$i][$k] * $this->QR[$i][$j];
}
$s = -$s/$this->QR[$k][$k];
$s = -$s / $this->QR[$k][$k];
for ($i = $k; $i < $this->m; ++$i) {
$this->QR[$i][$j] += $s * $this->QR[$i][$k];
}
@ -125,7 +125,7 @@ class QRDecomposition
{
$Q = [[]];
for ($k = $this->n-1; $k >= 0; --$k) {
for ($k = $this->n - 1; $k >= 0; --$k) {
for ($i = 0; $i < $this->m; ++$i) {
$Q[$i][$k] = 0.0;
}
@ -137,7 +137,7 @@ class QRDecomposition
for ($i = $k; $i < $this->m; ++$i) {
$s += $this->QR[$i][$k] * $Q[$i][$j];
}
$s = -$s/$this->QR[$k][$k];
$s = -$s / $this->QR[$k][$k];
for ($i = $k; $i < $this->m; ++$i) {
$Q[$i][$j] += $s * $this->QR[$i][$k];
}
@ -168,20 +168,20 @@ class QRDecomposition
for ($i = $k; $i < $this->m; ++$i) {
$s += $this->QR[$i][$k] * $X[$i][$j];
}
$s = -$s/$this->QR[$k][$k];
$s = -$s / $this->QR[$k][$k];
for ($i = $k; $i < $this->m; ++$i) {
$X[$i][$j] += $s * $this->QR[$i][$k];
}
}
}
// Solve R*X = Y;
for ($k = $this->n-1; $k >= 0; --$k) {
for ($k = $this->n - 1; $k >= 0; --$k) {
for ($j = 0; $j < $nx; ++$j) {
$X[$k][$j] /= $this->Rdiag[$k];
}
for ($i = 0; $i < $k; ++$i) {
for ($j = 0; $j < $nx; ++$j) {
$X[$i][$j] -= $X[$k][$j]* $this->QR[$i][$k];
$X[$i][$j] -= $X[$k][$j] * $this->QR[$i][$k];
}
}
}
@ -189,6 +189,6 @@ class QRDecomposition
$matrix = new Matrix();
$matrix->setArray($X);
return $matrix->getMatrix(0, $this->n-1, 0, $nx);
return $matrix->getMatrix(0, $this->n - 1, 0, $nx);
}
}

View File

@ -45,11 +45,11 @@ class NaiveBayesFilter
$n = 0.0;
foreach ($toMatch as $element) {
if (isset($normalizedDict[$element])) {
$n += log(1-$normalizedDict[$element]['match'] / $normalizedDict[$element]['total']) - log($normalizedDict[$element]['match'] / $normalizedDict[$element]['total']);
$n += log(1 - $normalizedDict[$element]['match'] / $normalizedDict[$element]['total']) - log($normalizedDict[$element]['match'] / $normalizedDict[$element]['total']);
}
}
return 1 / (1+exp($n));
return 1 / (1 + exp($n));
}
private function normalizeDictionary() : array

View File

@ -282,7 +282,7 @@ class SmartDateTime extends \DateTime
// add difference to $weekStartsWith counting backwards from days of previous month (reorder so that lowest value first)
for ($i = $daysPreviousMonth - $diffToWeekStart; $i < $daysPreviousMonth; $i++) {
$days[] = new \DateTime($previousMonth->format('Y') . '-' . $previousMonth->format('m') . '-' . ($i+1));
$days[] = new \DateTime($previousMonth->format('Y') . '-' . $previousMonth->format('m') . '-' . ($i + 1));
}
// add normal count of current days

View File

@ -154,11 +154,11 @@ class BinaryTree extends Tree
$right = $this->getRight($node);
if (isset($left)) {
$this->getVerticalOrder($left, $horizontalDistance-1, $order);
$this->getVerticalOrder($left, $horizontalDistance - 1, $order);
}
if (isset($right)) {
$this->getVerticalOrder($right, $horizontalDistance+1, $order);
$this->getVerticalOrder($right, $horizontalDistance + 1, $order);
}
}

View File

@ -85,7 +85,7 @@ class Caesar
$ascii = ord($raw[$i]) - ord($key[$j]);
if ($ascii < self::LIMIT_LOWER) {
$ascii = self::LIMIT_UPPER + ($ascii - self::LIMIT_LOWER) ;
$ascii = self::LIMIT_UPPER + ($ascii - self::LIMIT_LOWER);
}
$result .= chr($ascii);

View File

@ -232,7 +232,7 @@ abstract class ViewAbstract implements \Serializable
ob_start();
/** @noinspection PhpIncludeInspection */
$includeData = include $path;
$ob = ob_get_clean();
$ob = ob_get_clean();
if (is_array($includeData)) {
return json_encode($includeData);