-
Notifications
You must be signed in to change notification settings - Fork 0
/
testassembly.c
83 lines (67 loc) · 2.44 KB
/
testassembly.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include "pqnn64c.c"
//_____________________Funzioni esterne scritte in assembly_____________________
//extern float distance(VECTOR x1, VECTOR x2, int d);
//extern void test_residual(VECTOR res, VECTOR x,VECTOR centroid,int d);
//extern float test_objective(int n,int m, MATRIX distances_from_centroids);
//extern void memset_float(float* array, float val, int dim );
//extern void accumulate(MATRIX dest, MATRIX source, int dim);
extern void divide( MATRIX dividendo, float divisore, int dim);
int main(int argc, char** argv) {
//---------------------------Test Assembly---------------------------
VECTOR x = alloc_matrix(1, 37);
VECTOR y = alloc_matrix(1, 37);
for(int i=0; i<37; i++){
x[i] = rand()%20;
y[i] = rand()%20;
}
printf("Vettore X : \n");
print_matrix(1, 47, 1, x, 'p');
// printf("Vettore Y : \n");
// print_matrix(1, 47, 1, y, 'p');
/*
for( int i=1; i<47; i++){
printf("Distanza Assembly: %f\n", distance64(x, y, i) );
printf("Distanza C : %f\n\n", distance(x, y, i) );
if( distance64(x, y, i) != distance(x, y, i) ) printf("ERRORE\n");
}
*/
/* VECTOR res = residual(x, y, 37);
printf("Residual C : \n");
print_matrix(1, 37, 1, res, 'p');
VECTOR res2 = alloc_matrix(1, 37);
test_residual(res2, x, y, 37);
printf("Residual Assembly: \n");
print_matrix(1, 37, 1, res2, 'p');
MATRIX tmp = alloc_matrix(1,47);
memset(tmp, 0, 47*sizeof(float));
printf("TEMP AZZERATA:\n" );
print_matrix(1, 47, 1, tmp, 'p');
*/
printf("TEMP DIVIDE:\n" );
//accumulate(tmp, x, 37);
divide(x, 2, 37); //x = x/2
// memset_float64(tmp, 87.25, 47);
print_matrix(1, 37, 1, x, 'p');
// for (int i = 0; i < 37; i++)
// printf("%f\t", tmp[i]);
// printf("TEMP ACCUMULATA2:\n" );
// accumulate(tmp, y, 37);
// print_matrix(1, 37, 1, tmp, 'p');
/*
int n=10;
int m=37;
VECTOR distances_from_centroids = alloc_matrix(n, m);
for(int i=0; i<n; i++)
for( int j=0; j<m; i++)
distances_from_centroids[i*n+j] = rand()%20;
float obiettivo = objective_function(n,m, distances_from_centroids);
float obiettivoAss = test_objective(n,m, distances_from_centroids);
printf("Funzione obiettivo C : %lf\n", obiettivo );
printf("Funzione obiettivo Assembly: %lf\n\n", obiettivoAss );
*/
return 0;
}