This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import combinations | |
stations = [ | |
"a", "b", "c", "d", "e", | |
"f", "g", "h", "i", "j", | |
"k", "l", "m", "n" | |
] | |
line1 = ["a", "b", "f", "d", "e"] | |
line2 = ["c", "e", "j", "g", "i"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
N = 5 | |
v = np.random.random((N, 3)) | |
v = v / np.linalg.norm(v, axis=1)[:, None] | |
r = np.random.randn(N, 3) | |
r = r / np.linalg.norm(r, axis=1)[:, None] | |
angle = np.arccos(np.einsum('ij,ij->i', v, r)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import numpy as np | |
from time import time | |
a = np.random.random((10000, 3)) | |
b = np.random.random((10000, 3)) | |
t0 = time() | |
c = np.array([np.cross(x, y) for x, y in zip(a, b)]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Different functions to get pairwise distance in cubic box with PBC | |
Args: | |
positions: the positions of particles, shape (N, dim) | |
box (int or float): the size of the box | |
Return: | |
np.ndarray: the pair-wise distances, shape (N, N) | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
n_sample = 8 | |
x = np.linspace(0, 10, n_sample) | |
par = [1e-4, 2e-3, -3e-2, -2e-1, 1] | |
order = len(par) - 1 | |
# the shape of x_poly is (order + 1, n_sample) | |
x_poly = x[None, :] ** np.arange(order + 1)[:, None] | |
y = np.polyval(par, x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 | |
H 16.658345122844334 5.438348200947194 15.278503165303777 | |
H 11.904690376717243 5.1529666697956795 13.25948396116124 | |
H 9.62667890619329 7.438653597799468 5.290790255780805 | |
H 6.017600501383954 7.235017543794983 12.626298470129054 | |
H 9.33671886855014 10.014970018631432 4.270413237226138 | |
H 2.168893723778388 0.9019879254927321 7.552264051940874 | |
H 10.211873888717818 10.346039720521441 13.019842912794617 | |
H 7.797419763761877 17.778647693825153 15.882609513949191 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_longest_token(search_buffer, look_ahead_buffer, offset): | |
""" | |
Get the longest duplicated token in both search buffer and look ahead buffer | |
given a constant offset value | |
Args: | |
search_buffer (list): the search buffer | |
look_ahead_buffer (list): the look ahead buffer | |
offset (int): the offset, starting from tail of the search buffer |