-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheigen.c
More file actions
executable file
·41 lines (26 loc) · 866 Bytes
/
eigen.c
File metadata and controls
executable file
·41 lines (26 loc) · 866 Bytes
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
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <time.h>
#include "MatrixAndVectorOps.h"
/* the function return 1 if the difference between each corresponding pair of values is less then Epsilon */
int hasEpsilonDifference(double* vector, double* oldVector, int length){
int i;
double EPSILON = 0.00001;
for(i =0 ; i < length ; i++){
if(EPSILON <= fabs(vector[i]-oldVector[i])){
return 0;
}
}
return 1;
}
int iterate(double** matrix, double* vector, double* newVector, int length){
multiplyMatrixAndVector(matrix,vector,newVector,length);
normalizeVector(length,newVector);
/*printVector(length,newVector);*/
multiplyMatrixAndVector(matrix,newVector,vector,length);
normalizeVector(length,vector);
/*printVector(length,vector);*/
return EXIT_SUCCESS;
}