mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-03 03:00:56 +08:00
Fixed infinite values with vector addition and subtraction
This commit is contained in:
@@ -656,6 +656,10 @@ vector_add(PG_FUNCTION_ARGS)
|
||||
for (int i = 0, imax = a->dim; i < imax; i++)
|
||||
rx[i] = ax[i] + bx[i];
|
||||
|
||||
for (int i = 0, imax = a->dim; i < imax; i++)
|
||||
if (isinf(rx[i]))
|
||||
float_overflow_error();
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
@@ -682,6 +686,10 @@ vector_sub(PG_FUNCTION_ARGS)
|
||||
for (int i = 0, imax = a->dim; i < imax; i++)
|
||||
rx[i] = ax[i] - bx[i];
|
||||
|
||||
for (int i = 0, imax = a->dim; i < imax; i++)
|
||||
if (isinf(rx[i]))
|
||||
float_overflow_error();
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user