Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created November 26, 2011 17:54
Show Gist options
  • Save Raynos/1396037 to your computer and use it in GitHub Desktop.
Save Raynos/1396037 to your computer and use it in GitHub Desktop.
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);
}
int main(void) {
double** matrix;
double** result;
int size;
size = 8191;
matrix = make_matrix(size);
result = relax(matrix, size, 4, 0.01);
}
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