The stride is the number of elements(in this case floats) in one row (one horizontal line).
Let's simplify your example mainly we make your array smaller 5 by 5 elements: float a[5][5];.
How you thing the array it will look (in memory) ? something like :
I row | 00, 01, 02, 03, 04,
II row | 10, 11, 12, 13, 14,
III row | 20, 21, 22, 23, 24,
IV row | 30, 31, 32, 33, 34,
V row | 40, 41, 42, 43, 44
wrong, there are not such things like 2D, 3D ... nD organizations in memory, only
one dimensional layout of bytes (4 bytes for a float) from lower to higher addresses.
Our array it will be:
I row II row III row IV row V row
<----------------> <----------------> <----------------> <----------------> <---------------->
00, 01, 02, 03, 04, 10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 30, 31, 32, 33, 34, 40, 41, 42, 43, 44
better
I row II row III row IV row V row
<----------------> <----------------> <----------------> <----------------> <---------------->
00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 (25 elements)
// and because one float take 4 bytes
//
// I row II row
// <------------------------------------------------------------------------------------------------------> <--.......
// 00, 01, 02, 03, 04, 05, ...
// starting at address:
// a_pointer
// +
// offset:
// 0x00 0x04 0x08 0x0c 0x10 0x14 ...
// 0x00,0x01,0x02,0x03, 0x04,0x05,0x06,0x07, 0x08,0x09,0x0a,0x0b, 0x0c,0x0d,0x0e,0x0f, 0x10,0x11,0x12,0x13....
// -------------------|--------------------|--------------------|--------------------|-------------...
// float float float float float ...
So the short answer
the stride is <----------------> = 5 (50 in your original code) because you access your array with a float pointer.
Let's say you want to access the a[2][3] element (get or set)
stride = 5
<--------x------->
| 00, 01, 02, 03, 04,
| 10, 11, 12, 13, 14,
y 20, 21, 22, 23, 24,
| 30, 31, 32, 33, 34,
| 40, 41, 42, 43, 44
Remember the indexes in C starts from 0, and a_pointer point to a[0][0]. So you want a[y=2][x=3]
value = value at (a_pointer + (stride * y) + x)
= value at (a_pointer + (5 * 2) + 3)
= value at (a_pointer + 13 )
= *(a_pointer + 13 )
<----------------> <----------------> <----------------> <----------------> <---------------->
00, 01, 02, 03, 04, 10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 30, 31, 32, 33, 34, 40, 41, 42, 43, 44
-> -> -> -> -> -> -> -> -> -> -> -> ->
1 2 3 4 5 6 7 8 9 10 11 12 13
Laur