String based "name" for Variable class removed for performance

This commit is contained in:
2024-03-19 15:09:13 +00:00
parent 0095829906
commit ae5d2a8b73
14 changed files with 28 additions and 83 deletions

View File

@ -6,15 +6,12 @@ namespace DNW\Skills\FactorGraphs;
use DNW\Skills\Numerics\GaussianDistribution;
class Variable implements \Stringable
class Variable
{
private readonly string $name;
private mixed $value;
public function __construct(string $name, private GaussianDistribution $prior)
public function __construct(private GaussianDistribution $prior)
{
$this->name = 'Variable[' . $name . ']';
$this->resetToPrior();
}
@ -32,9 +29,4 @@ class Variable implements \Stringable
{
$this->value = $this->prior;
}
public function __toString(): string
{
return $this->name;
}
}