mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Warning fixes continued
This commit is contained in:
@@ -92,9 +92,9 @@ public:
|
||||
/**
|
||||
Default constructor. Initializes a new pool.
|
||||
*/
|
||||
PooledAllocator(int blocksize = BLOCKSIZE)
|
||||
PooledAllocator(int blockSize = BLOCKSIZE)
|
||||
{
|
||||
this->blocksize = blocksize;
|
||||
blocksize = blockSize;
|
||||
remaining = 0;
|
||||
base = NULL;
|
||||
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
*/
|
||||
void* allocateMemory(int size)
|
||||
{
|
||||
int blocksize;
|
||||
int blockSize;
|
||||
|
||||
/* Round size up to a multiple of wordsize. The following expression
|
||||
only works for WORDSIZE that is a power of 2, by masking last bits of
|
||||
@@ -138,11 +138,11 @@ public:
|
||||
wastedMemory += remaining;
|
||||
|
||||
/* Allocate new storage. */
|
||||
blocksize = (size + sizeof(void*) + (WORDSIZE-1) > BLOCKSIZE) ?
|
||||
blockSize = (size + sizeof(void*) + (WORDSIZE-1) > BLOCKSIZE) ?
|
||||
size + sizeof(void*) + (WORDSIZE-1) : BLOCKSIZE;
|
||||
|
||||
// use the standard C malloc to allocate memory
|
||||
void* m = ::malloc(blocksize);
|
||||
void* m = ::malloc(blockSize);
|
||||
if (!m) {
|
||||
fprintf(stderr,"Failed to allocate memory.\n");
|
||||
return NULL;
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
int shift = 0;
|
||||
//int shift = (WORDSIZE - ( (((size_t)m) + sizeof(void*)) & (WORDSIZE-1))) & (WORDSIZE-1);
|
||||
|
||||
remaining = blocksize - sizeof(void*) - shift;
|
||||
remaining = blockSize - sizeof(void*) - shift;
|
||||
loc = ((char*)m + sizeof(void*) + shift);
|
||||
}
|
||||
void* rloc = loc;
|
||||
|
||||
@@ -66,9 +66,9 @@ public:
|
||||
/** @param only constructor we use in our code
|
||||
* @param the size of the bitset (in bits)
|
||||
*/
|
||||
DynamicBitset(size_t size)
|
||||
DynamicBitset(size_t sz)
|
||||
{
|
||||
resize(size);
|
||||
resize(sz);
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -116,10 +116,10 @@ public:
|
||||
/** @param resize the bitset so that it contains at least size bits
|
||||
* @param size
|
||||
*/
|
||||
void resize(size_t size)
|
||||
void resize(size_t sz)
|
||||
{
|
||||
size_ = size;
|
||||
bitset_.resize(size / cell_bit_size_ + 1);
|
||||
size_ = sz;
|
||||
bitset_.resize(sz / cell_bit_size_ + 1);
|
||||
}
|
||||
|
||||
/** @param set a bit to true
|
||||
|
||||
@@ -67,12 +67,12 @@ public:
|
||||
* Constructor.
|
||||
*
|
||||
* Params:
|
||||
* size = heap size
|
||||
* sz = heap size
|
||||
*/
|
||||
|
||||
Heap(int size)
|
||||
Heap(int sz)
|
||||
{
|
||||
length = size;
|
||||
length = sz;
|
||||
heap.reserve(length);
|
||||
count = 0;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ private:
|
||||
* indices_length = length of indices vector
|
||||
*
|
||||
*/
|
||||
void chooseCentersRandom(int k, int* indices, int indices_length, int* centers, int& centers_length)
|
||||
void chooseCentersRandom(int k, int* dsindices, int indices_length, int* centers, int& centers_length)
|
||||
{
|
||||
UniqueRandom r(indices_length);
|
||||
|
||||
@@ -122,7 +122,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
centers[index] = indices[rnd];
|
||||
centers[index] = dsindices[rnd];
|
||||
|
||||
for (int j=0; j<index; ++j) {
|
||||
DistanceType sq = distance(dataset[centers[index]], dataset[centers[j]], dataset.cols);
|
||||
@@ -147,14 +147,14 @@ private:
|
||||
* indices = indices in the dataset
|
||||
* Returns:
|
||||
*/
|
||||
void chooseCentersGonzales(int k, int* indices, int indices_length, int* centers, int& centers_length)
|
||||
void chooseCentersGonzales(int k, int* dsindices, int indices_length, int* centers, int& centers_length)
|
||||
{
|
||||
int n = indices_length;
|
||||
|
||||
int rnd = rand_int(n);
|
||||
assert(rnd >=0 && rnd < n);
|
||||
|
||||
centers[0] = indices[rnd];
|
||||
centers[0] = dsindices[rnd];
|
||||
|
||||
int index;
|
||||
for (index=1; index<k; ++index) {
|
||||
@@ -162,9 +162,9 @@ private:
|
||||
int best_index = -1;
|
||||
DistanceType best_val = 0;
|
||||
for (int j=0; j<n; ++j) {
|
||||
DistanceType dist = distance(dataset[centers[0]],dataset[indices[j]],dataset.cols);
|
||||
DistanceType dist = distance(dataset[centers[0]],dataset[dsindices[j]],dataset.cols);
|
||||
for (int i=1; i<index; ++i) {
|
||||
DistanceType tmp_dist = distance(dataset[centers[i]],dataset[indices[j]],dataset.cols);
|
||||
DistanceType tmp_dist = distance(dataset[centers[i]],dataset[dsindices[j]],dataset.cols);
|
||||
if (tmp_dist<dist) {
|
||||
dist = tmp_dist;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ private:
|
||||
}
|
||||
}
|
||||
if (best_index!=-1) {
|
||||
centers[index] = indices[best_index];
|
||||
centers[index] = dsindices[best_index];
|
||||
}
|
||||
else {
|
||||
break;
|
||||
@@ -198,7 +198,7 @@ private:
|
||||
* indices = indices in the dataset
|
||||
* Returns:
|
||||
*/
|
||||
void chooseCentersKMeanspp(int k, int* indices, int indices_length, int* centers, int& centers_length)
|
||||
void chooseCentersKMeanspp(int k, int* dsindices, int indices_length, int* centers, int& centers_length)
|
||||
{
|
||||
int n = indices_length;
|
||||
|
||||
@@ -208,10 +208,10 @@ private:
|
||||
// Choose one random center and set the closestDistSq values
|
||||
int index = rand_int(n);
|
||||
assert(index >=0 && index < n);
|
||||
centers[0] = indices[index];
|
||||
centers[0] = dsindices[index];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
closestDistSq[i] = distance(dataset[indices[i]], dataset[indices[index]], dataset.cols);
|
||||
closestDistSq[i] = distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols);
|
||||
currentPot += closestDistSq[i];
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ private:
|
||||
|
||||
// Compute the new potential
|
||||
double newPot = 0;
|
||||
for (int i = 0; i < n; i++) newPot += std::min( distance(dataset[indices[i]], dataset[indices[index]], dataset.cols), closestDistSq[i] );
|
||||
for (int i = 0; i < n; i++) newPot += std::min( distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols), closestDistSq[i] );
|
||||
|
||||
// Store the best result
|
||||
if ((bestNewPot < 0)||(newPot < bestNewPot)) {
|
||||
@@ -247,9 +247,9 @@ private:
|
||||
}
|
||||
|
||||
// Add the appropriate center
|
||||
centers[centerCount] = indices[bestNewIndex];
|
||||
centers[centerCount] = dsindices[bestNewIndex];
|
||||
currentPot = bestNewPot;
|
||||
for (int i = 0; i < n; i++) closestDistSq[i] = std::min( distance(dataset[indices[i]], dataset[indices[bestNewIndex]], dataset.cols), closestDistSq[i] );
|
||||
for (int i = 0; i < n; i++) closestDistSq[i] = std::min( distance(dataset[dsindices[i]], dataset[dsindices[bestNewIndex]], dataset.cols), closestDistSq[i] );
|
||||
}
|
||||
|
||||
centers_length = centerCount;
|
||||
@@ -518,11 +518,11 @@ private:
|
||||
|
||||
|
||||
|
||||
void computeLabels(int* indices, int indices_length, int* centers, int centers_length, int* labels, DistanceType& cost)
|
||||
void computeLabels(int* dsindices, int indices_length, int* centers, int centers_length, int* labels, DistanceType& cost)
|
||||
{
|
||||
cost = 0;
|
||||
for (int i=0; i<indices_length; ++i) {
|
||||
ElementType* point = dataset[indices[i]];
|
||||
ElementType* point = dataset[dsindices[i]];
|
||||
DistanceType dist = distance(point, dataset[centers[0]], veclen_);
|
||||
labels[i] = 0;
|
||||
for (int j=1; j<centers_length; ++j) {
|
||||
@@ -547,13 +547,13 @@ private:
|
||||
*
|
||||
* TODO: for 1-sized clusters don't store a cluster center (it's the same as the single cluster point)
|
||||
*/
|
||||
void computeClustering(NodePtr node, int* indices, int indices_length, int branching, int level)
|
||||
void computeClustering(NodePtr node, int* dsindices, int indices_length, int branching, int level)
|
||||
{
|
||||
node->size = indices_length;
|
||||
node->level = level;
|
||||
|
||||
if (indices_length < leaf_size_) { // leaf node
|
||||
node->indices = indices;
|
||||
node->indices = dsindices;
|
||||
std::sort(node->indices,node->indices+indices_length);
|
||||
node->childs = NULL;
|
||||
return;
|
||||
@@ -563,10 +563,10 @@ private:
|
||||
std::vector<int> labels(indices_length);
|
||||
|
||||
int centers_length;
|
||||
(this->*chooseCenters)(branching, indices, indices_length, ¢ers[0], centers_length);
|
||||
(this->*chooseCenters)(branching, dsindices, indices_length, ¢ers[0], centers_length);
|
||||
|
||||
if (centers_length<branching) {
|
||||
node->indices = indices;
|
||||
node->indices = dsindices;
|
||||
std::sort(node->indices,node->indices+indices_length);
|
||||
node->childs = NULL;
|
||||
return;
|
||||
@@ -575,7 +575,7 @@ private:
|
||||
|
||||
// assign points to clusters
|
||||
DistanceType cost;
|
||||
computeLabels(indices, indices_length, ¢ers[0], centers_length, &labels[0], cost);
|
||||
computeLabels(dsindices, indices_length, ¢ers[0], centers_length, &labels[0], cost);
|
||||
|
||||
node->childs = pool.allocate<NodePtr>(branching);
|
||||
int start = 0;
|
||||
@@ -583,7 +583,7 @@ private:
|
||||
for (int i=0; i<branching; ++i) {
|
||||
for (int j=0; j<indices_length; ++j) {
|
||||
if (labels[j]==i) {
|
||||
std::swap(indices[j],indices[end]);
|
||||
std::swap(dsindices[j],dsindices[end]);
|
||||
std::swap(labels[j],labels[end]);
|
||||
end++;
|
||||
}
|
||||
@@ -592,7 +592,7 @@ private:
|
||||
node->childs[i] = pool.allocate<Node>();
|
||||
node->childs[i]->pivot = centers[i];
|
||||
node->childs[i]->indices = NULL;
|
||||
computeClustering(node->childs[i],indices+start, end-start, branching, level+1);
|
||||
computeClustering(node->childs[i],dsindices+start, end-start, branching, level+1);
|
||||
start=end;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user