mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-12 15:46:54 +08:00
Moved overflow check
This commit is contained in:
@@ -398,9 +398,6 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers)
|
|||||||
|
|
||||||
if (centerCounts[j] > 0)
|
if (centerCounts[j] > 0)
|
||||||
{
|
{
|
||||||
for (k = 0; k < dimensions; k++)
|
|
||||||
vec->x[k] /= centerCounts[j];
|
|
||||||
|
|
||||||
/* Double avoids overflow, but requires more memory */
|
/* Double avoids overflow, but requires more memory */
|
||||||
/* TODO Update bounds */
|
/* TODO Update bounds */
|
||||||
for (k = 0; k < dimensions; k++)
|
for (k = 0; k < dimensions; k++)
|
||||||
@@ -408,6 +405,9 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers)
|
|||||||
if (isinf(vec->x[k]))
|
if (isinf(vec->x[k]))
|
||||||
vec->x[k] = vec->x[k] > 0 ? FLT_MAX : -FLT_MAX;
|
vec->x[k] = vec->x[k] > 0 ? FLT_MAX : -FLT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (k = 0; k < dimensions; k++)
|
||||||
|
vec->x[k] /= centerCounts[j];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user