Consider a matrix
M1 giving values for all combinations
x,y. Consider a partition
f(x)->X and a partition
g(y)->Y. Furthermore consider an operation
p(A) on a set
A of numbers, i.e.
f,g can be used to create from
M1 a block matrix
M2 where all
x that are mapped to the same
X are adjacent, and the same for all
M2 has a block for each combination of the 'sets'
Now I would like to condense this matrix
M2 into another matrix
M3 by applying
p on each block separately.
M3 has one value for each combination of
Ideally, I would like to skip the transformation of
g on the fly.
What would be the most efficient way to perform such operation and would it be possible to deploy
scipy for it?
Special case: Actually, in my case
y are identical and there is only one function
f applied to both of them. I only care about the part of
M2 that is under the diagonal.