Download scripts/utils/hypersphere.py from kalpesh77/Multiverse-field-coordinates: direct link, hf CLI and curl.
- Browser
- Download file 308 Bytes
-
https://huggingface.co/datasets/kalpesh77/Multiverse-field-coordinates/resolve/main/scripts/utils/hypersphere.py
- Command line
-
hf download hf://datasets/kalpesh77/Multiverse-field-coordinates/scripts/utils/hypersphere.py
-
curl -L -o hypersphere.py https://huggingface.co/datasets/kalpesh77/Multiverse-field-coordinates/resolve/main/scripts/utils/hypersphere.py
308 Bytes
| import numpy as np | |
| def point_on_hypersphere(n, theta): | |
| """Unit vector on n-sphere using angle theta in first two dimensions.""" | |
| v = np.zeros(n) | |
| v[0] = np.cos(theta) | |
| v[1] = np.sin(theta) | |
| return v | |
| def normalize(v): | |
| norm = np.linalg.norm(v) | |
| return v if norm < 1e-12 else v / norm | |