Skip to content

Instantly share code, notes, and snippets.

@ryanrhymes
Last active June 30, 2017 23:49
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 ryanrhymes/94ee2fb392062f64ee7794d09b052835 to your computer and use it in GitHub Desktop.
Save ryanrhymes/94ee2fb392062f64ee7794d09b052835 to your computer and use it in GitHub Desktop.
owl linalg
let x = Mat.uniform 4 4;;
let x = Mat.symmetric x;;
let v, w = Linalg.D.eig x;;
let w = Dense.Matrix.Z.re w;;
let v = Dense.Matrix.Z.re v;;
let v0 = Mat.col v 0;;
let a = Mat.(x *@ v0);;
let b = Mat.(v0 *$ w.{0,0});;
Mat.(a =~ b);;
let x = Mat.uniform 4 4;;
let v, w = Linalg.D.eig x;;
let k = 1;;
let vk = Dense.Matrix.Z.col v k;;
let x = Dense.Matrix.Z.complex x (Mat.zeros 4 4);;
let a = Dense.Matrix.Z.(x *@ vk);;
let b = Dense.Matrix.Z.(vk *$ w.{0,k});;
Mat.(a =~ b);;
let x = Mat.uniform 2000 2000;;
let f () = Linalg.D.eig x;;
Utils.time f;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment