compute a cube of covariance and a cube of distance between the items (rows) of a matrix of measurements comprising KKK different blocks of possibly different number of variables.
Useful links