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 | |
from scipy.linalg.blas import ddot | |
def np_dot(data): | |
x, y = data | |
return np.dot(x, y) | |
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 | |
from scipy.linalg.blas import daxpy | |
a = 1.3 | |
def np_axpy(data): | |
x, y = data | |
return a * x + y |
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 div(ab): | |
a, b = ab | |
return a / b | |
def mul(ab): |
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 math | |
import numpy as np | |
import perfplot | |
import random | |
def plain_loop(n): | |
inside = 0 | |
random.seed() | |
for _ 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 perfplot | |
import numpy as np | |
from scipy.sparse import spdiags | |
def setup_dense(n): | |
A = np.random.rand(n, n) + 1j * np.random.rand(n, n) | |
AH = A.T.conj() | |
x = np.random.rand(n) + 1j * np.random.rand(n) | |
return A, AH, 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
import numpy as np | |
import perfplot | |
def dot(xy): | |
x, y = xy | |
return np.dot(x, y) | |
def einsum(xy): |
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 scipy.optimize | |
np.random.seed(0) | |
V_orig = np.random.rand(50, 3) | |
def func(x): | |
Vx = V_orig @ x | |
return np.dot(Vx, Vx) |
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 dot(a, b): | |
a_shape = a.shape | |
b_shape = b.shape | |
b = b.reshape(b.shape[0], -1) | |
return np.dot(a, b).reshape(a_shape[:-1] + b_shape[1:]) |
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 | |
import perfplot | |
def setup(n): | |
pts = numpy.random.rand(3, n, 2) | |
e = numpy.array([ | |
pts[2] - pts[1], | |
pts[0] - pts[2], | |
pts[1] - pts[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 | |
def setup(n): | |
a = numpy.random.rand(n, 3) | |
b = numpy.ascontiguousarray(a.T) | |
return a, b | |