Package org.jblas

Class JavaBlas


  • public class JavaBlas
    extends java.lang.Object

    Implementation of some Blas functions, mostly those which require linear runtime in the number of matrix elements. Because of the copying overhead when passing primitive arrays to native code, it doesn't make sense for these functions to be implemented in native code. The Java code is about as fast.

    The same conventions were used as in the native code, that is, for each array you also pass an index pointing to the starting index.

    These methods are mostly optimized for the case where the starting index is 0 and the increment is 1.

    • Constructor Summary

      Constructors 
      Constructor Description
      JavaBlas()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void raxpy​(int n, double da, double[] dx, int dxIdx, int incx, double[] dy, int dyIdx, int incy)
      Compute dy <- da * dx + dy.
      static void raxpy​(int n, float da, float[] dx, int dxIdx, int incx, float[] dy, int dyIdx, int incy)
      Compute dy <- da * dx + dy.
      static void rcopy​(int n, double[] dx, int dxIdx, int incx, double[] dy, int dyIdx, int incy)
      Copy dx to dy.
      static void rcopy​(int n, float[] dx, int dxIdx, int incx, float[] dy, int dyIdx, int incy)
      Copy dx to dy.
      static double rdot​(int n, double[] dx, int dxIdx, int incx, double[] dy, int dyIdx, int incy)
      Compute scalar product between dx and dy.
      static float rdot​(int n, float[] dx, int dxIdx, int incx, float[] dy, int dyIdx, int incy)
      Compute scalar product between dx and dy.
      static void rswap​(int n, double[] dx, int dxIdx, int incx, double[] dy, int dyIdx, int incy)
      Exchange two vectors.
      static void rswap​(int n, float[] dx, int dxIdx, int incx, float[] dy, int dyIdx, int incy)
      Exchange two vectors.
      static void rzaxpy​(int n, double[] dz, int dzIdx, int incz, double da, double[] dx, int dxIdx, int incx, double[] dy, int dyIdx, int incy)
      Computes dz <- dx + dy
      static void rzaxpy​(int n, float[] dz, int dzIdx, int incz, float da, float[] dx, int dxIdx, int incx, float[] dy, int dyIdx, int incy)
      Computes dz <- dx + dy
      static void rzgxpy​(int n, double[] dz, double[] dx, double[] dy)  
      static void rzgxpy​(int n, float[] dz, float[] dx, float[] dy)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • rswap

        public static void rswap​(int n,
                                 double[] dx,
                                 int dxIdx,
                                 int incx,
                                 double[] dy,
                                 int dyIdx,
                                 int incy)
        Exchange two vectors.
      • rcopy

        public static void rcopy​(int n,
                                 double[] dx,
                                 int dxIdx,
                                 int incx,
                                 double[] dy,
                                 int dyIdx,
                                 int incy)
        Copy dx to dy.
      • raxpy

        public static void raxpy​(int n,
                                 double da,
                                 double[] dx,
                                 int dxIdx,
                                 int incx,
                                 double[] dy,
                                 int dyIdx,
                                 int incy)
        Compute dy <- da * dx + dy.
      • rzaxpy

        public static void rzaxpy​(int n,
                                  double[] dz,
                                  int dzIdx,
                                  int incz,
                                  double da,
                                  double[] dx,
                                  int dxIdx,
                                  int incx,
                                  double[] dy,
                                  int dyIdx,
                                  int incy)
        Computes dz <- dx + dy
      • rzgxpy

        public static void rzgxpy​(int n,
                                  double[] dz,
                                  double[] dx,
                                  double[] dy)
      • rdot

        public static double rdot​(int n,
                                  double[] dx,
                                  int dxIdx,
                                  int incx,
                                  double[] dy,
                                  int dyIdx,
                                  int incy)
        Compute scalar product between dx and dy.
      • rswap

        public static void rswap​(int n,
                                 float[] dx,
                                 int dxIdx,
                                 int incx,
                                 float[] dy,
                                 int dyIdx,
                                 int incy)
        Exchange two vectors.
      • rcopy

        public static void rcopy​(int n,
                                 float[] dx,
                                 int dxIdx,
                                 int incx,
                                 float[] dy,
                                 int dyIdx,
                                 int incy)
        Copy dx to dy.
      • raxpy

        public static void raxpy​(int n,
                                 float da,
                                 float[] dx,
                                 int dxIdx,
                                 int incx,
                                 float[] dy,
                                 int dyIdx,
                                 int incy)
        Compute dy <- da * dx + dy.
      • rzaxpy

        public static void rzaxpy​(int n,
                                  float[] dz,
                                  int dzIdx,
                                  int incz,
                                  float da,
                                  float[] dx,
                                  int dxIdx,
                                  int incx,
                                  float[] dy,
                                  int dyIdx,
                                  int incy)
        Computes dz <- dx + dy
      • rzgxpy

        public static void rzgxpy​(int n,
                                  float[] dz,
                                  float[] dx,
                                  float[] dy)
      • rdot

        public static float rdot​(int n,
                                 float[] dx,
                                 int dxIdx,
                                 int incx,
                                 float[] dy,
                                 int dyIdx,
                                 int incy)
        Compute scalar product between dx and dy.