I am performing comparisons to generate a similarity matrix. The comparisons in the upper triangle matrix are the inverse of the ones in the lower triangle matrix but they result in the same value. My actual code is much more complicated than that shown below but the example code below demonstrates the point.
inmatrix = {{1}, {2}, {3}, {4}};
multifunc = Function[x, Abs[Part[x, 1] - Part[x, 2]]];
comparisons = Tuples[inmatrix, 2];
outmatrix = Map[multifunc, comparisons]
outmatrix2 = Partition[outmatrix, 4]
MatrixForm[outmatrix2]
There is no need to calculate both the lower and upper triangle matrix because the values are redundant. Is there a simple way to calculate only the upper or lower triangle matrix?