diff --git a/qutip_benchmark/benchmarks/bench_linear_algebra.py b/qutip_benchmark/benchmarks/bench_linear_algebra.py index 01b10a798..c9c5a2029 100644 --- a/qutip_benchmark/benchmarks/bench_linear_algebra.py +++ b/qutip_benchmark/benchmarks/bench_linear_algebra.py @@ -1,4 +1,5 @@ """This file contains the benchmarks that are run the benchmark.py script.""" + import pytest import qutip import scipy @@ -19,13 +20,18 @@ def size(request): return request.param +@pytest.fixture(params=["dense", "sparse", "tridiag"]) +def density_oper(request): + return request.param + + @pytest.fixture(params=["dense", "sparse"]) -def density(request): +def density_ket(request): return request.param @pytest.fixture() -def left_oper(size, density, dtype): +def left_oper(size, density_oper, dtype): """Return a random matrix of size `sizexsize'. Density is either 'dense' or 'sparse' and returns a fully dense or a sparse matrix respectively. The matrices are Hermitian.""" @@ -34,6 +40,9 @@ def left_oper(size, density, dtype): res = qutip.rand_herm(size, density=1 / size) elif density == "dense": res = qutip.rand_herm(size, density=1) + elif density == "tridiag": + a = qutip.destroy(size) + res = a + a.dag() + a * a.dag() if dtype == "numpy": return res.full() @@ -49,7 +58,7 @@ def left_oper(size, density, dtype): @pytest.fixture() -def right_oper(size, density, dtype): +def right_oper(size, density_oper, dtype): """Return a random matrix of size `sizexsize'. Density is either 'dense' or 'sparse' and returns a fully dense or a sparse matrix respectively. The matrices are Hermitian.""" @@ -58,6 +67,9 @@ def right_oper(size, density, dtype): res = qutip.rand_herm(size, density=1 / size) elif density == "dense": res = qutip.rand_herm(size, density=1) + elif density == "tridiag": + a = qutip.destroy(size) + res = a + a.dag() + a * a.dag() if dtype == "numpy": return res.full() @@ -73,7 +85,7 @@ def right_oper(size, density, dtype): @pytest.fixture() -def right_ket(size, density, dtype): +def right_ket(size, density_ket, dtype): if density == "sparse": res = qutip.rand_ket(size, density=0.3) else: diff --git a/qutip_benchmark/benchmarks/bench_qobjevo.py b/qutip_benchmark/benchmarks/bench_qobjevo.py index 261ba3d52..884a71a4c 100644 --- a/qutip_benchmark/benchmarks/bench_qobjevo.py +++ b/qutip_benchmark/benchmarks/bench_qobjevo.py @@ -1,4 +1,5 @@ """This file contains the benchmarks that are run the benchmark.py script.""" + import pytest import qutip import numpy as np @@ -9,7 +10,7 @@ def size(request): return request.param -@pytest.fixture(params=["dense", "sparse"]) +@pytest.fixture(params=["dense", "sparse", "tridiag"]) def density(request): return request.param @@ -35,6 +36,10 @@ def left_QobjEvo(size, density, coeftype): elif density == "dense": q_obj = qutip.rand_herm(size, density=1) + elif density == "tridiag": + a = qutip.destroy(size) + q_obj = a + a.dag() + a * a.dag() + # Creating coefficients tlist = None if coeftype == "function":