mpi line with matrix exchange
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* Create a matrix stored in a single array.
|
||||
*/
|
||||
double *create_sa_matrix(int rows, int cols) {
|
||||
double *x;
|
||||
|
||||
@@ -11,21 +8,26 @@ double *create_sa_matrix(int rows, int cols) {
|
||||
return x;
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroy a single array matrix.
|
||||
*/
|
||||
void destroy_sa_matrix(double *x) {
|
||||
free(x);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the index for the single array matrix
|
||||
* that correspond to the given row and column.
|
||||
*/
|
||||
int sa_index(int cols, int r, int c) {
|
||||
return r * cols + c;
|
||||
}
|
||||
|
||||
|
||||
void print_sa_matrix(double *x, int rows, int cols) {
|
||||
int i, j;
|
||||
for (i = 0; i < rows; i++) {
|
||||
for (j = 0; j < cols; j++) {
|
||||
printf("%f\t", x[sa_index(cols, i, j)]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
double **create_matrix(int rows, int cols) {
|
||||
int i;
|
||||
double **x;
|
||||
|
||||
@@ -17,11 +17,27 @@ typedef struct borders {
|
||||
} borders;
|
||||
|
||||
|
||||
/*
|
||||
* Create a matrix stored in a single array.
|
||||
*/
|
||||
double *create_sa_matrix(int rows, int cols);
|
||||
|
||||
/*
|
||||
* Destroy a single array matrix.
|
||||
*/
|
||||
void destroy_sa_matrix(double *x);
|
||||
|
||||
/*
|
||||
* Get the index for the single array matrix
|
||||
* that correspond to the given row and column.
|
||||
*/
|
||||
int sa_index(int cols, int r, int c);
|
||||
|
||||
/*
|
||||
* Print a single array matrix.
|
||||
*/
|
||||
void print_sa_matrix(double *x, int rows, int cols);
|
||||
|
||||
double **create_matrix(int rows, int cols);
|
||||
void destroy_matrix(double **x, int rows);
|
||||
|
||||
void print_matrix(double **x, int rows, int cols);
|
||||
|
||||
Reference in New Issue
Block a user