for ( int i = 0; i < row * col; ++ i )
{
one2two ( i, col, xy );
*(tranData + transpositionTwo2one (xy, row)) = *(matrixData + i);
}
}
void show (double *matrix)
{
double *data =(double*) ((int*) matrix + 2);
int row = *((int*) matrix);
int col = *((int*) matrix + 1);
printf ("%d %d matrix \n", row, col);
for (int i = 0; i < row; ++i)
{
for (int j = 0; j < col; ++j)
{
printf("%lf ",*(data + i * col + j));
}
printf("\n");
}
}
void testRead (char *fileName, int *sizes)
{
int err;
MPI_File file;
MPI_Status status;
MPI_File_open (MPI_COMM_WORLD, fileName, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &file);
MPI_File_set_view (file, 0, MPI_INT, MPI_INT, "native", MPI_INFO_NULL);
if(0 == rank)
printf("e %d %d %d \n", err, sizes[0], sizes[1] );
err = MPI_File_read (file, sizes, 2, MPI_INT, &status);
if(0 == rank)
printf("ee %d %d %d \n", err, sizes[0], sizes[1] );
MPI_File_close (&file);
}
int main (int argc, char* argv[])
{
MPI_Init (&argc, &argv);
MPI_Comm_rank (MPI_COMM_WORLD, &rank);
MPI_Comm_size (MPI_COMM_WORLD, &size);
int sizes[2];
readSize (argv[1], sizes);
double *matrix = (double*) malloc(sizes[0] * sizes[1] * sizeof(double) + 2 *sizeof(int));
double *transp = (double*) malloc(sizes[0] * sizes[1] * sizeof(double) + 2 *sizeof(int));
readMatrixByColumn (argv[1], sizes[0], sizes[1], matrix);
transposite(matrix ,transp);
if (2 == rank)
{
printf ("matrix\n");
show (matrix);
printf ("transposition \n");
show (transp);
}
MPI_Finalize ();
free (matrix);
return 0;
}