Skip to content
This repository was archived by the owner on Nov 10, 2017. It is now read-only.
This repository was archived by the owner on Nov 10, 2017. It is now read-only.

Nondeterministic behaviour of SVD for some blas implementations #82

@marcelluethi

Description

@marcelluethi

Hi,

I hope this is the right place to report issues (I haven't found a mailing list).

We are experiencing non-deterministic behaviour when doing an SVD with breeze.
Calling SVD several times with the same matrix results in (sometimes drastically) different results (see the test code below).
We know, however, that it is related to the the underlying blas library that is used, as we experience the problem only when we use:

  • the native libraries bundled with netlib-java
  • atlas on Ubuntu 14.04

The problem does not occur if we use

  • F2jBLAS
  • Use Openblas

Here is the code to reproduce it:

import breeze.linalg.DenseMatrix
import breeze.linalg.svd.SVD

object Test {

  def main(args : Array[String]) : Unit = {
   // System.setProperty("com.github.fommil.netlib.BLAS", "com.github.fommil.netlib.F2jBLAS")
   // System.setProperty("com.github.fommil.netlib.LAPACK", "com.github.fommil.netlib.F2jLAPACK")
   // System.setProperty("com.github.fommil.netlib.ARPACK", "com.github.fommil.netlib.F2jARPACK")


    val n = 1000
    val K = DenseMatrix.zeros[Float](n, n)
    val xs = (0 until 1000 by 10)
    for ((x, i) <- xs.zipWithIndex;
         (y, j) <- xs.zipWithIndex)
    {
      K(i,j) = Math.exp(- Math.pow(x-y, 2) / 1000).toFloat
    }
    K +=  DenseMatrix.eye[Float](n) * 1e-6f

    for (i <- (0 until 100)) {
      val SVD(u,d,v)= breeze.linalg.svd(K)
      println(s"u ${u.sum} d ${d.min} v ${v.sum} ")
    }
  }
}

And this is the output it produces:

...
u 916.70703 d 7.860268E-7 v 916.7068 
u 918.3815 d 6.009904E-7 v 918.38116 
u 916.70703 d 7.860268E-7 v 916.7069 
...

While this example uses float arrays, similar problems also occur when using double precision.
Do you have any idea what could be the problem?

Thanks,

Marcel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions