From 1e197375c59cb5982510fe76287fd065b87f0350 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 22 Oct 2023 18:26:48 +0000 Subject: [PATCH] fix tests --- Math/Solver/Root/Illinois.php | 2 +- Math/Solver/Root/RegulaFalsi.php | 2 +- Math/Topology/Kernel2D.php | 32 ++++++++++++++++---------------- Message/ResponseAbstract.php | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Math/Solver/Root/Illinois.php b/Math/Solver/Root/Illinois.php index 90b5d8091..c8e87f25a 100644 --- a/Math/Solver/Root/Illinois.php +++ b/Math/Solver/Root/Illinois.php @@ -87,6 +87,6 @@ final class Illinois ++$iteration; } - return ($a + $b) / 2; + return $c; } } diff --git a/Math/Solver/Root/RegulaFalsi.php b/Math/Solver/Root/RegulaFalsi.php index fe9bb9210..7916b40b0 100644 --- a/Math/Solver/Root/RegulaFalsi.php +++ b/Math/Solver/Root/RegulaFalsi.php @@ -76,6 +76,6 @@ final class RegulaFalsi ++$iteration; } - return ($a + $b) / 2; + return $c; } } diff --git a/Math/Topology/Kernel2D.php b/Math/Topology/Kernel2D.php index 719497d12..400e96356 100644 --- a/Math/Topology/Kernel2D.php +++ b/Math/Topology/Kernel2D.php @@ -17,7 +17,7 @@ namespace phpOMS\Math\Topology; /** * Kernels. * - * The bandwidth in the following functions is equivalent with sigma. + * The bandwidth in the following functions is equivalent with 2 * sigma. * * @package phpOMS\Math\Topology * @license OMS License 2.0 @@ -82,10 +82,10 @@ final class Kernel2D */ public static function epanechnikovKernel(float $distance, float $bandwidth) : float { - if (\abs($distance) <= $bandwidth) { - $u = \abs($distance) / $bandwidth; + if (\abs($distance) <= $bandwidth / 2) { + $u = \abs($distance) / ($bandwidth / 2); - return 0.75 * (1 - $u * $u) / $bandwidth; + return 0.75 * (1 - $u * $u) / ($bandwidth / 2); } else { return 0.0; } @@ -103,10 +103,10 @@ final class Kernel2D */ public static function quarticKernel(float $distance, float $bandwidth) : float { - if (\abs($distance) <= $bandwidth) { - $u = \abs($distance) / $bandwidth; + if (\abs($distance) <= $bandwidth / 2) { + $u = \abs($distance) / ($bandwidth / 2); - return (15 / 16) * (1 - $u * $u) * (1 - $u * $u) / $bandwidth; + return (15 / 16) * (1 - $u * $u) * (1 - $u * $u) / ($bandwidth / 2); } else { return 0.0; } @@ -124,10 +124,10 @@ final class Kernel2D */ public static function triweightKernel(float $distance, float $bandwidth) : float { - if (\abs($distance) <= $bandwidth) { - $u = \abs($distance) / $bandwidth; + if (\abs($distance) <= $bandwidth / 2) { + $u = \abs($distance) / ($bandwidth / 2); - return (35 / 32) * (1 - $u * $u) * (1 - $u * $u) * (1 - $u * $u) / $bandwidth; + return (35 / 32) * (1 - $u * $u) * (1 - $u * $u) * (1 - $u * $u) / ($bandwidth / 2); } else { return 0.0; } @@ -145,10 +145,10 @@ final class Kernel2D */ public static function tricubeKernel(float $distance, float $bandwidth) : float { - if (\abs($distance) <= $bandwidth) { - $u = \abs($distance) / $bandwidth; + if (\abs($distance) <= $bandwidth / 2) { + $u = \abs($distance) / ($bandwidth / 2); - return (70 / 81) * (1 - $u * $u * $u) * (1 - $u * $u * $u) * (1 - $u * $u * $u) / $bandwidth; + return (70 / 81) * (1 - $u * $u * $u) * (1 - $u * $u * $u) * (1 - $u * $u * $u) / ($bandwidth / 2); } else { return 0.0; } @@ -181,8 +181,8 @@ final class Kernel2D */ public static function cosineKernel(float $distance, float $bandwidth) : float { - return \abs($distance) <= $bandwidth - ? (\M_PI / 4) * \cos(\M_PI * $distance / (2 * $bandwidth)) / $bandwidth + return \abs($distance) <= $bandwidth / 2 + ? (\M_PI / 4) * \cos(\M_PI * $distance / $bandwidth) / ($bandwidth / 2) : 0.0; } @@ -198,6 +198,6 @@ final class Kernel2D */ public static function logisticKernel(float $distance, float $bandwidth) : float { - return 1 / (\exp($distance / $bandwidth) + 2 + \exp(-$distance / $bandwidth)); + return 1 / (\exp($distance / ($bandwidth / 2)) + 2 + \exp(-$distance / ($bandwidth / 2))); } } diff --git a/Message/ResponseAbstract.php b/Message/ResponseAbstract.php index 16aa7f393..45789786c 100755 --- a/Message/ResponseAbstract.php +++ b/Message/ResponseAbstract.php @@ -51,7 +51,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface * * @since 1.0.0 */ - public function getData(mixed $key, string $type = null) : mixed + public function getData(mixed $key = null, string $type = null) : mixed { if ($key === null) { return $this->data;