2

Given A is a large, sparse, 0-1 matrix, (not necessarily a square matrix). I want to calculate B = A*A^T, where A^T is the transpose of A. Note that although A is 0-1 matrix, B is not 0-1 matrix.

In addition, this question has the following special features:

  1. I don't need the elements on the diagonal of B, so it's okay to either delete them after calculation or ignore them when calculating.

  2. I only need to know the values of all non-zero elements in B (except for the elements on the diagonal), so it is OK if the program only gives a list which contains all non-zero elements. However, repeated elements cannot be merged: For example, if B[2,3] = B[2,4] = 1, then this list should contain two '1's instead of one.

  3. Since B must be a symmetric matrix, it is also possible to give only the upper or lower part of it.

I have tried using Eigen (http://eigen.tuxfamily.org/). But the functions of sparse matrix in Eigen are not specifically optimized for this problem, I hope to get some more efficient algorithms.

Any algorithm, open source library, or papers are welcome.

Related Questions: Which is the best way to multiply a large and sparse matrix with its transpose?

sparse sparse product A^T*A optim in Eigen lib

Ulrich Eckhardt
  • 16,572
  • 3
  • 28
  • 55
Takanashi
  • 129
  • 3
  • 1
    Maybe [cs.se] would be more suitable for general algorithm questions? – L. F. Jun 22 '19 at 01:52
  • I guess the answer heavily depends on the storage schemes of `A` and `B` and their sizes. The method of "Four Russians" can be of some help here. – Evg Jun 22 '19 at 06:50
  • CHOLMOD has a function for this, `cholmod_aat`. But it seems like this should be easy: it's a bunch of set-intersections between sparse sets, counting only the cardinality. – harold Jun 22 '19 at 07:30
  • How sparse is `A`? Density? – Damien Jun 22 '19 at 07:33
  • There's also a site on stackexchange.com that's dedicated to maths. Since you don't ask a programming question, assigning two conflicting (read the descriptions!) tags with C and C++ doesn't help either, I just removed them. As a new user here, please make sure you take the [tour] and read [ask]. – Ulrich Eckhardt Jun 22 '19 at 08:11

0 Answers0