mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 01:38:41 +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;
|
||||
|
||||
$factorial = 1;
|
||||
$pow = $matrix;
|
||||
$pow = clone $matrix;
|
||||
|
||||
for ($i = 1; $i <= $iterations; ++$i) {
|
||||
$factorial *= $i;
|
||||
$coeff = 1 / $factorial;
|
||||
|
||||
$term = $pow->mult($coeff);
|
||||
$matrix = $matrix->add($term);
|
||||
$pow = $pow->mult($matrix); // @todo: maybe wrong order?
|
||||
$term = clone $pow->mult($this);
|
||||
$matrix = $matrix->add($term->mult($coeff));
|
||||
}
|
||||
|
||||
return $matrix;
|
||||
|
|
|
|||
|
|
@ -111,8 +111,8 @@ final class MetricsND
|
|||
}
|
||||
|
||||
$dotProduct = 0;
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$dotProduct += $a[$i] * $b[$i];
|
||||
foreach ($a as $id => $_) {
|
||||
$dotProduct += $a[$id] * $b[$id];
|
||||
}
|
||||
|
||||
$sumOfSquares = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user