I'm writing a program to calculate a value that is a measure of the similarity between two objects. The comparison is commutative, so compare(a, b) == compare(b, a)
.
The program's output to the console is a matrix of all results. However, since the matrix has each comparison twice ((a, b)
and (b, a)
), I'd like to save time by only calculating it once. What is the best way to cache these results?
Rough example of what the output looks like:
a b c
a 0 20 9001
b 20 0 333
c 9001 333 0