{"action":"created","issue":{"url":"https://api.github.com/repos/fommil/netlib-java/issues/82","labels_url":"https://api.github.com/repos/fommil/netlib-java/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/fommil/netlib-java/issues/82/comments","events_url":"https://api.github.com/repos/fommil/netlib-java/issues/82/events","html_url":"https://github.com/fommil/netlib-java/issues/82","id":68928448,"number":82,"title":"Nondeterministic behaviour of SVD for some blas implementations","user":{"login":"marcelluethi","id":1332115,"avatar_url":"https://avatars.githubusercontent.com/u/1332115?v=3","gravatar_id":"","url":"https://api.github.com/users/marcelluethi","html_url":"https://github.com/marcelluethi","followers_url":"https://api.github.com/users/marcelluethi/followers","following_url":"https://api.github.com/users/marcelluethi/following{/other_user}","gists_url":"https://api.github.com/users/marcelluethi/gists{/gist_id}","starred_url":"https://api.github.com/users/marcelluethi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcelluethi/subscriptions","organizations_url":"https://api.github.com/users/marcelluethi/orgs","repos_url":"https://api.github.com/users/marcelluethi/repos","events_url":"https://api.github.com/users/marcelluethi/events{/privacy}","received_events_url":"https://api.github.com/users/marcelluethi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-04-16T13:50:11Z","updated_at":"2015-04-17T06:41:20Z","closed_at":null,"body":"Hi, \r\n\r\nI hope this is the right place to report issues (I haven't found a mailing list). \r\n\r\nWe are experiencing non-deterministic behaviour when doing an SVD with breeze.\r\nCalling SVD several times with the same matrix results in (sometimes drastically) different results (see the test code below). \r\nWe know, however, that it is related to the the underlying blas library that is used, as we experience the problem only when we use:\r\n\r\n* the native libraries bundled with netlib-java\r\n* atlas on Ubuntu 14.04\r\n\r\nThe problem does not occur if we use\r\n* F2jBLAS\r\n* Use Openblas\r\n\r\nHere is the code to reproduce it:\r\n```scala\r\nimport breeze.linalg.DenseMatrix\r\nimport breeze.linalg.svd.SVD\r\n\r\nobject Test {\r\n\r\n  def main(args : Array[String]) : Unit = {\r\n   // System.setProperty(\"com.github.fommil.netlib.BLAS\", \"com.github.fommil.netlib.F2jBLAS\")\r\n   // System.setProperty(\"com.github.fommil.netlib.LAPACK\", \"com.github.fommil.netlib.F2jLAPACK\")\r\n   // System.setProperty(\"com.github.fommil.netlib.ARPACK\", \"com.github.fommil.netlib.F2jARPACK\")\r\n\r\n\r\n    val n = 1000\r\n    val K = DenseMatrix.zeros[Float](n, n)\r\n    val xs = (0 until 1000 by 10)\r\n    for ((x, i) <- xs.zipWithIndex;\r\n         (y, j) <- xs.zipWithIndex)\r\n    {\r\n      K(i,j) = Math.exp(- Math.pow(x-y, 2) / 1000).toFloat\r\n    }\r\n    K +=  DenseMatrix.eye[Float](n) * 1e-6f\r\n\r\n    for (i <- (0 until 100)) {\r\n      val SVD(u,d,v)= breeze.linalg.svd(K)\r\n      println(s\"u ${u.sum} d ${d.min} v ${v.sum} \")\r\n    }\r\n  }\r\n}\r\n\r\n```\r\n\r\nAnd this is the output it produces:\r\n\r\n```\r\n...\r\nu 916.70703 d 7.860268E-7 v 916.7068 \r\nu 918.3815 d 6.009904E-7 v 918.38116 \r\nu 916.70703 d 7.860268E-7 v 916.7069 \r\n...\r\n```\r\n\r\nWhile this example uses float arrays, similar problems also occur when using double precision. \r\nDo you have any idea what could be the problem?\r\n\r\nThanks, \r\n\r\nMarcel\r\n"},"comment":{"url":"https://api.github.com/repos/fommil/netlib-java/issues/comments/93912574","html_url":"https://github.com/fommil/netlib-java/issues/82#issuecomment-93912574","issue_url":"https://api.github.com/repos/fommil/netlib-java/issues/82","id":93912574,"user":{"login":"marcelluethi","id":1332115,"avatar_url":"https://avatars.githubusercontent.com/u/1332115?v=3","gravatar_id":"","url":"https://api.github.com/users/marcelluethi","html_url":"https://github.com/marcelluethi","followers_url":"https://api.github.com/users/marcelluethi/followers","following_url":"https://api.github.com/users/marcelluethi/following{/other_user}","gists_url":"https://api.github.com/users/marcelluethi/gists{/gist_id}","starred_url":"https://api.github.com/users/marcelluethi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcelluethi/subscriptions","organizations_url":"https://api.github.com/users/marcelluethi/orgs","repos_url":"https://api.github.com/users/marcelluethi/repos","events_url":"https://api.github.com/users/marcelluethi/events{/privacy}","received_events_url":"https://api.github.com/users/marcelluethi/received_events","type":"User","site_admin":false},"created_at":"2015-04-17T06:41:20Z","updated_at":"2015-04-17T06:41:20Z","body":"Unfortunately, I will personally not find time to dig deep into the problem within the next weeks, but can follow it up a bit later if needed (from early June things should look better, time-wise). \r\n\r\nNeither accuracy nor speed is a big issue for us at the moment, but the behaviour should be deterministic. The code is part of an evaluation metric that assesses the quality of a statistical model, and we realized that different runs for the same model resulted in very different metric values. \r\nFor the moment we will therefore use F2jblas to guarantee that we get consistent results. \r\n\r\nBTW, thanks a lot for providing these libraries. So far they worked very well for us. \r\n\r\n"}}