Skip to content

Instantly share code, notes, and snippets.

@kvchen
Created December 5, 2016 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kvchen/b5488fa570a72c45665edb2051791f23 to your computer and use it in GitHub Desktop.
Save kvchen/b5488fa570a72c45665edb2051791f23 to your computer and use it in GitHub Desktop.
import ray
import matplotlib.pyplot as plt
import numpy as np
import ray.array.distributed as rd
# from scipy.linalg import lu
def main():
ray.init(start_ray_local=True, num_workers=10)
test = np.random.rand(100, 100)
# test = np.identity(400)
# p, l, u = lu(test)
pr, lr, ur = ray.get(rd.linalg.block_lu.remote(test, block_size=40))
# print(pr)
# print(lr)
# print(ur)
result = np.dot(pr, np.dot(lr, ur))
print("If this is above 1, something went terribly wrong. {}".format(result.max()))
residual = np.clip(result - test, 0, 10)
print(test)
print(result)
print(residual)
plt.imshow(residual, interpolation='nearest')
plt.colorbar()
plt.show()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment