Sum of sub-matrix of a matrix
Hallo:
I need some suggestions:
There is a M int square matrix of NxN, and i need to get the sum of ALL the submatrices, a submatrix is not less than 1x1.
For ex:
M = 1 2 3 4
-5 -6 8 1
9 10 2 8
-6 8 9 1
A first sum would be all the M matrix = 1 + 2 +... + 9 + 1
Another could be the submatrix [1 2 3] [-5 -6 8] = 1 + 2 + .. + (-6) + 8
Another could be [1 2 3 4], and another could be [1 -5 9 -6],
Also the middle matrix could be, for ex [-6 8] [10 2]
As you can see there are a lot of cases, i was trying to do some loops imitating the procedure of calculating a determinant of a Matrix, but there are many cases out.
So, if you could suggest me a way -efficient and short code way- to implement this i would be thankful.
Greetings
Gromlok
|