blob: 28099e8c0e45877d30519f0c92b9cb42b3979d32 (
plain) (
blame)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 | /********************************
Author: Sravanthi Kota Venkata
********************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "localization.h"
I2D* weightedSample(F2D* w)
{
    I2D *bin;
    F2D *seed;
    int n, i, j;
    n = w->height;
    seed = randWrapper(n, 1);
    bin = iSetArray(n, 1, 0);
    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            if(asubsref(seed,j) > 0)
                asubsref(bin,j) = asubsref(bin,j) + 1;
        }
        for(j=0; j<n; j++)
            asubsref(seed,j) = asubsref(seed,j) - asubsref(w,i);
    }
    free(seed);
    return bin;
}
 |