Fixed underflow error

This commit is contained in:
Andrew Kane
2024-03-30 10:06:21 -07:00
parent 49bc34caf3
commit e68db812aa
4 changed files with 28 additions and 18 deletions

View File

@@ -741,6 +741,27 @@ halfvec_to_vector(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(result);
}
/*
* Convert vector to half vec
*/
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_to_halfvec);
Datum
vector_to_halfvec(PG_FUNCTION_ARGS)
{
Vector *vec = PG_GETARG_VECTOR_P(0);
/* TODO Check halfvec dims in InitHalfVector */
HalfVector *result = InitHalfVector(vec->dim);
for (int i = 0; i < vec->dim; i++)
{
result->x[i] = Float4ToHalfUnchecked(vec->x[i]);
CheckElement(result->x[i]);
}
PG_RETURN_POINTER(result);
}
/*
* Get the L2 distance between half vectors
*/

View File

@@ -533,24 +533,6 @@ vector_to_float4(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(result);
}
/*
* Convert vector to half vec
*/
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_to_halfvec);
Datum
vector_to_halfvec(PG_FUNCTION_ARGS)
{
Vector *vec = PG_GETARG_VECTOR_P(0);
/* TODO Check halfvec dims in InitHalfVector */
HalfVector *result = InitHalfVector(vec->dim);
for (int i = 0; i < vec->dim; i++)
result->x[i] = Float4ToHalf(vec->x[i]);
PG_RETURN_POINTER(result);
}
/*
* Get the L2 distance between vectors
*/