mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-06 05:51:21 +08:00
Use INFINITY instead of DBL_MAX for comparisons
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "catalog/index.h"
|
||||
#include "ivfflat.h"
|
||||
@@ -110,7 +110,7 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
|
||||
{
|
||||
IvfflatBuildState *buildstate = (IvfflatBuildState *) state;
|
||||
double distance;
|
||||
double minDistance = DBL_MAX;
|
||||
double minDistance = INFINITY;
|
||||
int closestCenter = -1;
|
||||
VectorArray centers = buildstate->centers;
|
||||
TupleTableSlot *slot = buildstate->slot;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "ivfflat.h"
|
||||
#include "storage/bufmgr.h"
|
||||
@@ -15,7 +15,7 @@ FindInsertPage(Relation rel, Datum *values, BlockNumber *insertPage, ListInfo *
|
||||
Page cpage;
|
||||
IvfflatList list;
|
||||
double distance;
|
||||
double minDistance = DBL_MAX;
|
||||
double minDistance = INFINITY;
|
||||
BlockNumber nextblkno = IVFFLAT_HEAD_BLKNO;
|
||||
FmgrInfo *procinfo;
|
||||
Oid collation;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "ivfflat.h"
|
||||
#include "miscadmin.h"
|
||||
@@ -33,7 +33,7 @@ InitCenters(Relation index, VectorArray samples, VectorArray centers, double *lo
|
||||
centers->length++;
|
||||
|
||||
for (j = 0; j < numSamples; j++)
|
||||
weight[j] = DBL_MAX;
|
||||
weight[j] = INFINITY;
|
||||
|
||||
for (i = 0; i < numCenters; i++)
|
||||
{
|
||||
@@ -219,7 +219,7 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers)
|
||||
/* Assign each x to its closest initial center c(x) = argmin d(x,c) */
|
||||
for (j = 0; j < numSamples; j++)
|
||||
{
|
||||
minDistance = DBL_MAX;
|
||||
minDistance = INFINITY;
|
||||
closestCenter = -1;
|
||||
|
||||
vec = VectorArrayGet(samples, j);
|
||||
@@ -265,7 +265,7 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers)
|
||||
/* For all centers c, compute s(c) */
|
||||
for (j = 0; j < numCenters; j++)
|
||||
{
|
||||
minDistance = DBL_MAX;
|
||||
minDistance = INFINITY;
|
||||
|
||||
for (k = 0; k < numCenters; k++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user