Commit 37307dcb authored by Sven Neumann's avatar Sven Neumann

more micro optimizations

parent f4893406
...@@ -324,8 +324,8 @@ stagetwo (lab *points, ...@@ -324,8 +324,8 @@ stagetwo (lab *points,
{ {
gint curdim = depth % dims; gint curdim = depth % dims;
gfloat min, max; gfloat min, max;
gint i, countsm, countgr, smallc, bigc;
gfloat pivotvalue, curval; gfloat pivotvalue, curval;
gint i, countsm, countgr, smallc, bigc;
gint sum; gint sum;
lab *point; lab *point;
lab *smallerpoints; lab *smallerpoints;
...@@ -405,9 +405,7 @@ stagetwo (lab *points, ...@@ -405,9 +405,7 @@ stagetwo (lab *points,
sum = 0; sum = 0;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ sum += points[i].cardinality;
sum += points[i].cardinality;
}
if (((sum * 100.0) / total) >= threshold) if (((sum * 100.0) / total) >= threshold)
{ {
...@@ -462,14 +460,13 @@ create_signature (lab *input, ...@@ -462,14 +460,13 @@ create_signature (lab *input,
const gfloat *limits, const gfloat *limits,
gint *returnlength) gint *returnlength)
{ {
ArrayList *clusters1; ArrayList *clusters;
ArrayList *clusters2;
ArrayList *curelem; ArrayList *curelem;
lab *centroids; lab *centroids;
lab *cluster; lab *cluster;
lab *rval; lab *rval;
gint k, i; gint k, i;
gint clusters1size; gint size;
if (length < 1) if (length < 1)
{ {
...@@ -477,12 +474,12 @@ create_signature (lab *input, ...@@ -477,12 +474,12 @@ create_signature (lab *input,
return NULL; return NULL;
} }
clusters1 = list_new (); clusters = list_new ();
stageone (input, SIOX_DIMS, 0, clusters1, limits, length); stageone (input, SIOX_DIMS, 0, clusters, limits, length);
clusters1size = list_size (clusters1); size = list_size (clusters);
centroids = g_new (lab, clusters1size); centroids = g_new (lab, size);
curelem = clusters1; curelem = clusters;
i = 0; i = 0;
while (curelem->array) while (curelem->array)
...@@ -503,6 +500,7 @@ create_signature (lab *input, ...@@ -503,6 +500,7 @@ create_signature (lab *input,
centroids[i].l = l / curelem->arraylength; centroids[i].l = l / curelem->arraylength;
centroids[i].a = a / curelem->arraylength; centroids[i].a = a / curelem->arraylength;
centroids[i].b = b / curelem->arraylength; centroids[i].b = b / curelem->arraylength;
centroids[i].cardinality = curelem->arraylength; centroids[i].cardinality = curelem->arraylength;
i++; i++;
...@@ -510,19 +508,20 @@ create_signature (lab *input, ...@@ -510,19 +508,20 @@ create_signature (lab *input,
} }
#ifdef DEBUG #ifdef DEBUG
g_printerr ("step #1 -> %d clusters\n", clusters1size); g_printerr ("step #1 -> %d clusters\n", size);
#endif #endif
clusters2 = list_new (); free_list (clusters);
clusters = list_new ();
stagetwo (centroids, stagetwo (centroids,
SIOX_DIMS, 0, clusters2, limits, clusters1size, length, SIOX_DIMS, 0, clusters, limits, size, length,
0.1 /* magic constant, see paper by tomasi */); 0.1 /* magic constant, see paper by tomasi */);
rval = list_to_array (clusters2, returnlength); rval = list_to_array (clusters, returnlength);
free_list (clusters2); free_list (clusters);
free_list (clusters1);
#ifdef DEBUG #ifdef DEBUG
g_printerr ("step #2 -> %d clusters\n", returnlength[0]); g_printerr ("step #2 -> %d clusters\n", returnlength[0]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment