For a set of observations:
[a1,a2,a3,a4,a5]
their pairwise distances
d=[[0,a12,a13,a14,a15]
[a21,0,a23,a24,a25]
[a31,
This is in addition to the answer provided by phynfo and your comment. It does not feel like a clean design to me to infer the dimension of the matrix from the length of the compressed matrix. That said, here is how you can compute it:
from math import sqrt, ceil
for i in range(1,10):
thelen = (i * (i+1)) / 2
thedim = sqrt(2*thelen + ceil(sqrt(2*thelen)))
print "compressed array of length %d has dimension %d" % (thelen, thedim)
The argument to the outer square root should always be a square integer, but sqrt returns a floating point number, so some care is needed when using this.