raise ValueError("If supplied, axis must be in (0, 1)")
if density is None:
density = 1.0 / 3
Omega = _sketches.sparse_random_map(A, l, axis, density, random_state)
// project A onto Omega
if axis == 0:
return safe_sparse_dot(Omega.T, A)
return safe_sparse_dot(A, Omega)
def fast_johnson_lindenstrauss(A, l, axis=1, random_state=None):
After Change
raise ValueError("If supplied, axis must be in (0, 1)")
if density is None:
density = A.shape[0] / log(A.shape[0])
// construct sparse sketch
Omega = _sketches.sparse_random_map(A, l, axis, density, random_state)
// project A onto Omega
if axis == 0:
Q = safe_sparse_dot(Omega.T, A)
else:
Q = safe_sparse_dot(A, Omega)
if n_subspace is not None:
Q = perform_subspace_iterations(A, Q, n_iter=n_subspace, axis=axis)
return Q
def fast_johnson_lindenstrauss(A, l, axis=1, random_state=None):