Emulating Matlab’s meshgrid in CUDA

On our GitHub webpage, we are posting a worked example implementing in CUDA the classical Matlab’s meshgrid function.
In Matlab:

x = [1 2 3];
y = [4 5 6 7];
[X, Y] = meshgrid(x, y);

produces:

X =

1     2     3
1     2     3
1     2     3
1     2     3

and

Y =

4     4     4
5     5     5
6     6     6
7     7     7

X is exactly the four-fold replication of the x array, while Y is the three-fold consecutive replication of each element of the y array.

Leave a Reply

Your email address will not be published. Required fields are marked *