-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhvc.c
62 lines (49 loc) · 1.25 KB
/
hvc.c
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <time.h>
#include <math.h>
#include <pthread.h>
#include <stdbool.h>
#include "hv.h"
double *data_maximum(double *data, int nobj, int rows)
{
double *vector;
int n, r, k;
vector = malloc(nobj * sizeof(double));
for (k = 0; k < nobj; k++)
vector[k] = data[k];
for (r = 1; r < rows; r++)
{
for (n = 0; n < nobj; n++, k++)
{
if (vector[n] < data[k])
vector[n] = data[k];
}
}
return vector;
}
double hvc(double **py_list, int dim_x, int dim_y)
{
//int n = 2; // dim_x
//int d = 4; // dim_y
double *dyn_array = malloc(dim_x * dim_y * sizeof(double));
// we need a reshape for this funny tool
int k = 0;
for (int i = 0; i < dim_y; i++)
for (int j = 0; j < dim_x; j++)
dyn_array[k++] = py_list[i][j];
/*for (int j = 0; j < dim_x * dim_y; j++)
{
printf("debug: %f\n", dyn_array[j]);
}*/
// make a reference array
double *res = data_maximum(dyn_array, dim_x, dim_y);
double vol = fpli_hv(dyn_array, dim_x, dim_y, res);
// clean up memory
free(res);
free(dyn_array);
return vol;
}