Created
November 26, 2011 17:54
-
-
Save Raynos/1396037 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double** relax(double** matrix, int dim, int threads, double precision) { | |
double** target; | |
double** source; | |
int bytes = dim * dim * sizeof(double); | |
/* copy matrix into source */ | |
source = (double**) malloc(bytes); | |
memcpy(source, matrix, bytes); | |
/* copy matrix into target */; | |
target = (double**) malloc(bytes); | |
memcpy(target, matrix, bytes); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(void) { | |
double** matrix; | |
double** result; | |
int size; | |
size = 8191; | |
matrix = make_matrix(size); | |
result = relax(matrix, size, 4, 0.01); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double** make_matrix(int size) { | |
double** matrix; | |
int i; | |
int j; | |
int bignum = 100; | |
matrix = calloc(size, sizeof(double)); | |
for (i = 0; i < size; i++) { | |
matrix[i] = calloc(size, sizeof(double)); | |
} | |
for (i = 0; i < size; i++) { | |
printf("making the matrix %i \n", i); | |
for (j = 0; j < size; j++) { | |
if (i == 0 || j == 0) { | |
matrix[i][j] = size; | |
} else if (i == size - 1 || j == size - 1) { | |
matrix[i][j] = 0; | |
} else { | |
matrix[i][j] = (rand() % (size * bignum)) / 100.0; | |
} | |
} | |
} | |
return matrix; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment