Optimizing sparse dot-product in C#
- by Haggai
Hello.
I'm trying to calculate the dot-product of two very sparse associative arrays.
The arrays contain an ID and a value, so the calculation should be done only on those IDs that are common to both arrays, e.g. <(1, 0.5), (3, 0.7), (12, 1.3) * <(2, 0.4), (3, 2.3), (12, 4.7) = 0.7*2.3 + 1.3*4.7 .
My implementation (call it dict) currently…