diff --git a/mpi_line/jacobi_mpi_line.c b/mpi_line/jacobi_mpi_line.c index 2a99683..6ca8f5f 100644 --- a/mpi_line/jacobi_mpi_line.c +++ b/mpi_line/jacobi_mpi_line.c @@ -159,7 +159,7 @@ double *compute_jacobi(int n, double init_value, double threshold, borders b, in if (rank == 0) { complete_x = create_sa_matrix(n + 2, n + 2); - memcpy(complete_x, x, (rows + 1) * (n + 2) * sizeof(double)); /* rows + 2 if rank == numprocs - 1 */ + memcpy(complete_x, x, (rows + ((rank == numprocs - 1) ? 2 : 1)) * (n + 2) * sizeof(double)); rows_to_transmit = n / numprocs; receive_pos = rows + 1; for (i = 1; i < numprocs; i++) {