I have one 2D matrix. My problem requires me to logically divide it into 4 sub-matrices. e.g if my original matrix is 4*4 then there are 4 sub-matrices of 2*2.
one starts at (0,0) other are (0,2), (2,0) and (2,2) index of original matrix.
I am accessing and setting values many times during program. I want to access the sub-matrix element by something like matrix[x][y].at(row,col) where x,y specify sub-matrix number and row,col denote element withing that sub-matrix at(row,col).
e.g
matrix[2][2].at[0][0] –> should give first element in 4th sub-matrix.
Any help is deeply appreciated.
Thanks in Advance
I’m not sure what the issue is here. Basically you just want a pseudo semantic api for addressing elements of a 2-d matrix. You note (presumed random) reads and writes to array. We’ll assume you are not dealing with threading issues.
A 2-dim array of type Foo, Foo[][], certainly can work. You just basically need to wrap it.