From 14c47f39447523a7faa5a400ca39d530082251d5 Mon Sep 17 00:00:00 2001 From: mtzikara Date: Fri, 14 Sep 2018 00:36:36 +0200 Subject: [PATCH] Add files via upload --- filterMARP.c | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 filterMARP.c diff --git a/filterMARP.c b/filterMARP.c new file mode 100644 index 0000000..60ee05a --- /dev/null +++ b/filterMARP.c @@ -0,0 +1,216 @@ + + + +//ALGORITHM 6 +//p_1 is period 1, p_2 is period 2 in no. of iterations +float** filterMARP(int** A, float* x, float e, int max_iterations, float a, int p_1, int p_2, int size){ + + float* x_new, x_c, y; + int count = 0; + float norm = 1.0; + int* N, C, N_new, C_new; + int** Ann, Acn; + int i; + /*********** ...malloc... *************/ + x_new = malloc(size*sizeof(float)); + + x_c = malloc(size*sizeof(float)); + y = malloc(size*sizeof(float)); + N = malloc(size*sizeof(int)); + C = malloc(size*sizeof(int)); + N_new = malloc(size*sizeof(int)); + C_new = malloc(size*sizeof(int)); + Ann = malloc(size*sizeof(int *)); + for(i=0; i +#include + + +void main(){ + printf("Hello I am maria \n"); + + //Read from file of adjacency matrix + FILE *adjm; + + int x; + adjm = fopen("adj_matrix.txt", "r+"); + if(!adjm){ + printf("Error opening file \n"); + exit(0); + } + + //Read dimensions of file (square) + int m, count=0; + while((m=fgetc(adjm))) { + // break if end of file + if(m == EOF) break; + // otherwise add one to the count of that particular character + if(m=='\n'){ + count+=1; + } + } + printf("Line count of matrix is %d \n", count); + int d = count; + int i,j; + + // Put values in matrix A + int** A = malloc(d*sizeof(int *)); + for( i=0; i