mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-15 17:16:56 +08:00
Improved variable scoping
This commit is contained in:
@@ -17,10 +17,6 @@ InitCenters(Relation index, VectorArray samples, VectorArray centers, float *low
|
|||||||
FmgrInfo *procinfo;
|
FmgrInfo *procinfo;
|
||||||
Oid collation;
|
Oid collation;
|
||||||
int64 j;
|
int64 j;
|
||||||
double distance;
|
|
||||||
double sum;
|
|
||||||
double choice;
|
|
||||||
Vector *vec;
|
|
||||||
float *weight = palloc(samples->length * sizeof(float));
|
float *weight = palloc(samples->length * sizeof(float));
|
||||||
int numCenters = centers->maxlen;
|
int numCenters = centers->maxlen;
|
||||||
int numSamples = samples->length;
|
int numSamples = samples->length;
|
||||||
@@ -37,13 +33,17 @@ InitCenters(Relation index, VectorArray samples, VectorArray centers, float *low
|
|||||||
|
|
||||||
for (int i = 0; i < numCenters; i++)
|
for (int i = 0; i < numCenters; i++)
|
||||||
{
|
{
|
||||||
|
double sum;
|
||||||
|
double choice;
|
||||||
|
|
||||||
CHECK_FOR_INTERRUPTS();
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
sum = 0.0;
|
sum = 0.0;
|
||||||
|
|
||||||
for (j = 0; j < numSamples; j++)
|
for (j = 0; j < numSamples; j++)
|
||||||
{
|
{
|
||||||
vec = VectorArrayGet(samples, j);
|
Vector *vec = VectorArrayGet(samples, j);
|
||||||
|
double distance;
|
||||||
|
|
||||||
/* Only need to compute distance for new center */
|
/* Only need to compute distance for new center */
|
||||||
/* TODO Use triangle inequality to reduce distance calculations */
|
/* TODO Use triangle inequality to reduce distance calculations */
|
||||||
|
|||||||
Reference in New Issue
Block a user