how to effieciently calculate the sum of all differences in a group of matrices

37 Views Asked by At

For a computer graphics/machine learning problem I need to calculate the sum of all values of a group of gram matrices. Problems is that each of these gram matrices is rather large(I can only store about 3 of them in memory) and calculating one takes rather a lot of time.

In other words I would like to calculate

d=sumOfAllElement($\sum_{i}\sum_{j}(|A_i-A_j|$))

where A is a list of gram matrices (I hope that makes sense).

Now I know that if these were single values I can calculate the distance of each line segment and then figure out how often it has to be traversed (see https://stackoverflow.com/questions/32470046/calculating-sum-of-all-the-distance ) however I cannot really see myself doing that in this case as the these matrices are massive and figuring out how often each segment will be traversed does not seem like an easy matrix computation (cannot be executed on gpu) So does anybody know of a method that can calculate this that relies mostly on matrices manipulation? Do note that these are Gram matrices withh all properties associated with that.