Search code examples
apache-sparkbreeze

What's the difference between Breeze and BLAS when doing dot product of two vectors


Both Breeze and BlAS provides API to calculate dot product of two vectors

For BLAS, it is:

BLAS.ddot(int n, double[] dx, int incx, double[] dy, int incy);

For Breeze, it is: DenseVector.dot

I would ask what't the difference between them? Which one should I choose to use? I ask so because when I read the Spark MLLib code, it looks that spark chooses BLAS to do vector calculation.


Solution

  • Generally, a BLAS library makes use of lower level functionalities of your machines, which can be highly optimized, depending on your configuration. Breeze, on the other hand, is built as a general optimizer for linear algebra operations on Scala.

    As both have different implementations (one big thing of Breeze is to utilize vector-only representations), you should use whatever is more fitting to your usecase.