Ejemplo n.º 1
0
 /**
  * @param A
  * @param B
  * @return
  */
 public static Matrix mmul(final Matrix A, final Matrix B) {
   try {
     if (A.n != B.m) throw new Matrix.WrongDimensionsException();
   } catch (Matrix.WrongDimensionsException e) {
     e.printStackTrace();
     System.exit(1);
   }
   float[] result = new float[A.m * B.n];
   Level3.sgemm(
       BlasOrder.ROW_MAJOR,
       BlasTrans.NO_TRANS,
       BlasTrans.NO_TRANS,
       A.m,
       B.n,
       A.n,
       1f,
       A.getData(),
       A.ld,
       B.getData(),
       B.ld,
       1f,
       result,
       B.ld);
   return new Matrix(result, A.m, B.n);
 }
Ejemplo n.º 2
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];
  }