mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 14:08:40 +00:00
fix matrix exp and cosine metric
This commit is contained in:
parent
c52b6c8863
commit
1f9f97f8d9
|
|
@ -917,15 +917,14 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
$matrix = $identity;
|
$matrix = $identity;
|
||||||
|
|
||||||
$factorial = 1;
|
$factorial = 1;
|
||||||
$pow = $matrix;
|
$pow = clone $matrix;
|
||||||
|
|
||||||
for ($i = 1; $i <= $iterations; ++$i) {
|
for ($i = 1; $i <= $iterations; ++$i) {
|
||||||
$factorial *= $i;
|
$factorial *= $i;
|
||||||
$coeff = 1 / $factorial;
|
$coeff = 1 / $factorial;
|
||||||
|
|
||||||
$term = $pow->mult($coeff);
|
$term = clone $pow->mult($this);
|
||||||
$matrix = $matrix->add($term);
|
$matrix = $matrix->add($term->mult($coeff));
|
||||||
$pow = $pow->mult($matrix); // @todo: maybe wrong order?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $matrix;
|
return $matrix;
|
||||||
|
|
|
||||||
|
|
@ -111,8 +111,8 @@ final class MetricsND
|
||||||
}
|
}
|
||||||
|
|
||||||
$dotProduct = 0;
|
$dotProduct = 0;
|
||||||
for ($i = 0; $i < $length; ++$i) {
|
foreach ($a as $id => $_) {
|
||||||
$dotProduct += $a[$i] * $b[$i];
|
$dotProduct += $a[$id] * $b[$id];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sumOfSquares = 0;
|
$sumOfSquares = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user