def inner_product_embedding(C, ndim): n = C.shape[0] if ndim > n: msg = 'Number of points: %s Dimensions: %s' % (n, ndim) raise ValueError(msg) eigvals = (n - ndim, n - 1) print n, eigvals S, V = eigh(C, eigvals=eigvals) assert S[0] <= S[1] # eigh returns in ascending order if np.any(S < 0): msg = 'The cosine matrix singular values are not all positive: \n' msg += formatm('S', S) msg += 'I assume it is rounding error and approximate with:\n' S[S < 0] = 0 msg += formatm('S\'', S) logger.warning(msg) assert V.shape == (n, ndim) assert S.shape == (ndim, ) # check_multiple([('K', ndim), # ('array[NxK]', V), # ('array[K]', S)]) coords = V.T for i in range(ndim): assert S[i] >= 0 coords[i, :] = coords[i, :] * np.sqrt(S[i]) return coords
def inner_product_embedding(C, ndim): n = C.shape[0] if ndim > n: msg = 'Number of points: %s Dimensions: %s' % (n, ndim) raise ValueError(msg) eigvals = (n - ndim, n - 1) print n, eigvals S, V = eigh(C, eigvals=eigvals) assert S[0] <= S[1] # eigh returns in ascending order if np.any(S < 0): msg = 'The cosine matrix singular values are not all positive: \n' msg += formatm('S', S) msg += 'I assume it is rounding error and approximate with:\n' S[S < 0] = 0 msg += formatm('S\'', S) logger.warning(msg) assert V.shape == (n, ndim) assert S.shape == (ndim,) # check_multiple([('K', ndim), # ('array[NxK]', V), # ('array[K]', S)]) coords = V.T for i in range(ndim): assert S[i] >= 0 coords[i, :] = coords[i, :] * np.sqrt(S[i]) return coords
def get_test_points(M, num_random=2): interesting = M.interesting_points() if isinstance(M, RandomManifold): for i in range(num_random): # @UnusedVariable interesting.append(M.sample_uniform()) if len(interesting) == 0: logger.warning('No test points for %s and not random.' % M) return interesting
def get_test_points(M, num_random=2): interesting = M.interesting_points() if isinstance(M, RandomManifold): for i in range(num_random): # @UnusedVariable interesting.append(M.sample_uniform()) if len(interesting) == 0: logger.warning("No test points for %s and not random." % M) return interesting