示例#1
0
  /**
   * @param A
   * @param B
   * @return
   */
  public static float dot(Matrix A, Matrix B) {
    int aLen = A.m * A.n;
    int bLen = B.m * B.n;
    try {
      if (bLen != aLen) throw new Matrix.WrongDimensionsException();
    } catch (Matrix.WrongDimensionsException e) {
      e.printStackTrace();
      System.exit(1);
    }
    float[] dotP = new float[1];

    Level1.sdot(aLen, dotP, A.getData(), B.getData());
    return dotP[0];
  }
示例#2
0
 public static float[] add(final float[] a, final float[] b) {
   Level1.saxpy(a.length, 1f, a, b);
   return b;
 }
示例#3
0
 /**
  * @param M
  * @param alpha
  * @return
  */
 public static Matrix scale(Matrix M, float alpha) {
   float[] scaled = M.getData().clone();
   Level1.sscal(scaled.length, alpha, scaled);
   return new Matrix(scaled, M.m, M.n);
 }