This file contains 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 math import tau | |
import matplotlib.pyplot as plt | |
n_max = 20 | |
sphere_vols = [2, tau] | |
for n in range(3, n_max + 1): | |
sphere_vols.append(sphere_vols[n-2] * tau / (n-2)) | |
plt.plot(range(1, n_max + 1), sphere_vols, "o") |
This file contains 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 sys import version_info | |
import matplotlib.pyplot as plt | |
import perfplot | |
import pickle | |
import netCDF4 | |
import numpy as np | |
import h5py | |
import tables |
This file contains 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 sys import version_info | |
import matplotlib.pyplot as plt | |
import perfplot | |
import pickle | |
import netCDF4 | |
import numpy as np | |
import h5py | |
import tables |
This file contains 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 | |
def agm(an, bn): | |
while np.any(abs(an - bn) > 1.0e-15): | |
an, bn = (an + bn) / 2, np.sqrt(an * bn) | |
return an | |
x = np.linspace(0, 4, 401) |
This file contains 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 perfplot | |
import numpy as np | |
def setup(n): | |
return np.random.randint(0, 100, (n, 4)) | |
def loop(data): | |
with open("f.txt", "w") as f: |
This file contains 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
# https://gist.github.com/fredrik-johansson/4098b7aea7e0321ac50bb533a03515d0 | |
import cplot | |
import matplotlib.pyplot as plt | |
import mpmath | |
import numpy as np | |
from mpmath import fp | |
def _wrap(fun): |
This file contains 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 cplot | |
import numpy as np | |
def lambert_series(z, n=100): | |
zn = z.copy() | |
s = np.zeros_like(z) | |
for _ in range(n): | |
s += zn / (1 - zn) | |
zn *= z |
This file contains 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 matplotx | |
import matplotlib.pyplot as plt | |
import numpy as np | |
class Rastrigin: | |
def __init__(self): | |
self.roots = np.array([[0, 0]]) | |
def f(self, x): |
This file contains 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 meshzoo | |
import meshio | |
def ackley(x): | |
xx = np.einsum("i...,i...->...", x, x) | |
sumcos = np.sum(np.cos(2 * np.pi * x), axis=0) | |
return ( | |
-20.0 * np.exp(-0.2 * np.sqrt(0.5 * xx)) |
This file contains 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 perfplot | |
def setup(n): | |
x = np.random.rand(n, k) | |
y = np.random.rand(n, k) | |
xt = np.ascontiguousarray(x.T) | |
yt = np.ascontiguousarray(y.T) | |
return x, y, xt, yt |
NewerOlder