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 perfplot | |
import numpy as np | |
rng = np.random.default_rng(0) | |
def setup(n): | |
return [rng.random(n) for _ in range(10)] | |
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 perfplot | |
import numpy as np | |
def householder(A): | |
m, n = A.shape | |
R = A.copy() | |
Q = np.identity(m) | |
for j in range(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 | |
import perfplot | |
rng = np.random.default_rng(1) | |
def setup(n): | |
U = rng.random((n, 10)) | |
return U, np.ascontiguousarray(U.T) |
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 perfplot | |
import numpy as np | |
def inv(AX): | |
A, X = AX | |
Ainv = np.linalg.inv(A) | |
return Ainv @ X @ Ainv.T | |
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 math import sqrt | |
fibonacci = [1, 1] | |
phi = (sqrt(5) - 1) / 2 | |
print(phi) | |
print() | |
errors = [] |
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 random | |
import perfplot | |
lst = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"] | |
string = "abcdefghijkl" | |
def list_lookup(data): | |
return [lst[n] for n in data] |
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 perfplot | |
import numpy as np | |
threshold = 0.5 | |
# threshold = 1.0e-3 | |
def div_where(data): | |
a, b = data | |
return a / np.where(b > threshold, b, 1.0) |
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 numpy import pi, cos, sin | |
def f(z, s_z, c_z): | |
return (0.5 - s_z) * cos(pi / 2 * z ** 2) - (0.5 - c_z) * sin(pi / 2 * z ** 2) | |
def f_asymp(z): | |
zp2 = (pi * z ** 2) ** 2 | |
r = 1.0 |
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 perfplot | |
import numpy as np | |
import npx | |
A = np.array([[0.0, 1.0, 0.0], [125 / 29, -125 / 29, 0.0], [0.0, 50 / 29, -50 / 29]]) | |
def manual(data): | |
fx, fy, fz = data |
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 perfplot | |
def mult(x): | |
return x * (1.0 / np.pi) | |
def div(x): | |
return x / np.pi |