I need to write a program that computes values in a matrix, first sequentially, then in parallel using openCL.
It is the same thing as I already did in regular C (using MPI)
I want to make simple functions to initializeMatrix and printMatrix and the likes.
In C i used to do this very simply :
// Matrix initialization
void initMatrix(size_t M, size_t N, double (*matrix)[M][N][2])
{
int i, j;
for (j = 0; j < N; ++j)
{
for (i = 0; i < M; ++i)
{
(*matrix)[i][j][0] = (double)(( i * ( M - i - 1 ) ) * ( j * ( N - j - 1 ) ));
(*matrix)[i][j][1] = (*matrix)[i][j][0];
}
}
printf("Matrix has been initialized\n");
}
I saw this gets me errors in C++, as the compiler wants to know at COMPILE TIME the sizes of arrays (the M and N sizes are passed as arguments to program, therefore I can't know at compile time).
How do I do this in C++?
I am considering using Vectors, but I'm not sure if it's a good idea since I will have to use the OpenCL library