Skip to content

Instantly share code, notes, and snippets.

@andersx
Last active January 25, 2019 17:24
Show Gist options
  • Select an option

  • Save andersx/55dc3ac1fd6d81083b31bd6924aadf39 to your computer and use it in GitHub Desktop.

Select an option

Save andersx/55dc3ac1fd6d81083b31bd6924aadf39 to your computer and use it in GitHub Desktop.
Test SVD from QML
#!/usr/bin/env python3
from __future__ import print_function
import numpy as np
import qml
from qml.math import svd_solve
from time import time
from scipy.linalg import lstsq
print("Generating random matrix")
height = 10000
width = 2000
M = np.random.rand(height, width)
V = np.random.rand(height)
print(M.shape)
print(V.shape)
print("QML solver")
start = time()
alpha = svd_solve(M, V)
end = time()
print(end-start)
print("SciPy solver")
start = time()
alpha = lstsq(M, V, lapack_driver="gelsd")
end = time()
print(end-start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment