Bunch of generic code standard items. Will need a cleanup.
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
2024-02-02 15:16:11 +00:00
parent 3dddfc05db
commit c18ccd38e2
38 changed files with 117 additions and 26 deletions

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DNW\Skills\Numerics;
/**
@ -13,7 +15,8 @@ class BasicMath
/**
* Squares the input (x^2 = x * x)
*
* @param float $x Value to square (x)
* @param float $x Value to square (x)
*
* @return float The squared value (x^2)
*/
public static function square($x): float
@ -24,8 +27,9 @@ class BasicMath
/**
* Sums the items in $itemsToSum
*
* @param mixed[] $itemsToSum The items to sum,
* @param \Closure $callback The function to apply to each array element before summing.
* @param mixed[] $itemsToSum The items to sum,
* @param \Closure $callback The function to apply to each array element before summing.
*
* @return float The sum.
*/
public static function sum(array $itemsToSum, \Closure $callback): float

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DNW\Skills\Numerics;
/**
@ -198,7 +200,8 @@ class GaussianDistribution implements \Stringable
-1.523e-15,
-9.4e-17,
1.21e-16,
-2.8e-17, ];
-2.8e-17,
];
$ncof = count($coefficients);
$d = 0.0;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DNW\Skills\Numerics;
class IdentityMatrix extends DiagonalMatrix

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DNW\Skills\Numerics;
// The whole purpose of this class is to make the code for the SkillCalculator(s)

View File

@ -1,12 +1,14 @@
<?php
declare(strict_types=1);
namespace DNW\Skills\Numerics;
class SquareMatrix extends Matrix
{
public function __construct(float|int ...$allValues)
{
$rows = (int) sqrt(count($allValues));
$rows = (int)sqrt(count($allValues));
$cols = $rows;
$matrixData = [];

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DNW\Skills\Numerics;
class Vector extends Matrix