there is no standard to wire a matrix, so just the matrix builder knows how the thing would be a function for the calculation of the adress like:
#define ROWS XX
#define COLUMS YY
int GetAdress(int row, int colum)
{
if((row<ROWS)&&(rows>=0)
{
if((colum<COLUMS)&&(colum>=0)
{
return (colum+COLUMS*(row-1));
}
}
return -1; //if wrong insert -> ERROR Code
}
Edit:
the circuit/adresses would be:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7|
----------------------------------------
| 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
...