hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r718523 - in /incubator/hama/trunk: CHANGES.txt src/java/org/apache/hama/SubMatrix.java src/java/org/apache/hama/algebra/BlockCyclicMultiplyReduce.java src/test/org/apache/hama/TestDenseMatrix.java
Date Tue, 18 Nov 2008 09:01:38 GMT
Author: edwardyoon
Date: Tue Nov 18 01:01:37 2008
New Revision: 718523

URL: http://svn.apache.org/viewvc?rev=718523&view=rev
Log:
SubMatrix should be able to get row, column size 

Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/src/java/org/apache/hama/SubMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/algebra/BlockCyclicMultiplyReduce.java
    incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=718523&r1=718522&r2=718523&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Tue Nov 18 01:01:37 2008
@@ -78,6 +78,7 @@
 
   BUG FIXES
    
+    HAMA-106: SubMatrix should be able to get row, column size (edwardyoon)
     HAMA-98: change '~=' operation to use `echo $f | grep 'examples$'` 
                (samuel via edwardyoon)
     HAMA-64: Bytes and Double convert (edwardyoon)

Modified: incubator/hama/trunk/src/java/org/apache/hama/SubMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/SubMatrix.java?rev=718523&r1=718522&r2=718523&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/SubMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/SubMatrix.java Tue Nov 18 01:01:37 2008
@@ -37,7 +37,7 @@
    * @param j the size of columns
    */
   public SubMatrix(int i, int j) {
-    matrix = new double[i][j];
+    this.matrix = new double[i][j];
   }
 
   /**
@@ -79,9 +79,9 @@
    * @return c
    */
   public SubMatrix add(SubMatrix b) {
-    double[][] C = new double[size()][size()];
-    for (int i = 0; i < size(); i++) {
-      for (int j = 0; j < size(); j++) {
+    double[][] C = new double[getRows()][getColumns()];
+    for (int i = 0; i < this.getRows(); i++) {
+      for (int j = 0; j < this.getColumns(); j++) {
         C[i][j] += this.get(i, j) + b.get(i, j);
       }
     }
@@ -96,10 +96,10 @@
    * @return c
    */
   public SubMatrix mult(SubMatrix b) {
-    double[][] C = new double[size()][size()];
-    for (int i = 0; i < size(); i++) {
-      for (int j = 0; j < size(); j++) {
-        for (int k = 0; k < size(); k++) {
+    double[][] C = new double[getRows()][getColumns()];
+    for (int i = 0; i < this.getRows(); i++) {
+      for (int j = 0; j < b.getColumns(); j++) {
+        for (int k = 0; k < this.getColumns(); k++) {
           C[i][k] += this.get(i, j) * b.get(j, k);
         }
       }
@@ -108,15 +108,14 @@
     return new SubMatrix(C);
   }
 
-  /**
-   * TODO: SubMatrix should be able to get row, column size
-   * 
-   * @return the length
-   */
-  public int size() {
-    return matrix.length;
+  public int getRows() {
+    return this.matrix.length;
   }
-
+  
+  public int getColumns() {
+    return this.matrix[0].length;
+  }
+  
   public void close() {
     matrix = null;
   }

Modified: incubator/hama/trunk/src/java/org/apache/hama/algebra/BlockCyclicMultiplyReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/BlockCyclicMultiplyReduce.java?rev=718523&r1=718522&r2=718523&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/algebra/BlockCyclicMultiplyReduce.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/algebra/BlockCyclicMultiplyReduce.java Tue
Nov 18 01:01:37 2008
@@ -62,13 +62,12 @@
       int column = e.getKey();
       SubMatrix mat = e.getValue();
 
-      int startRow = row * mat.size();
-      int startColumn = column * mat.size();
+      int startRow = row * mat.getRows();
+      int startColumn = column * mat.getColumns();
 
-      // TODO: sub matrix can be not a regular sqaure
-      for (int i = 0; i < mat.size(); i++) {
+      for (int i = 0; i < mat.getRows(); i++) {
         VectorUpdate update = new VectorUpdate(i + startRow);
-        for (int j = 0; j < mat.size(); j++) {
+        for (int j = 0; j < mat.getColumns(); j++) {
           update.put(j + startColumn, mat.get(i, j));
         }
         output.collect(key, update);

Modified: incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java?rev=718523&r1=718522&r2=718523&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java Tue Nov 18 01:01:37
2008
@@ -124,8 +124,8 @@
 
   public void testSubMatrix() throws IOException {
     SubMatrix a = m1.subMatrix(2, 4, 2, 4);
-    for (int i = 0; i < a.size(); i++) {
-      for (int j = 0; j < a.size(); j++) {
+    for (int i = 0; i < a.getRows(); i++) {
+      for (int j = 0; j < a.getColumns(); j++) {
         assertEquals(a.get(i, j), m1.get(i + 2, j + 2));
       }
     }



Mime
View raw message