I have a 2d matrix created with the code:
for(i=0; i < size; i++)
{
for(j=0; j <size; j++)
{
a1[i][j] = i+1 + j+2;
}
}
I am trying to replicate that pattern in a matrix created by:
double*
a = malloc(sizeof(double)*randk*randk);
I can’t seem to figure out how to define that same pattern.
You mean creating the same numeric pattern? That’s just:
Or if you prefer a single loop: