From e279bb3d7e5c0f578b4b386d8adbf9b817e2366f Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 25 Apr 2021 19:51:35 -0700 Subject: [PATCH] Revert "Use INFINITY instead of DBL_MAX for comparisons" This reverts commit 0aa39a8c0cd57e7d66e04ccf38226fa865f740e6. --- src/ivfbuild.c | 4 ++-- src/ivfinsert.c | 4 ++-- src/ivfkmeans.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ivfbuild.c b/src/ivfbuild.c index 34e07aa..228db3c 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -1,6 +1,6 @@ #include "postgres.h" -#include +#include #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 = INFINITY; + double minDistance = DBL_MAX; int closestCenter = -1; VectorArray centers = buildstate->centers; TupleTableSlot *slot = buildstate->slot; diff --git a/src/ivfinsert.c b/src/ivfinsert.c index bd18c4e..fa10f0f 100644 --- a/src/ivfinsert.c +++ b/src/ivfinsert.c @@ -1,6 +1,6 @@ #include "postgres.h" -#include +#include #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 = INFINITY; + double minDistance = DBL_MAX; BlockNumber nextblkno = IVFFLAT_HEAD_BLKNO; FmgrInfo *procinfo; Oid collation; diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c index 8086ca0..61dd917 100644 --- a/src/ivfkmeans.c +++ b/src/ivfkmeans.c @@ -1,6 +1,6 @@ #include "postgres.h" -#include +#include #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] = INFINITY; + weight[j] = DBL_MAX; 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 = INFINITY; + minDistance = DBL_MAX; 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 = INFINITY; + minDistance = DBL_MAX; for (k = 0; k < numCenters; k++) {