Converts a vector-form distance vector to a square-form distance matrix, and vice-versa.
Parameters : | X : ndarray
|
---|---|
Returns : | Y : ndarray
force : str, optional
checks : bool, optional
|
Notes
v = squareform(X)
Given a square d-by-d symmetric distance matrix X, v=squareform(X) returns a d * (d-1) / 2 (or ${n choose 2}$) sized vector v.
v[{n choose 2}-{n-i choose 2} + (j-i-1)] is the distance between points i and j. If X is non-square or asymmetric, an error is returned.
X = squareform(v)
Given a d*d(-1)/2 sized v for some integer d>=2 encoding distances as described, X=squareform(v) returns a d by d distance matrix X. The X[i, j] and X[j, i] values are set to v[{n choose 2}-{n-i choose 2} + (j-u-1)] and all diagonal elements are zero.