extract functions from loops and remove unused code

This commit is contained in:
Arkadiusz Kondas 2016-08-02 13:23:58 +02:00
parent 637fd613b8
commit f186aa9c0b
2 changed files with 6 additions and 5 deletions

View File

@ -61,7 +61,7 @@ class Space extends SplObjectStorage
*/
public function addPoint(array $coordinates, $data = null)
{
return $this->attach($this->newPoint($coordinates), $data);
$this->attach($this->newPoint($coordinates), $data);
}
/**
@ -74,7 +74,7 @@ class Space extends SplObjectStorage
throw new InvalidArgumentException('can only attach points to spaces');
}
return parent::attach($point, $data);
parent::attach($point, $data);
}
/**
@ -230,8 +230,8 @@ class Space extends SplObjectStorage
protected function initializeKMPPClusters(int $clustersNumber)
{
$clusters = [];
$position = rand(1, count($this));
for ($i = 1, $this->rewind(); $i < $position && $this->valid(); $i++, $this->next());
$this->rewind();
$clusters[] = new Cluster($this, $this->current()->getCoordinates());
$distances = new SplObjectStorage();

View File

@ -193,7 +193,8 @@ class Matrix
$product = [];
$multiplier = $matrix->toArray();
for ($i = 0; $i < $this->rows; ++$i) {
for ($j = 0; $j < $matrix->getColumns(); ++$j) {
$columns = $matrix->getColumns();
for ($j = 0; $j < $columns; ++$j) {
$product[$i][$j] = 0;
for ($k = 0; $k < $this->columns; ++$k) {
$product[$i][$j] += $this->matrix[$i][$k] * $multiplier[$k][$j];