Created
May 18, 2013 16:13
-
-
Save craigmbooth/5604946 to your computer and use it in GitHub Desktop.
Sparse matrix multiply in SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Join columns to rows, group by rows and columns, then filter to get the cell you want. | |
| SELECT A.row_num, B.col_num, SUM(A.value*B.value) | |
| FROM A,B | |
| WHERE A.col_num=B.row_num | |
| GROUP BY A.row_num, B.col_num; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment