code fixes

This commit is contained in:
Dennis Eichhorn 2023-10-15 17:41:45 +00:00
parent 513fa7bf8b
commit 0b5d51f9b8
6 changed files with 23 additions and 22 deletions

View File

@ -177,7 +177,7 @@ final class MarkovChain
$prob = 1.0; $prob = 1.0;
for ($i = $this->order; $i < $length; ++$i) { for ($i = $this->order; $i < $length; ++$i) {
$prob *= $this->data[\implode($key)][$path[$i]] ?? 0.0; $prob *= $this->data[\implode(' ', $key)][$path[$i]] ?? 0.0;
$key[] = $path[$i]; $key[] = $path[$i];
\array_shift($key); \array_shift($key);

View File

@ -433,7 +433,7 @@ final class ReadMapper extends DataMapperAbstract
$query = $this->getQuery( $query = $this->getQuery(
null, null,
[ [
'COUNT(' . (empty($this->columns) ? '*' : \implode($this->columns)) . ')' => 'count' 'COUNT(' . (empty($this->columns) ? '*' : \implode(',', $this->columns)) . ')' => 'count',
] ]
); );
@ -452,7 +452,7 @@ final class ReadMapper extends DataMapperAbstract
$query = $this->getQuery( $query = $this->getQuery(
null, null,
[ [
'SUM(' . (empty($this->columns) ? '*' : \implode($this->columns)) . ')' => 'sum' 'SUM(' . (empty($this->columns) ? '*' : \implode(',', $this->columns)) . ')' => 'sum',
] ]
); );

View File

@ -70,7 +70,7 @@ final class GrahamScan
$subpoints = \array_slice($points, 2, $count); $subpoints = \array_slice($points, 2, $count);
\usort($subpoints, function (array $a, array $b) use ($c) : int { \usort($subpoints, function (array $a, array $b) use ($c) : int {
// @todo: Might be wrong order of comparison // @todo: Might be wrong order of comparison
return \atan2($a['y'] - $c['y'], $a['x'] - $c['x']) <=> \atan2( $b['y'] - $c['y'], $b['x'] - $c['x']); return \atan2($a['y'] - $c['y'], $a['x'] - $c['x']) <=> \atan2($b['y'] - $c['y'], $b['x'] - $c['x']);
}); });
/** @var array<int, array{x:int|float, y:int|float}> $points */ /** @var array<int, array{x:int|float, y:int|float}> $points */
@ -106,9 +106,9 @@ final class GrahamScan
/** /**
* Counterclockwise rotation * Counterclockwise rotation
* *
* @param array<x:int|float, y:int|float> $a Vector * @param array{x:int|float, y:int|float} $a Vector
* @param array<x:int|float, y:int|float> $b Vector * @param array{x:int|float, y:int|float} $b Vector
* @param array<x:int|float, y:int|float> $c Vector * @param array{x:int|float, y:int|float} $c Vector
* *
* @return int|float * @return int|float
* *

View File

@ -26,6 +26,7 @@ namespace phpOMS\Math\Optimization;
class Simplex class Simplex
{ {
private int $m = 0; private int $m = 0;
private int $n = 0; private int $n = 0;
private array $A = []; private array $A = [];
@ -40,7 +41,7 @@ class Simplex
private array $Nonbasic = []; private array $Nonbasic = [];
private function pivot (int $x, int $y) private function pivot (int $x, int $y) : void
{ {
for ($j = 0; $j < $this->n; ++$j) { for ($j = 0; $j < $this->n; ++$j) {
if ($j !== $y) { if ($j !== $y) {

View File

@ -185,7 +185,7 @@ class BinarySearchTree
if ($comparison < 0) { if ($comparison < 0) {
if ($current->left === null) { if ($current->left === null) {
$BST = new BinarySearchTree(); $BST = new self();
$new = new Node($node->key, $node->data); $new = new Node($node->key, $node->data);
$new->parent = $current; $new->parent = $current;
$new->tree = $BST; $new->tree = $BST;
@ -197,7 +197,7 @@ class BinarySearchTree
} }
} elseif ($comparison > 0) { } elseif ($comparison > 0) {
if ($current->right === null) { if ($current->right === null) {
$BST = new BinarySearchTree(); $BST = new self();
$new = new Node($node->key, $node->data); $new = new Node($node->key, $node->data);
$new->parent = $current; $new->parent = $current;
$new->tree = $BST; $new->tree = $BST;

View File

@ -14,9 +14,9 @@ declare(strict_types=1);
namespace phpOMS\tests\Utils\IO\Spreadsheet; namespace phpOMS\tests\Utils\IO\Spreadsheet;
use phpOMS\tests\Autoloader;
use phpOMS\DataStorage\Database\Connection\SQLiteConnection; use phpOMS\DataStorage\Database\Connection\SQLiteConnection;
use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\tests\Autoloader;
use phpOMS\Utils\IO\Spreadsheet\SpreadsheetDatabaseMapper; use phpOMS\Utils\IO\Spreadsheet\SpreadsheetDatabaseMapper;
use phpOMS\Utils\StringUtils; use phpOMS\Utils\StringUtils;