diff --git a/Math/Numerics/Integration.php b/Math/Numerics/Integration.php index 155781897..68d982694 100644 --- a/Math/Numerics/Integration.php +++ b/Math/Numerics/Integration.php @@ -140,8 +140,11 @@ class Integration $sum1 = 0.0; $sum2 = 0.0; - for ($i = 1; $i < $n; ++$i) { + for ($i = 0; $i < $n; ++$i) { $sum1 += $func($from + $h * $i + $h / 2.0); + } + + for ($i = 1; $i < $n; ++$i) { $sum2 += $func($from + $h * $i); } diff --git a/Stdlib/Base/Heap.php b/Stdlib/Base/Heap.php index 4923b09aa..76bff0879 100644 --- a/Stdlib/Base/Heap.php +++ b/Stdlib/Base/Heap.php @@ -261,6 +261,8 @@ class Heap public function getNLargest(int $n) : array { $nodes = $this->nodes; + \uasort($nodes, $this->compare); + return \array_slice(\array_reverse($nodes), 0, $n); } @@ -276,6 +278,8 @@ class Heap public function getNSmallest(int $n): array { $nodes = $this->nodes; + \uasort($nodes, $this->compare); + return \array_slice($nodes, 0, $n); } diff --git a/Stdlib/Base/Location.php b/Stdlib/Base/Location.php index 5133d5f8f..21b517537 100644 --- a/Stdlib/Base/Location.php +++ b/Stdlib/Base/Location.php @@ -31,7 +31,7 @@ class Location implements \JsonSerializable, \Serializable * @var int * @since 1.0.0 */ - private int $id = 0; + protected int $id = 0; /** * Zip or postal. @@ -39,7 +39,7 @@ class Location implements \JsonSerializable, \Serializable * @var string * @since 1.0.0 */ - private string $postal = ''; + protected string $postal = ''; /** * Name of city. @@ -47,7 +47,7 @@ class Location implements \JsonSerializable, \Serializable * @var string * @since 1.0.0 */ - private string $city = ''; + protected string $city = ''; /** * Name of the country. @@ -55,7 +55,7 @@ class Location implements \JsonSerializable, \Serializable * @var string * @since 1.0.0 */ - private string $country = ''; + protected string $country = ''; /** * Street & district. @@ -63,7 +63,7 @@ class Location implements \JsonSerializable, \Serializable * @var string * @since 1.0.0 */ - private string $address = ''; + protected string $address = ''; /** * Address type @@ -71,7 +71,7 @@ class Location implements \JsonSerializable, \Serializable * @var int * @since 1.0.0 */ - private int $type = AddressType::HOME; + protected int $type = AddressType::HOME; /** * State. @@ -79,7 +79,7 @@ class Location implements \JsonSerializable, \Serializable * @var string * @since 1.0.0 */ - private string $state = ''; + protected string $state = ''; /** * Geo coordinates. @@ -87,7 +87,7 @@ class Location implements \JsonSerializable, \Serializable * @var float[] * @since 1.0.0 */ - private array $geo = ['lat' => 0, 'long' => 0]; + protected array $geo = ['lat' => 0, 'long' => 0]; /** * Get location id