Use INFINITY instead of DBL_MAX for comparisons

This commit is contained in:
Andrew Kane
2021-04-25 19:16:29 -07:00
parent e0854e6381
commit 0aa39a8c0c
3 changed files with 8 additions and 8 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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++)
{