7. แถวลำดับ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 7-27  เมท็อดการคูณเมทริกซ์กับเมทริกซ์
  public static double[][] multiply(double[][] a, double[][] b) {
    if (a[0].length != b.length) {
      throw new IllegalArgumentException("มิติไม่เท่ากัน");
    }
    double[][] c = new double[a.length][b[0].length];
    for (int i = 0; i < c.length; i++) {
      for (int j = 0; j < c[0].length; j++) {
        for (int k = 0; k < a[0].length; k++) {
          c[i][j] += a[i][k]*b[k][j];
        }
      }
    }
    return c;
  }
©2009 S.Prasitjutrakul