mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r883974 [12/20] - in /lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix: ./ bench/ doublealgo/ impl/ linalg/ objectalgo/
Date Wed, 25 Nov 2009 03:41:31 GMT
Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseDoubleMatrix2D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseDoubleMatrix2D.java?rev=883974&r1=883973&r2=883974&view=diff
==============================================================================
--- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseDoubleMatrix2D.java (original)
+++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseDoubleMatrix2D.java Wed Nov 25 03:41:28 2009
@@ -43,21 +43,21 @@
 @version 1.0, 09/24/99
 */
 class SelectedDenseDoubleMatrix2D extends DoubleMatrix2D {
-	/**
-	  * The elements of this matrix.
-	  */
-	protected double[] elements;
-	
-	/**
-	  * The offsets of the visible cells of this matrix.
-	  */
-	protected int[] rowOffsets;
-	protected int[] columnOffsets;
-	
-	/**
-	  * The offset.
-	  */
-	protected int offset;	
+  /**
+    * The elements of this matrix.
+    */
+  protected double[] elements;
+  
+  /**
+    * The offsets of the visible cells of this matrix.
+    */
+  protected int[] rowOffsets;
+  protected int[] columnOffsets;
+  
+  /**
+    * The offset.
+    */
+  protected int offset;  
 /**
  * Constructs a matrix view with the given parameters.
  * @param elements the cells.
@@ -66,7 +66,7 @@
  * @param  offset   
  */
 protected SelectedDenseDoubleMatrix2D(double[] elements, int[] rowOffsets, int[] columnOffsets, int offset) {
-	this(rowOffsets.length,columnOffsets.length,elements,0,0,1,1,rowOffsets,columnOffsets,offset);
+  this(rowOffsets.length,columnOffsets.length,elements,0,0,1,1,rowOffsets,columnOffsets,offset);
 }
 /**
  * Constructs a matrix view with the given parameters.
@@ -82,15 +82,15 @@
  * @param  offset   
  */
 protected SelectedDenseDoubleMatrix2D(int rows, int columns, double[] elements, int rowZero, int columnZero, int rowStride, int columnStride, int[] rowOffsets, int[] columnOffsets, int offset) {
-	// be sure parameters are valid, we do not check...
-	setUp(rows,columns,rowZero,columnZero,rowStride,columnStride);
-	
-	this.elements = elements;
-	this.rowOffsets = rowOffsets;
-	this.columnOffsets = columnOffsets;
-	this.offset = offset;
-	
-	this.isNoView = false;
+  // be sure parameters are valid, we do not check...
+  setUp(rows,columns,rowZero,columnZero,rowStride,columnStride);
+  
+  this.elements = elements;
+  this.rowOffsets = rowOffsets;
+  this.columnOffsets = columnOffsets;
+  this.offset = offset;
+  
+  this.isNoView = false;
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -100,7 +100,7 @@
  * @return the position.
  */
 protected int _columnOffset(int absRank) {
-	return columnOffsets[absRank];
+  return columnOffsets[absRank];
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -110,7 +110,7 @@
  * @return the position.
  */
 protected int _rowOffset(int absRank) {
-	return rowOffsets[absRank];
+  return rowOffsets[absRank];
 }
 /**
  * Returns the matrix cell value at coordinate <tt>[row,column]</tt>.
@@ -124,10 +124,10 @@
  * @return    the value at the specified coordinate.
  */
 public double getQuick(int row, int column) {
-	//if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
-	//return elements[index(row,column)];
-	//manually inlined:
-	return elements[offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]];
+  //if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
+  //return elements[index(row,column)];
+  //manually inlined:
+  return elements[offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]];
 }
 /**
  * Returns <tt>true</tt> if both matrices share common cells.
@@ -139,15 +139,15 @@
  * </ul>
  */
 protected boolean haveSharedCellsRaw(DoubleMatrix2D other) {
-	if (other instanceof SelectedDenseDoubleMatrix2D) {
-		SelectedDenseDoubleMatrix2D otherMatrix = (SelectedDenseDoubleMatrix2D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	else if (other instanceof DenseDoubleMatrix2D) {
-		DenseDoubleMatrix2D otherMatrix = (DenseDoubleMatrix2D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	return false;
+  if (other instanceof SelectedDenseDoubleMatrix2D) {
+    SelectedDenseDoubleMatrix2D otherMatrix = (SelectedDenseDoubleMatrix2D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  else if (other instanceof DenseDoubleMatrix2D) {
+    DenseDoubleMatrix2D otherMatrix = (DenseDoubleMatrix2D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  return false;
 }
 /**
  * Returns the position of the given coordinate within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -156,9 +156,9 @@
  * @param     column   the index of the column-coordinate.
  */
 protected int index(int row, int column) {
-	//return this.offset + super.index(row,column);
-	//manually inlined:
-	return this.offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
+  //return this.offset + super.index(row,column);
+  //manually inlined:
+  return this.offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
 }
 /**
  * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of rows and columns.
@@ -171,7 +171,7 @@
  * @return  a new empty matrix of the same dynamic type.
  */
 public DoubleMatrix2D like(int rows, int columns) {
-	return new DenseDoubleMatrix2D(rows, columns);
+  return new DenseDoubleMatrix2D(rows, columns);
 }
 /**
  * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
@@ -182,7 +182,7 @@
  * @return  a new matrix of the corresponding dynamic type.
  */
 public DoubleMatrix1D like1D(int size) {
-	return new DenseDoubleMatrix1D(size);
+  return new DenseDoubleMatrix1D(size);
 }
 /**
  * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, sharing the same cells.
@@ -195,7 +195,7 @@
  * @return  a new matrix of the corresponding dynamic type.
  */
 protected DoubleMatrix1D like1D(int size, int zero, int stride) {
-	throw new InternalError(); // this method is never called since viewRow() and viewColumn are overridden properly.
+  throw new InternalError(); // this method is never called since viewRow() and viewColumn are overridden properly.
 }
 /**
  * Sets the matrix cell at coordinate <tt>[row,column]</tt> to the specified value.
@@ -209,35 +209,35 @@
  * @param    value the value to be filled into the specified cell.
  */
 public void setQuick(int row, int column, double value) {
-	//if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
-	//elements[index(row,column)] = value;
-	//manually inlined:
-	elements[offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]] = value;
+  //if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
+  //elements[index(row,column)] = value;
+  //manually inlined:
+  elements[offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]] = value;
 }
 /**
  * Sets up a matrix with a given number of rows and columns.
  * @param rows the number of rows the matrix shall have.
  * @param columns the number of columns the matrix shall have.
- * @throws	IllegalArgumentException if <tt>(double)columns*rows > Integer.MAX_VALUE</tt>.
+ * @throws  IllegalArgumentException if <tt>(double)columns*rows > Integer.MAX_VALUE</tt>.
  */
 protected void setUp(int rows, int columns) {
-	super.setUp(rows,columns);
-	this.rowStride = 1;
-	this.columnStride = 1;
-	this.offset = 0;
+  super.setUp(rows,columns);
+  this.rowStride = 1;
+  this.columnStride = 1;
+  this.offset = 0;
 }
 /**
 Self modifying version of viewDice().
 */
 protected AbstractMatrix2D vDice() {
-	super.vDice();
-	// swap
-	int[] tmp = rowOffsets; rowOffsets = columnOffsets; columnOffsets = tmp;
+  super.vDice();
+  // swap
+  int[] tmp = rowOffsets; rowOffsets = columnOffsets; columnOffsets = tmp;
 
-	// flips stay unaffected
+  // flips stay unaffected
 
-	this.isNoView = false;
-	return this;
+  this.isNoView = false;
+  return this;
 }
 /**
 Constructs and returns a new <i>slice view</i> representing the rows of the given column.
@@ -247,12 +247,12 @@
 <b>Example:</b> 
 <table border="0">
   <tr nowrap> 
-	<td valign="top">2 x 3 matrix: <br>
-	  1, 2, 3<br>
-	  4, 5, 6 </td>
-	<td>viewColumn(0) ==></td>
-	<td valign="top">Matrix1D of size 2:<br>
-	  1, 4</td>
+  <td valign="top">2 x 3 matrix: <br>
+    1, 2, 3<br>
+    4, 5, 6 </td>
+  <td>viewColumn(0) ==></td>
+  <td valign="top">Matrix1D of size 2:<br>
+    1, 4</td>
    </tr>
 </table>
 
@@ -262,13 +262,13 @@
 @see #viewRow(int)
 */
 public DoubleMatrix1D viewColumn(int column) {
-	checkColumn(column);
-	int viewSize = this.rows;
-	int viewZero = this.rowZero;
-	int viewStride = this.rowStride;
-	int[] viewOffsets = this.rowOffsets;
-	int viewOffset = this.offset + _columnOffset(_columnRank(column));
-	return new SelectedDenseDoubleMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
+  checkColumn(column);
+  int viewSize = this.rows;
+  int viewZero = this.rowZero;
+  int viewStride = this.rowStride;
+  int[] viewOffsets = this.rowOffsets;
+  int viewOffset = this.offset + _columnOffset(_columnRank(column));
+  return new SelectedDenseDoubleMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
 }
 /**
 Constructs and returns a new <i>slice view</i> representing the columns of the given row.
@@ -278,12 +278,12 @@
 <b>Example:</b> 
 <table border="0">
   <tr nowrap> 
-	<td valign="top">2 x 3 matrix: <br>
-	  1, 2, 3<br>
-	  4, 5, 6 </td>
-	<td>viewRow(0) ==></td>
-	<td valign="top">Matrix1D of size 3:<br>
-	  1, 2, 3</td>
+  <td valign="top">2 x 3 matrix: <br>
+    1, 2, 3<br>
+    4, 5, 6 </td>
+  <td>viewRow(0) ==></td>
+  <td valign="top">Matrix1D of size 3:<br>
+    1, 2, 3</td>
    </tr>
 </table>
 
@@ -293,13 +293,13 @@
 @see #viewColumn(int)
 */
 public DoubleMatrix1D viewRow(int row) {
-	checkRow(row);
-	int viewSize = this.columns;
-	int viewZero = columnZero;
-	int viewStride = this.columnStride;
-	int[] viewOffsets = this.columnOffsets;
-	int viewOffset = this.offset + _rowOffset(_rowRank(row));
-	return new SelectedDenseDoubleMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
+  checkRow(row);
+  int viewSize = this.columns;
+  int viewZero = columnZero;
+  int viewStride = this.columnStride;
+  int[] viewOffsets = this.columnOffsets;
+  int viewOffset = this.offset + _rowOffset(_rowRank(row));
+  return new SelectedDenseDoubleMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
 }
 /**
  * Construct and returns a new selection view.
@@ -309,6 +309,6 @@
  * @return  a new view.
  */
 protected DoubleMatrix2D viewSelectionLike(int[] rowOffsets, int[] columnOffsets) {
-	return new SelectedDenseDoubleMatrix2D(this.elements,rowOffsets,columnOffsets,this.offset);
+  return new SelectedDenseDoubleMatrix2D(this.elements,rowOffsets,columnOffsets,this.offset);
 }
 }

Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseDoubleMatrix3D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseDoubleMatrix3D.java?rev=883974&r1=883973&r2=883974&view=diff
==============================================================================
--- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseDoubleMatrix3D.java (original)
+++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseDoubleMatrix3D.java Wed Nov 25 03:41:28 2009
@@ -43,23 +43,23 @@
 @version 1.0, 09/24/99
 */
 class SelectedDenseDoubleMatrix3D extends DoubleMatrix3D {
-	/**
-	  * The elements of this matrix.
-	  */
-	protected double[] elements;
-	
-	/**
-	  * The offsets of the visible cells of this matrix.
-	  */
-	protected int[] sliceOffsets;
-	protected int[] rowOffsets;
-	protected int[] columnOffsets;
-	
-	/**
-	  * The offset.
-	  */
-	protected int offset;	
-	
+  /**
+    * The elements of this matrix.
+    */
+  protected double[] elements;
+  
+  /**
+    * The offsets of the visible cells of this matrix.
+    */
+  protected int[] sliceOffsets;
+  protected int[] rowOffsets;
+  protected int[] columnOffsets;
+  
+  /**
+    * The offset.
+    */
+  protected int offset;  
+  
 /**
  * Constructs a matrix view with the given parameters.
  * @param elements the cells.
@@ -68,21 +68,21 @@
  * @param  columnOffsets   The column offsets of the cells that shall be visible.
  */
 protected SelectedDenseDoubleMatrix3D(double[] elements, int[] sliceOffsets, int[] rowOffsets, int[] columnOffsets, int offset) {
-	// be sure parameters are valid, we do not check...
-	int slices = sliceOffsets.length;
-	int rows = rowOffsets.length;
-	int columns = columnOffsets.length;
-	setUp(slices,rows, columns);
-	
-	this.elements = elements;
-	
-	this.sliceOffsets = sliceOffsets;
-	this.rowOffsets = rowOffsets;
-	this.columnOffsets = columnOffsets;
-
-	this.offset = offset;
-	
-	this.isNoView = false;
+  // be sure parameters are valid, we do not check...
+  int slices = sliceOffsets.length;
+  int rows = rowOffsets.length;
+  int columns = columnOffsets.length;
+  setUp(slices,rows, columns);
+  
+  this.elements = elements;
+  
+  this.sliceOffsets = sliceOffsets;
+  this.rowOffsets = rowOffsets;
+  this.columnOffsets = columnOffsets;
+
+  this.offset = offset;
+  
+  this.isNoView = false;
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -92,7 +92,7 @@
  * @return the position.
  */
 protected int _columnOffset(int absRank) {
-	return columnOffsets[absRank];
+  return columnOffsets[absRank];
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -102,7 +102,7 @@
  * @return the position.
  */
 protected int _rowOffset(int absRank) {
-	return rowOffsets[absRank];
+  return rowOffsets[absRank];
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -112,7 +112,7 @@
  * @return the position.
  */
 protected int _sliceOffset(int absRank) {
-	return sliceOffsets[absRank];
+  return sliceOffsets[absRank];
 }
 /**
  * Returns the matrix cell value at coordinate <tt>[slice,row,column]</tt>.
@@ -127,10 +127,10 @@
  * @return    the value at the specified coordinate.
  */
 public double getQuick(int slice, int row, int column) {
-	//if (debug) if (slice<0 || slice>=slices || row<0 || row>=rows || column<0 || column>=columns) throw new IndexOutOfBoundsException("slice:"+slice+", row:"+row+", column:"+column);
-	//return elements[index(slice,row,column)];
-	//manually inlined:
-	return elements[offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]];
+  //if (debug) if (slice<0 || slice>=slices || row<0 || row>=rows || column<0 || column>=columns) throw new IndexOutOfBoundsException("slice:"+slice+", row:"+row+", column:"+column);
+  //return elements[index(slice,row,column)];
+  //manually inlined:
+  return elements[offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]];
 }
 /**
  * Returns <tt>true</tt> if both matrices share common cells.
@@ -142,15 +142,15 @@
  * </ul>
  */
 protected boolean haveSharedCellsRaw(DoubleMatrix3D other) {
-	if (other instanceof SelectedDenseDoubleMatrix3D) {
-		SelectedDenseDoubleMatrix3D otherMatrix = (SelectedDenseDoubleMatrix3D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	else if (other instanceof DenseDoubleMatrix3D) {
-		DenseDoubleMatrix3D otherMatrix = (DenseDoubleMatrix3D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	return false;
+  if (other instanceof SelectedDenseDoubleMatrix3D) {
+    SelectedDenseDoubleMatrix3D otherMatrix = (SelectedDenseDoubleMatrix3D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  else if (other instanceof DenseDoubleMatrix3D) {
+    DenseDoubleMatrix3D otherMatrix = (DenseDoubleMatrix3D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  return false;
 }
 /**
  * Returns the position of the given coordinate within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -160,9 +160,9 @@
  * @param     column   the index of the third-coordinate.
  */
 protected int index(int slice, int row, int column) {
-	//return this.offset + super.index(slice,row,column);
-	//manually inlined:
-	return this.offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
+  //return this.offset + super.index(slice,row,column);
+  //manually inlined:
+  return this.offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
 }
 /**
  * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of slices, rows and columns.
@@ -176,7 +176,7 @@
  * @return  a new empty matrix of the same dynamic type.
  */
 public DoubleMatrix3D like(int slices, int rows, int columns) {
-	return new DenseDoubleMatrix3D(slices,rows,columns); 
+  return new DenseDoubleMatrix3D(slices,rows,columns); 
 }
 /**
  * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, sharing the same cells.
@@ -192,7 +192,7 @@
  * @return  a new matrix of the corresponding dynamic type.
  */
 protected DoubleMatrix2D like2D(int rows, int columns, int rowZero, int columnZero, int rowStride, int columnStride) {
-	throw new InternalError(); // this method is never called since viewRow() and viewColumn are overridden properly.
+  throw new InternalError(); // this method is never called since viewRow() and viewColumn are overridden properly.
 }
 /**
  * Sets the matrix cell at coordinate <tt>[slice,row,column]</tt> to the specified value.
@@ -207,43 +207,43 @@
  * @param    value the value to be filled into the specified cell.
  */
 public void setQuick(int slice, int row, int column, double value) {
-	//if (debug) if (slice<0 || slice>=slices || row<0 || row>=rows || column<0 || column>=columns) throw new IndexOutOfBoundsException("slice:"+slice+", row:"+row+", column:"+column);
-	//elements[index(slice,row,column)] = value;
-	//manually inlined:
-	elements[offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]] = value;
+  //if (debug) if (slice<0 || slice>=slices || row<0 || row>=rows || column<0 || column>=columns) throw new IndexOutOfBoundsException("slice:"+slice+", row:"+row+", column:"+column);
+  //elements[index(slice,row,column)] = value;
+  //manually inlined:
+  elements[offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]] = value;
 }
 /**
  * Sets up a matrix with a given number of slices and rows.
  * @param slices the number of slices the matrix shall have.
  * @param rows the number of rows the matrix shall have.
  * @param columns the number of columns the matrix shall have.
- * @throws	IllegalArgumentException if <tt>(double)rows*slices > Integer.MAX_VALUE</tt>.
+ * @throws  IllegalArgumentException if <tt>(double)rows*slices > Integer.MAX_VALUE</tt>.
  */
 protected void setUp(int slices, int rows, int columns) {
-	super.setUp(slices,rows,columns);
-	this.sliceStride = 1;
-	this.rowStride = 1;
-	this.columnStride = 1;
-	this.offset = 0;
+  super.setUp(slices,rows,columns);
+  this.sliceStride = 1;
+  this.rowStride = 1;
+  this.columnStride = 1;
+  this.offset = 0;
 }
 /**
 Self modifying version of viewDice().
 @throws IllegalArgumentException if some of the parameters are equal or not in range 0..2.
 */
 protected AbstractMatrix3D vDice(int axis0, int axis1, int axis2) {
-	super.vDice(axis0,axis1,axis2);
-	
-	// swap offsets
-	int[][] offsets = new int[3][];
-	offsets[0] = this.sliceOffsets;
-	offsets[1] = this.rowOffsets;
-	offsets[2] = this.columnOffsets;
-
-	this.sliceOffsets = offsets[axis0];
-	this.rowOffsets = offsets[axis1];
-	this.columnOffsets = offsets[axis2];
+  super.vDice(axis0,axis1,axis2);
+  
+  // swap offsets
+  int[][] offsets = new int[3][];
+  offsets[0] = this.sliceOffsets;
+  offsets[1] = this.rowOffsets;
+  offsets[2] = this.columnOffsets;
+
+  this.sliceOffsets = offsets[axis0];
+  this.rowOffsets = offsets[axis1];
+  this.columnOffsets = offsets[axis2];
 
-	return this;
+  return this;
 }
 /**
 Constructs and returns a new 2-dimensional <i>slice view</i> representing the slices and rows of the given column.
@@ -260,22 +260,22 @@
 @see #viewRow(int)
 */
 public DoubleMatrix2D viewColumn(int column) {
-	checkColumn(column);
-	
-	int viewRows = this.slices;
-	int viewColumns = this.rows;
-	
-	int viewRowZero = sliceZero;
-	int viewColumnZero = rowZero;
-	int viewOffset = this.offset + _columnOffset(_columnRank(column));
+  checkColumn(column);
+  
+  int viewRows = this.slices;
+  int viewColumns = this.rows;
+  
+  int viewRowZero = sliceZero;
+  int viewColumnZero = rowZero;
+  int viewOffset = this.offset + _columnOffset(_columnRank(column));
 
-	int viewRowStride = this.sliceStride;
-	int viewColumnStride = this.rowStride;
+  int viewRowStride = this.sliceStride;
+  int viewColumnStride = this.rowStride;
 
-	int[] viewRowOffsets = this.sliceOffsets;
-	int[] viewColumnOffsets = this.rowOffsets;
+  int[] viewRowOffsets = this.sliceOffsets;
+  int[] viewColumnOffsets = this.rowOffsets;
 
-	return new SelectedDenseDoubleMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
+  return new SelectedDenseDoubleMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
 }
 /**
 Constructs and returns a new 2-dimensional <i>slice view</i> representing the slices and columns of the given row.
@@ -292,22 +292,22 @@
 @see #viewColumn(int)
 */
 public DoubleMatrix2D viewRow(int row) {
-	checkRow(row);
-	
-	int viewRows = this.slices;
-	int viewColumns = this.columns;
-	
-	int viewRowZero = sliceZero;
-	int viewColumnZero = columnZero;
-	int viewOffset = this.offset + _rowOffset(_rowRank(row));
+  checkRow(row);
+  
+  int viewRows = this.slices;
+  int viewColumns = this.columns;
+  
+  int viewRowZero = sliceZero;
+  int viewColumnZero = columnZero;
+  int viewOffset = this.offset + _rowOffset(_rowRank(row));
 
-	int viewRowStride = this.sliceStride;
-	int viewColumnStride = this.columnStride;
+  int viewRowStride = this.sliceStride;
+  int viewColumnStride = this.columnStride;
 
-	int[] viewRowOffsets = this.sliceOffsets;
-	int[] viewColumnOffsets = this.columnOffsets;
+  int[] viewRowOffsets = this.sliceOffsets;
+  int[] viewColumnOffsets = this.columnOffsets;
 
-	return new SelectedDenseDoubleMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
+  return new SelectedDenseDoubleMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
 }
 /**
  * Construct and returns a new selection view.
@@ -318,7 +318,7 @@
  * @return  a new view.
  */
 protected DoubleMatrix3D viewSelectionLike(int[] sliceOffsets, int[] rowOffsets, int[] columnOffsets) {
-	return new SelectedDenseDoubleMatrix3D(this.elements,sliceOffsets,rowOffsets,columnOffsets,this.offset);
+  return new SelectedDenseDoubleMatrix3D(this.elements,sliceOffsets,rowOffsets,columnOffsets,this.offset);
 }
 /**
 Constructs and returns a new 2-dimensional <i>slice view</i> representing the rows and columns of the given slice.
@@ -335,21 +335,21 @@
 @see #viewColumn(int)
 */
 public DoubleMatrix2D viewSlice(int slice) {
-	checkSlice(slice);
-	
-	int viewRows = this.rows;
-	int viewColumns = this.columns;
-	
-	int viewRowZero = rowZero;
-	int viewColumnZero = columnZero;
-	int viewOffset = this.offset + _sliceOffset(_sliceRank(slice));
+  checkSlice(slice);
+  
+  int viewRows = this.rows;
+  int viewColumns = this.columns;
+  
+  int viewRowZero = rowZero;
+  int viewColumnZero = columnZero;
+  int viewOffset = this.offset + _sliceOffset(_sliceRank(slice));
 
-	int viewRowStride = this.rowStride;
-	int viewColumnStride = this.columnStride;
+  int viewRowStride = this.rowStride;
+  int viewColumnStride = this.columnStride;
 
-	int[] viewRowOffsets = this.rowOffsets;
-	int[] viewColumnOffsets = this.columnOffsets;
+  int[] viewRowOffsets = this.rowOffsets;
+  int[] viewColumnOffsets = this.columnOffsets;
 
-	return new SelectedDenseDoubleMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
+  return new SelectedDenseDoubleMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
 }
 }

Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix1D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix1D.java?rev=883974&r1=883973&r2=883974&view=diff
==============================================================================
--- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix1D.java (original)
+++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix1D.java Wed Nov 25 03:41:28 2009
@@ -43,27 +43,27 @@
 @version 1.0, 09/24/99
 */
 class SelectedDenseObjectMatrix1D extends ObjectMatrix1D {
-	/**
-	  * The elements of this matrix.
-	  */
-	protected Object[] elements;
-	
-	/**
-	  * The offsets of visible indexes of this matrix.
-	  */
-	protected int[] offsets;
+  /**
+    * The elements of this matrix.
+    */
+  protected Object[] elements;
+  
+  /**
+    * The offsets of visible indexes of this matrix.
+    */
+  protected int[] offsets;
 
-	/**
-	  * The offset.
-	  */
-	protected int offset;	
+  /**
+    * The offset.
+    */
+  protected int offset;  
 /**
  * Constructs a matrix view with the given parameters.
  * @param elements the cells.
  * @param  indexes   The indexes of the cells that shall be visible.
  */
 protected SelectedDenseObjectMatrix1D(Object[] elements, int[] offsets) {
-	this(offsets.length,elements,0,1,offsets,0);
+  this(offsets.length,elements,0,1,offsets,0);
 }
 /**
  * Constructs a matrix view with the given parameters.
@@ -75,12 +75,12 @@
  * @param offset   
  */
 protected SelectedDenseObjectMatrix1D(int size, Object[] elements, int zero, int stride, int[] offsets, int offset) {
-	setUp(size,zero,stride);
-	
-	this.elements = elements;
-	this.offsets = offsets;
-	this.offset = offset;
-	this.isNoView = false;
+  setUp(size,zero,stride);
+  
+  this.elements = elements;
+  this.offsets = offsets;
+  this.offset = offset;
+  this.isNoView = false;
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -90,7 +90,7 @@
  * @return the position.
  */
 protected int _offset(int absRank) {
-	return offsets[absRank];
+  return offsets[absRank];
 }
 /**
  * Returns the matrix cell value at coordinate <tt>index</tt>.
@@ -103,24 +103,24 @@
  * @return    the value of the specified cell.
  */
 public Object getQuick(int index) {
-	//if (debug) if (index<0 || index>=size) checkIndex(index);
-	//return elements[index(index)];
-	//manually inlined:
-	return elements[offset + offsets[zero + index*stride]];
+  //if (debug) if (index<0 || index>=size) checkIndex(index);
+  //return elements[index(index)];
+  //manually inlined:
+  return elements[offset + offsets[zero + index*stride]];
 }
 /**
  * Returns <tt>true</tt> if both matrices share at least one identical cell.
  */
 protected boolean haveSharedCellsRaw(ObjectMatrix1D other) {
-	if (other instanceof SelectedDenseObjectMatrix1D) {
-		SelectedDenseObjectMatrix1D otherMatrix = (SelectedDenseObjectMatrix1D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	else if (other instanceof DenseObjectMatrix1D) {
-		DenseObjectMatrix1D otherMatrix = (DenseObjectMatrix1D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	return false;
+  if (other instanceof SelectedDenseObjectMatrix1D) {
+    SelectedDenseObjectMatrix1D otherMatrix = (SelectedDenseObjectMatrix1D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  else if (other instanceof DenseObjectMatrix1D) {
+    DenseObjectMatrix1D otherMatrix = (DenseObjectMatrix1D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  return false;
 }
 /**
  * Returns the position of the element with the given relative rank within the (virtual or non-virtual) internal 1-dimensional array.
@@ -129,9 +129,9 @@
  * @param     rank   the rank of the element.
  */
 protected int index(int rank) {
-	//return this.offset + super.index(rank);
-	// manually inlined:
-	return offset + offsets[zero + rank*stride];
+  //return this.offset + super.index(rank);
+  // manually inlined:
+  return offset + offsets[zero + rank*stride];
 }
 /**
  * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified size.
@@ -143,7 +143,7 @@
  * @return  a new empty matrix of the same dynamic type.
  */
 public ObjectMatrix1D like(int size) {
-	return new DenseObjectMatrix1D(size);
+  return new DenseObjectMatrix1D(size);
 }
 /**
  * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
@@ -155,7 +155,7 @@
  * @return  a new matrix of the corresponding dynamic type.
  */
 public ObjectMatrix2D like2D(int rows, int columns) {
-	return new DenseObjectMatrix2D(rows,columns);
+  return new DenseObjectMatrix2D(rows,columns);
 }
 /**
  * Sets the matrix cell at coordinate <tt>index</tt> to the specified value.
@@ -168,19 +168,19 @@
  * @param    value the value to be filled into the specified cell.
  */
 public void setQuick(int index, Object value) {
-	//if (debug) if (index<0 || index>=size) checkIndex(index);
-	//elements[index(index)] = value;
-	//manually inlined:
-	elements[offset + offsets[zero + index*stride]] = value;
+  //if (debug) if (index<0 || index>=size) checkIndex(index);
+  //elements[index(index)] = value;
+  //manually inlined:
+  elements[offset + offsets[zero + index*stride]] = value;
 }
 /**
  * Sets up a matrix with a given number of cells.
  * @param size the number of cells the matrix shall have.
  */
 protected void setUp(int size) {
-	super.setUp(size);
-	this.stride = 1;
-	this.offset = 0;
+  super.setUp(size);
+  this.stride = 1;
+  this.offset = 0;
 }
 /**
  * Construct and returns a new selection view.
@@ -189,6 +189,6 @@
  * @return  a new view.
  */
 protected ObjectMatrix1D viewSelectionLike(int[] offsets) {
-	return new SelectedDenseObjectMatrix1D(this.elements,offsets);
+  return new SelectedDenseObjectMatrix1D(this.elements,offsets);
 }
 }

Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix2D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix2D.java?rev=883974&r1=883973&r2=883974&view=diff
==============================================================================
--- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix2D.java (original)
+++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix2D.java Wed Nov 25 03:41:28 2009
@@ -43,21 +43,21 @@
 @version 1.0, 09/24/99
 */
 class SelectedDenseObjectMatrix2D extends ObjectMatrix2D {
-	/**
-	  * The elements of this matrix.
-	  */
-	protected Object[] elements;
-	
-	/**
-	  * The offsets of the visible cells of this matrix.
-	  */
-	protected int[] rowOffsets;
-	protected int[] columnOffsets;
-	
-	/**
-	  * The offset.
-	  */
-	protected int offset;	
+  /**
+    * The elements of this matrix.
+    */
+  protected Object[] elements;
+  
+  /**
+    * The offsets of the visible cells of this matrix.
+    */
+  protected int[] rowOffsets;
+  protected int[] columnOffsets;
+  
+  /**
+    * The offset.
+    */
+  protected int offset;  
 /**
  * Constructs a matrix view with the given parameters.
  * @param elements the cells.
@@ -66,7 +66,7 @@
  * @param  offset   
  */
 protected SelectedDenseObjectMatrix2D(Object[] elements, int[] rowOffsets, int[] columnOffsets, int offset) {
-	this(rowOffsets.length,columnOffsets.length,elements,0,0,1,1,rowOffsets,columnOffsets,offset);
+  this(rowOffsets.length,columnOffsets.length,elements,0,0,1,1,rowOffsets,columnOffsets,offset);
 }
 /**
  * Constructs a matrix view with the given parameters.
@@ -82,15 +82,15 @@
  * @param  offset   
  */
 protected SelectedDenseObjectMatrix2D(int rows, int columns, Object[] elements, int rowZero, int columnZero, int rowStride, int columnStride, int[] rowOffsets, int[] columnOffsets, int offset) {
-	// be sure parameters are valid, we do not check...
-	setUp(rows,columns,rowZero,columnZero,rowStride,columnStride);
-	
-	this.elements = elements;
-	this.rowOffsets = rowOffsets;
-	this.columnOffsets = columnOffsets;
-	this.offset = offset;
-	
-	this.isNoView = false;
+  // be sure parameters are valid, we do not check...
+  setUp(rows,columns,rowZero,columnZero,rowStride,columnStride);
+  
+  this.elements = elements;
+  this.rowOffsets = rowOffsets;
+  this.columnOffsets = columnOffsets;
+  this.offset = offset;
+  
+  this.isNoView = false;
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -100,7 +100,7 @@
  * @return the position.
  */
 protected int _columnOffset(int absRank) {
-	return columnOffsets[absRank];
+  return columnOffsets[absRank];
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -110,7 +110,7 @@
  * @return the position.
  */
 protected int _rowOffset(int absRank) {
-	return rowOffsets[absRank];
+  return rowOffsets[absRank];
 }
 /**
  * Returns the matrix cell value at coordinate <tt>[row,column]</tt>.
@@ -124,10 +124,10 @@
  * @return    the value at the specified coordinate.
  */
 public Object getQuick(int row, int column) {
-	//if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
-	//return elements[index(row,column)];
-	//manually inlined:
-	return elements[offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]];
+  //if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
+  //return elements[index(row,column)];
+  //manually inlined:
+  return elements[offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]];
 }
 /**
  * Returns <tt>true</tt> if both matrices share common cells.
@@ -139,15 +139,15 @@
  * </ul>
  */
 protected boolean haveSharedCellsRaw(ObjectMatrix2D other) {
-	if (other instanceof SelectedDenseObjectMatrix2D) {
-		SelectedDenseObjectMatrix2D otherMatrix = (SelectedDenseObjectMatrix2D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	else if (other instanceof DenseObjectMatrix2D) {
-		DenseObjectMatrix2D otherMatrix = (DenseObjectMatrix2D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	return false;
+  if (other instanceof SelectedDenseObjectMatrix2D) {
+    SelectedDenseObjectMatrix2D otherMatrix = (SelectedDenseObjectMatrix2D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  else if (other instanceof DenseObjectMatrix2D) {
+    DenseObjectMatrix2D otherMatrix = (DenseObjectMatrix2D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  return false;
 }
 /**
  * Returns the position of the given coordinate within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -156,9 +156,9 @@
  * @param     column   the index of the column-coordinate.
  */
 protected int index(int row, int column) {
-	//return this.offset + super.index(row,column);
-	//manually inlined:
-	return this.offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
+  //return this.offset + super.index(row,column);
+  //manually inlined:
+  return this.offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
 }
 /**
  * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of rows and columns.
@@ -171,7 +171,7 @@
  * @return  a new empty matrix of the same dynamic type.
  */
 public ObjectMatrix2D like(int rows, int columns) {
-	return new DenseObjectMatrix2D(rows, columns);
+  return new DenseObjectMatrix2D(rows, columns);
 }
 /**
  * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
@@ -182,7 +182,7 @@
  * @return  a new matrix of the corresponding dynamic type.
  */
 public ObjectMatrix1D like1D(int size) {
-	return new DenseObjectMatrix1D(size);
+  return new DenseObjectMatrix1D(size);
 }
 /**
  * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, sharing the same cells.
@@ -195,7 +195,7 @@
  * @return  a new matrix of the corresponding dynamic type.
  */
 protected ObjectMatrix1D like1D(int size, int zero, int stride) {
-	throw new InternalError(); // this method is never called since viewRow() and viewColumn are overridden properly.
+  throw new InternalError(); // this method is never called since viewRow() and viewColumn are overridden properly.
 }
 /**
  * Sets the matrix cell at coordinate <tt>[row,column]</tt> to the specified value.
@@ -209,35 +209,35 @@
  * @param    value the value to be filled into the specified cell.
  */
 public void setQuick(int row, int column, Object value) {
-	//if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
-	//elements[index(row,column)] = value;
-	//manually inlined:
-	elements[offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]] = value;
+  //if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
+  //elements[index(row,column)] = value;
+  //manually inlined:
+  elements[offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]] = value;
 }
 /**
  * Sets up a matrix with a given number of rows and columns.
  * @param rows the number of rows the matrix shall have.
  * @param columns the number of columns the matrix shall have.
- * @throws	IllegalArgumentException if <tt>(Object)columns*rows > Integer.MAX_VALUE</tt>.
+ * @throws  IllegalArgumentException if <tt>(Object)columns*rows > Integer.MAX_VALUE</tt>.
  */
 protected void setUp(int rows, int columns) {
-	super.setUp(rows,columns);
-	this.rowStride = 1;
-	this.columnStride = 1;
-	this.offset = 0;
+  super.setUp(rows,columns);
+  this.rowStride = 1;
+  this.columnStride = 1;
+  this.offset = 0;
 }
 /**
 Self modifying version of viewDice().
 */
 protected AbstractMatrix2D vDice() {
-	super.vDice();
-	// swap
-	int[] tmp = rowOffsets; rowOffsets = columnOffsets; columnOffsets = tmp;
+  super.vDice();
+  // swap
+  int[] tmp = rowOffsets; rowOffsets = columnOffsets; columnOffsets = tmp;
 
-	// flips stay unaffected
+  // flips stay unaffected
 
-	this.isNoView = false;
-	return this;
+  this.isNoView = false;
+  return this;
 }
 /**
 Constructs and returns a new <i>slice view</i> representing the rows of the given column.
@@ -247,12 +247,12 @@
 <b>Example:</b> 
 <table border="0">
   <tr nowrap> 
-	<td valign="top">2 x 3 matrix: <br>
-	  1, 2, 3<br>
-	  4, 5, 6 </td>
-	<td>viewColumn(0) ==></td>
-	<td valign="top">Matrix1D of size 2:<br>
-	  1, 4</td>
+  <td valign="top">2 x 3 matrix: <br>
+    1, 2, 3<br>
+    4, 5, 6 </td>
+  <td>viewColumn(0) ==></td>
+  <td valign="top">Matrix1D of size 2:<br>
+    1, 4</td>
    </tr>
 </table>
 
@@ -262,13 +262,13 @@
 @see #viewRow(int)
 */
 public ObjectMatrix1D viewColumn(int column) {
-	checkColumn(column);
-	int viewSize = this.rows;
-	int viewZero = this.rowZero;
-	int viewStride = this.rowStride;
-	int[] viewOffsets = this.rowOffsets;
-	int viewOffset = this.offset + _columnOffset(_columnRank(column));
-	return new SelectedDenseObjectMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
+  checkColumn(column);
+  int viewSize = this.rows;
+  int viewZero = this.rowZero;
+  int viewStride = this.rowStride;
+  int[] viewOffsets = this.rowOffsets;
+  int viewOffset = this.offset + _columnOffset(_columnRank(column));
+  return new SelectedDenseObjectMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
 }
 /**
 Constructs and returns a new <i>slice view</i> representing the columns of the given row.
@@ -278,12 +278,12 @@
 <b>Example:</b> 
 <table border="0">
   <tr nowrap> 
-	<td valign="top">2 x 3 matrix: <br>
-	  1, 2, 3<br>
-	  4, 5, 6 </td>
-	<td>viewRow(0) ==></td>
-	<td valign="top">Matrix1D of size 3:<br>
-	  1, 2, 3</td>
+  <td valign="top">2 x 3 matrix: <br>
+    1, 2, 3<br>
+    4, 5, 6 </td>
+  <td>viewRow(0) ==></td>
+  <td valign="top">Matrix1D of size 3:<br>
+    1, 2, 3</td>
    </tr>
 </table>
 
@@ -293,13 +293,13 @@
 @see #viewColumn(int)
 */
 public ObjectMatrix1D viewRow(int row) {
-	checkRow(row);
-	int viewSize = this.columns;
-	int viewZero = columnZero;
-	int viewStride = this.columnStride;
-	int[] viewOffsets = this.columnOffsets;
-	int viewOffset = this.offset + _rowOffset(_rowRank(row));
-	return new SelectedDenseObjectMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
+  checkRow(row);
+  int viewSize = this.columns;
+  int viewZero = columnZero;
+  int viewStride = this.columnStride;
+  int[] viewOffsets = this.columnOffsets;
+  int viewOffset = this.offset + _rowOffset(_rowRank(row));
+  return new SelectedDenseObjectMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
 }
 /**
  * Construct and returns a new selection view.
@@ -309,6 +309,6 @@
  * @return  a new view.
  */
 protected ObjectMatrix2D viewSelectionLike(int[] rowOffsets, int[] columnOffsets) {
-	return new SelectedDenseObjectMatrix2D(this.elements,rowOffsets,columnOffsets,this.offset);
+  return new SelectedDenseObjectMatrix2D(this.elements,rowOffsets,columnOffsets,this.offset);
 }
 }

Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix3D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix3D.java?rev=883974&r1=883973&r2=883974&view=diff
==============================================================================
--- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix3D.java (original)
+++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedDenseObjectMatrix3D.java Wed Nov 25 03:41:28 2009
@@ -43,23 +43,23 @@
 @version 1.0, 09/24/99
 */
 class SelectedDenseObjectMatrix3D extends ObjectMatrix3D {
-	/**
-	  * The elements of this matrix.
-	  */
-	protected Object[] elements;
-	
-	/**
-	  * The offsets of the visible cells of this matrix.
-	  */
-	protected int[] sliceOffsets;
-	protected int[] rowOffsets;
-	protected int[] columnOffsets;
-	
-	/**
-	  * The offset.
-	  */
-	protected int offset;	
-	
+  /**
+    * The elements of this matrix.
+    */
+  protected Object[] elements;
+  
+  /**
+    * The offsets of the visible cells of this matrix.
+    */
+  protected int[] sliceOffsets;
+  protected int[] rowOffsets;
+  protected int[] columnOffsets;
+  
+  /**
+    * The offset.
+    */
+  protected int offset;  
+  
 /**
  * Constructs a matrix view with the given parameters.
  * @param elements the cells.
@@ -68,21 +68,21 @@
  * @param  columnOffsets   The column offsets of the cells that shall be visible.
  */
 protected SelectedDenseObjectMatrix3D(Object[] elements, int[] sliceOffsets, int[] rowOffsets, int[] columnOffsets, int offset) {
-	// be sure parameters are valid, we do not check...
-	int slices = sliceOffsets.length;
-	int rows = rowOffsets.length;
-	int columns = columnOffsets.length;
-	setUp(slices,rows, columns);
-	
-	this.elements = elements;
-	
-	this.sliceOffsets = sliceOffsets;
-	this.rowOffsets = rowOffsets;
-	this.columnOffsets = columnOffsets;
-
-	this.offset = offset;
-	
-	this.isNoView = false;
+  // be sure parameters are valid, we do not check...
+  int slices = sliceOffsets.length;
+  int rows = rowOffsets.length;
+  int columns = columnOffsets.length;
+  setUp(slices,rows, columns);
+  
+  this.elements = elements;
+  
+  this.sliceOffsets = sliceOffsets;
+  this.rowOffsets = rowOffsets;
+  this.columnOffsets = columnOffsets;
+
+  this.offset = offset;
+  
+  this.isNoView = false;
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -92,7 +92,7 @@
  * @return the position.
  */
 protected int _columnOffset(int absRank) {
-	return columnOffsets[absRank];
+  return columnOffsets[absRank];
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -102,7 +102,7 @@
  * @return the position.
  */
 protected int _rowOffset(int absRank) {
-	return rowOffsets[absRank];
+  return rowOffsets[absRank];
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -112,7 +112,7 @@
  * @return the position.
  */
 protected int _sliceOffset(int absRank) {
-	return sliceOffsets[absRank];
+  return sliceOffsets[absRank];
 }
 /**
  * Returns the matrix cell value at coordinate <tt>[slice,row,column]</tt>.
@@ -127,10 +127,10 @@
  * @return    the value at the specified coordinate.
  */
 public Object getQuick(int slice, int row, int column) {
-	//if (debug) if (slice<0 || slice>=slices || row<0 || row>=rows || column<0 || column>=columns) throw new IndexOutOfBoundsException("slice:"+slice+", row:"+row+", column:"+column);
-	//return elements[index(slice,row,column)];
-	//manually inlined:
-	return elements[offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]];
+  //if (debug) if (slice<0 || slice>=slices || row<0 || row>=rows || column<0 || column>=columns) throw new IndexOutOfBoundsException("slice:"+slice+", row:"+row+", column:"+column);
+  //return elements[index(slice,row,column)];
+  //manually inlined:
+  return elements[offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]];
 }
 /**
  * Returns <tt>true</tt> if both matrices share common cells.
@@ -142,15 +142,15 @@
  * </ul>
  */
 protected boolean haveSharedCellsRaw(ObjectMatrix3D other) {
-	if (other instanceof SelectedDenseObjectMatrix3D) {
-		SelectedDenseObjectMatrix3D otherMatrix = (SelectedDenseObjectMatrix3D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	else if (other instanceof DenseObjectMatrix3D) {
-		DenseObjectMatrix3D otherMatrix = (DenseObjectMatrix3D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	return false;
+  if (other instanceof SelectedDenseObjectMatrix3D) {
+    SelectedDenseObjectMatrix3D otherMatrix = (SelectedDenseObjectMatrix3D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  else if (other instanceof DenseObjectMatrix3D) {
+    DenseObjectMatrix3D otherMatrix = (DenseObjectMatrix3D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  return false;
 }
 /**
  * Returns the position of the given coordinate within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -160,9 +160,9 @@
  * @param     column   the index of the third-coordinate.
  */
 protected int index(int slice, int row, int column) {
-	//return this.offset + super.index(slice,row,column);
-	//manually inlined:
-	return this.offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
+  //return this.offset + super.index(slice,row,column);
+  //manually inlined:
+  return this.offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
 }
 /**
  * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of slices, rows and columns.
@@ -176,7 +176,7 @@
  * @return  a new empty matrix of the same dynamic type.
  */
 public ObjectMatrix3D like(int slices, int rows, int columns) {
-	return new DenseObjectMatrix3D(slices,rows,columns); 
+  return new DenseObjectMatrix3D(slices,rows,columns); 
 }
 /**
  * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, sharing the same cells.
@@ -192,7 +192,7 @@
  * @return  a new matrix of the corresponding dynamic type.
  */
 protected ObjectMatrix2D like2D(int rows, int columns, int rowZero, int columnZero, int rowStride, int columnStride) {
-	throw new InternalError(); // this method is never called since viewRow() and viewColumn are overridden properly.
+  throw new InternalError(); // this method is never called since viewRow() and viewColumn are overridden properly.
 }
 /**
  * Sets the matrix cell at coordinate <tt>[slice,row,column]</tt> to the specified value.
@@ -207,43 +207,43 @@
  * @param    value the value to be filled into the specified cell.
  */
 public void setQuick(int slice, int row, int column, Object value) {
-	//if (debug) if (slice<0 || slice>=slices || row<0 || row>=rows || column<0 || column>=columns) throw new IndexOutOfBoundsException("slice:"+slice+", row:"+row+", column:"+column);
-	//elements[index(slice,row,column)] = value;
-	//manually inlined:
-	elements[offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]] = value;
+  //if (debug) if (slice<0 || slice>=slices || row<0 || row>=rows || column<0 || column>=columns) throw new IndexOutOfBoundsException("slice:"+slice+", row:"+row+", column:"+column);
+  //elements[index(slice,row,column)] = value;
+  //manually inlined:
+  elements[offset + sliceOffsets[sliceZero + slice*sliceStride] + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]] = value;
 }
 /**
  * Sets up a matrix with a given number of slices and rows.
  * @param slices the number of slices the matrix shall have.
  * @param rows the number of rows the matrix shall have.
  * @param columns the number of columns the matrix shall have.
- * @throws	IllegalArgumentException if <tt>(Object)rows*slices > Integer.MAX_VALUE</tt>.
+ * @throws  IllegalArgumentException if <tt>(Object)rows*slices > Integer.MAX_VALUE</tt>.
  */
 protected void setUp(int slices, int rows, int columns) {
-	super.setUp(slices,rows,columns);
-	this.sliceStride = 1;
-	this.rowStride = 1;
-	this.columnStride = 1;
-	this.offset = 0;
+  super.setUp(slices,rows,columns);
+  this.sliceStride = 1;
+  this.rowStride = 1;
+  this.columnStride = 1;
+  this.offset = 0;
 }
 /**
 Self modifying version of viewDice().
 @throws IllegalArgumentException if some of the parameters are equal or not in range 0..2.
 */
 protected AbstractMatrix3D vDice(int axis0, int axis1, int axis2) {
-	super.vDice(axis0,axis1,axis2);
-	
-	// swap offsets
-	int[][] offsets = new int[3][];
-	offsets[0] = this.sliceOffsets;
-	offsets[1] = this.rowOffsets;
-	offsets[2] = this.columnOffsets;
-
-	this.sliceOffsets = offsets[axis0];
-	this.rowOffsets = offsets[axis1];
-	this.columnOffsets = offsets[axis2];
+  super.vDice(axis0,axis1,axis2);
+  
+  // swap offsets
+  int[][] offsets = new int[3][];
+  offsets[0] = this.sliceOffsets;
+  offsets[1] = this.rowOffsets;
+  offsets[2] = this.columnOffsets;
+
+  this.sliceOffsets = offsets[axis0];
+  this.rowOffsets = offsets[axis1];
+  this.columnOffsets = offsets[axis2];
 
-	return this;
+  return this;
 }
 /**
 Constructs and returns a new 2-dimensional <i>slice view</i> representing the slices and rows of the given column.
@@ -260,22 +260,22 @@
 @see #viewRow(int)
 */
 public ObjectMatrix2D viewColumn(int column) {
-	checkColumn(column);
-	
-	int viewRows = this.slices;
-	int viewColumns = this.rows;
-	
-	int viewRowZero = sliceZero;
-	int viewColumnZero = rowZero;
-	int viewOffset = this.offset + _columnOffset(_columnRank(column));
+  checkColumn(column);
+  
+  int viewRows = this.slices;
+  int viewColumns = this.rows;
+  
+  int viewRowZero = sliceZero;
+  int viewColumnZero = rowZero;
+  int viewOffset = this.offset + _columnOffset(_columnRank(column));
 
-	int viewRowStride = this.sliceStride;
-	int viewColumnStride = this.rowStride;
+  int viewRowStride = this.sliceStride;
+  int viewColumnStride = this.rowStride;
 
-	int[] viewRowOffsets = this.sliceOffsets;
-	int[] viewColumnOffsets = this.rowOffsets;
+  int[] viewRowOffsets = this.sliceOffsets;
+  int[] viewColumnOffsets = this.rowOffsets;
 
-	return new SelectedDenseObjectMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
+  return new SelectedDenseObjectMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
 }
 /**
 Constructs and returns a new 2-dimensional <i>slice view</i> representing the slices and columns of the given row.
@@ -292,22 +292,22 @@
 @see #viewColumn(int)
 */
 public ObjectMatrix2D viewRow(int row) {
-	checkRow(row);
-	
-	int viewRows = this.slices;
-	int viewColumns = this.columns;
-	
-	int viewRowZero = sliceZero;
-	int viewColumnZero = columnZero;
-	int viewOffset = this.offset + _rowOffset(_rowRank(row));
+  checkRow(row);
+  
+  int viewRows = this.slices;
+  int viewColumns = this.columns;
+  
+  int viewRowZero = sliceZero;
+  int viewColumnZero = columnZero;
+  int viewOffset = this.offset + _rowOffset(_rowRank(row));
 
-	int viewRowStride = this.sliceStride;
-	int viewColumnStride = this.columnStride;
+  int viewRowStride = this.sliceStride;
+  int viewColumnStride = this.columnStride;
 
-	int[] viewRowOffsets = this.sliceOffsets;
-	int[] viewColumnOffsets = this.columnOffsets;
+  int[] viewRowOffsets = this.sliceOffsets;
+  int[] viewColumnOffsets = this.columnOffsets;
 
-	return new SelectedDenseObjectMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
+  return new SelectedDenseObjectMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
 }
 /**
  * Construct and returns a new selection view.
@@ -318,7 +318,7 @@
  * @return  a new view.
  */
 protected ObjectMatrix3D viewSelectionLike(int[] sliceOffsets, int[] rowOffsets, int[] columnOffsets) {
-	return new SelectedDenseObjectMatrix3D(this.elements,sliceOffsets,rowOffsets,columnOffsets,this.offset);
+  return new SelectedDenseObjectMatrix3D(this.elements,sliceOffsets,rowOffsets,columnOffsets,this.offset);
 }
 /**
 Constructs and returns a new 2-dimensional <i>slice view</i> representing the rows and columns of the given slice.
@@ -335,21 +335,21 @@
 @see #viewColumn(int)
 */
 public ObjectMatrix2D viewSlice(int slice) {
-	checkSlice(slice);
-	
-	int viewRows = this.rows;
-	int viewColumns = this.columns;
-	
-	int viewRowZero = rowZero;
-	int viewColumnZero = columnZero;
-	int viewOffset = this.offset + _sliceOffset(_sliceRank(slice));
+  checkSlice(slice);
+  
+  int viewRows = this.rows;
+  int viewColumns = this.columns;
+  
+  int viewRowZero = rowZero;
+  int viewColumnZero = columnZero;
+  int viewOffset = this.offset + _sliceOffset(_sliceRank(slice));
 
-	int viewRowStride = this.rowStride;
-	int viewColumnStride = this.columnStride;
+  int viewRowStride = this.rowStride;
+  int viewColumnStride = this.columnStride;
 
-	int[] viewRowOffsets = this.rowOffsets;
-	int[] viewColumnOffsets = this.columnOffsets;
+  int[] viewRowOffsets = this.rowOffsets;
+  int[] viewColumnOffsets = this.columnOffsets;
 
-	return new SelectedDenseObjectMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
+  return new SelectedDenseObjectMatrix2D(viewRows,viewColumns,this.elements,viewRowZero,viewColumnZero,viewRowStride,viewColumnStride,viewRowOffsets,viewColumnOffsets,viewOffset);
 }
 }

Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedSparseDoubleMatrix1D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedSparseDoubleMatrix1D.java?rev=883974&r1=883973&r2=883974&view=diff
==============================================================================
--- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedSparseDoubleMatrix1D.java (original)
+++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedSparseDoubleMatrix1D.java Wed Nov 25 03:41:28 2009
@@ -44,20 +44,20 @@
 @version 1.0, 09/24/99
 */
 class SelectedSparseDoubleMatrix1D extends DoubleMatrix1D {
-	/*
-	 * The elements of the matrix.
-	 */
-	protected AbstractIntDoubleMap elements; 
-	
-	/**
-	  * The offsets of visible indexes of this matrix.
-	  */
-	protected int[] offsets;
+  /*
+   * The elements of the matrix.
+   */
+  protected AbstractIntDoubleMap elements; 
+  
+  /**
+    * The offsets of visible indexes of this matrix.
+    */
+  protected int[] offsets;
 
-	/**
-	  * The offset.
-	  */
-	protected int offset;	
+  /**
+    * The offset.
+    */
+  protected int offset;  
 /**
  * Constructs a matrix view with the given parameters.
  * @param size the number of cells the matrix shall have.
@@ -68,12 +68,12 @@
  * @param offset   
  */
 protected SelectedSparseDoubleMatrix1D(int size, AbstractIntDoubleMap elements, int zero, int stride, int[] offsets, int offset) {
-	setUp(size,zero,stride);
-	
-	this.elements = elements;
-	this.offsets = offsets;
-	this.offset = offset;
-	this.isNoView = false;
+  setUp(size,zero,stride);
+  
+  this.elements = elements;
+  this.offsets = offsets;
+  this.offset = offset;
+  this.isNoView = false;
 }
 /**
  * Constructs a matrix view with the given parameters.
@@ -81,7 +81,7 @@
  * @param  indexes   The indexes of the cells that shall be visible.
  */
 protected SelectedSparseDoubleMatrix1D(AbstractIntDoubleMap elements, int[] offsets) {
-	this(offsets.length,elements,0,1,offsets,0);
+  this(offsets.length,elements,0,1,offsets,0);
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -91,7 +91,7 @@
  * @return the position.
  */
 protected int _offset(int absRank) {
-	return offsets[absRank];
+  return offsets[absRank];
 }
 /**
  * Returns the matrix cell value at coordinate <tt>index</tt>.
@@ -104,24 +104,24 @@
  * @return    the value of the specified cell.
  */
 public double getQuick(int index) {
-	//if (debug) if (index<0 || index>=size) checkIndex(index);
-	//return elements.get(index(index));
-	//manually inlined:
-	return elements.get(offset + offsets[zero + index*stride]);
+  //if (debug) if (index<0 || index>=size) checkIndex(index);
+  //return elements.get(index(index));
+  //manually inlined:
+  return elements.get(offset + offsets[zero + index*stride]);
 }
 /**
  * Returns <tt>true</tt> if both matrices share at least one identical cell.
  */
 protected boolean haveSharedCellsRaw(DoubleMatrix1D other) {
-	if (other instanceof SelectedSparseDoubleMatrix1D) {
-		SelectedSparseDoubleMatrix1D otherMatrix = (SelectedSparseDoubleMatrix1D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	else if (other instanceof SparseDoubleMatrix1D) {
-		SparseDoubleMatrix1D otherMatrix = (SparseDoubleMatrix1D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	return false;
+  if (other instanceof SelectedSparseDoubleMatrix1D) {
+    SelectedSparseDoubleMatrix1D otherMatrix = (SelectedSparseDoubleMatrix1D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  else if (other instanceof SparseDoubleMatrix1D) {
+    SparseDoubleMatrix1D otherMatrix = (SparseDoubleMatrix1D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  return false;
 }
 /**
  * Returns the position of the element with the given relative rank within the (virtual or non-virtual) internal 1-dimensional array.
@@ -130,9 +130,9 @@
  * @param     rank   the rank of the element.
  */
 protected int index(int rank) {
-	//return this.offset + super.index(rank);
-	// manually inlined:
-	return offset + offsets[zero + rank*stride];
+  //return this.offset + super.index(rank);
+  // manually inlined:
+  return offset + offsets[zero + rank*stride];
 }
 /**
  * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified size.
@@ -144,7 +144,7 @@
  * @return  a new empty matrix of the same dynamic type.
  */
 public DoubleMatrix1D like(int size) {
-	return new SparseDoubleMatrix1D(size);
+  return new SparseDoubleMatrix1D(size);
 }
 /**
  * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
@@ -156,7 +156,7 @@
  * @return  a new matrix of the corresponding dynamic type.
  */
 public DoubleMatrix2D like2D(int rows, int columns) {
-	return new SparseDoubleMatrix2D(rows,columns);
+  return new SparseDoubleMatrix2D(rows,columns);
 }
 /**
  * Sets the matrix cell at coordinate <tt>index</tt> to the specified value.
@@ -169,23 +169,23 @@
  * @param    value the value to be filled into the specified cell.
  */
 public void setQuick(int index, double value) {
-	//if (debug) if (index<0 || index>=size) checkIndex(index);
-	//int i =	index(index);
-	//manually inlined:
-	int i = offset + offsets[zero + index*stride];
-	if (value == 0)
-		this.elements.removeKey(i);
-	else 
-		this.elements.put(i, value);
+  //if (debug) if (index<0 || index>=size) checkIndex(index);
+  //int i =  index(index);
+  //manually inlined:
+  int i = offset + offsets[zero + index*stride];
+  if (value == 0)
+    this.elements.removeKey(i);
+  else 
+    this.elements.put(i, value);
 }
 /**
  * Sets up a matrix with a given number of cells.
  * @param size the number of cells the matrix shall have.
  */
 protected void setUp(int size) {
-	super.setUp(size);
-	this.stride = 1;
-	this.offset = 0;
+  super.setUp(size);
+  this.stride = 1;
+  this.offset = 0;
 }
 /**
  * Construct and returns a new selection view.
@@ -194,6 +194,6 @@
  * @return  a new view.
  */
 protected DoubleMatrix1D viewSelectionLike(int[] offsets) {
-	return new SelectedSparseDoubleMatrix1D(this.elements,offsets);
+  return new SelectedSparseDoubleMatrix1D(this.elements,offsets);
 }
 }

Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedSparseDoubleMatrix2D.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedSparseDoubleMatrix2D.java?rev=883974&r1=883973&r2=883974&view=diff
==============================================================================
--- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedSparseDoubleMatrix2D.java (original)
+++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/matrix/impl/SelectedSparseDoubleMatrix2D.java Wed Nov 25 03:41:28 2009
@@ -44,21 +44,21 @@
 @version 1.0, 09/24/99
 */
 class SelectedSparseDoubleMatrix2D extends DoubleMatrix2D {
-	/*
-	 * The elements of the matrix.
-	 */
-	protected AbstractIntDoubleMap elements; 
-	
-	/**
-	  * The offsets of the visible cells of this matrix.
-	  */
-	protected int[] rowOffsets;
-	protected int[] columnOffsets;
-	
-	/**
-	  * The offset.
-	  */
-	protected int offset;	
+  /*
+   * The elements of the matrix.
+   */
+  protected AbstractIntDoubleMap elements; 
+  
+  /**
+    * The offsets of the visible cells of this matrix.
+    */
+  protected int[] rowOffsets;
+  protected int[] columnOffsets;
+  
+  /**
+    * The offset.
+    */
+  protected int offset;  
 /**
  * Constructs a matrix view with the given parameters.
  * @param rows the number of rows the matrix shall have.
@@ -73,15 +73,15 @@
  * @param  offset   
  */
 protected SelectedSparseDoubleMatrix2D(int rows, int columns, AbstractIntDoubleMap elements, int rowZero, int columnZero, int rowStride, int columnStride, int[] rowOffsets, int[] columnOffsets, int offset) {
-	// be sure parameters are valid, we do not check...
-	setUp(rows,columns,rowZero,columnZero,rowStride,columnStride);
-	
-	this.elements = elements;
-	this.rowOffsets = rowOffsets;
-	this.columnOffsets = columnOffsets;
-	this.offset = offset;
-	
-	this.isNoView = false;
+  // be sure parameters are valid, we do not check...
+  setUp(rows,columns,rowZero,columnZero,rowStride,columnStride);
+  
+  this.elements = elements;
+  this.rowOffsets = rowOffsets;
+  this.columnOffsets = columnOffsets;
+  this.offset = offset;
+  
+  this.isNoView = false;
 }
 /**
  * Constructs a matrix view with the given parameters.
@@ -91,7 +91,7 @@
  * @param  offset   
  */
 protected SelectedSparseDoubleMatrix2D(AbstractIntDoubleMap elements, int[] rowOffsets, int[] columnOffsets, int offset) {
-	this(rowOffsets.length,columnOffsets.length,elements,0,0,1,1,rowOffsets,columnOffsets,offset);
+  this(rowOffsets.length,columnOffsets.length,elements,0,0,1,1,rowOffsets,columnOffsets,offset);
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -101,7 +101,7 @@
  * @return the position.
  */
 protected int _columnOffset(int absRank) {
-	return columnOffsets[absRank];
+  return columnOffsets[absRank];
 }
 /**
  * Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -111,7 +111,7 @@
  * @return the position.
  */
 protected int _rowOffset(int absRank) {
-	return rowOffsets[absRank];
+  return rowOffsets[absRank];
 }
 /**
  * Returns the matrix cell value at coordinate <tt>[row,column]</tt>.
@@ -125,10 +125,10 @@
  * @return    the value at the specified coordinate.
  */
 public double getQuick(int row, int column) {
-	//if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
-	//return elements.get(index(row,column));
-	//manually inlined:
-	return elements.get(offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]);
+  //if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
+  //return elements.get(index(row,column));
+  //manually inlined:
+  return elements.get(offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride]);
 }
 /**
  * Returns <tt>true</tt> if both matrices share common cells.
@@ -140,15 +140,15 @@
  * </ul>
  */
 protected boolean haveSharedCellsRaw(DoubleMatrix2D other) {
-	if (other instanceof SelectedSparseDoubleMatrix2D) {
-		SelectedSparseDoubleMatrix2D otherMatrix = (SelectedSparseDoubleMatrix2D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	else if (other instanceof SparseDoubleMatrix2D) {
-		SparseDoubleMatrix2D otherMatrix = (SparseDoubleMatrix2D) other;
-		return this.elements==otherMatrix.elements;
-	}
-	return false;
+  if (other instanceof SelectedSparseDoubleMatrix2D) {
+    SelectedSparseDoubleMatrix2D otherMatrix = (SelectedSparseDoubleMatrix2D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  else if (other instanceof SparseDoubleMatrix2D) {
+    SparseDoubleMatrix2D otherMatrix = (SparseDoubleMatrix2D) other;
+    return this.elements==otherMatrix.elements;
+  }
+  return false;
 }
 /**
  * Returns the position of the given coordinate within the (virtual or non-virtual) internal 1-dimensional array. 
@@ -157,9 +157,9 @@
  * @param     column   the index of the column-coordinate.
  */
 protected int index(int row, int column) {
-	//return this.offset + super.index(row,column);
-	//manually inlined:
-	return this.offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
+  //return this.offset + super.index(row,column);
+  //manually inlined:
+  return this.offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
 }
 /**
  * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of rows and columns.
@@ -172,7 +172,7 @@
  * @return  a new empty matrix of the same dynamic type.
  */
 public DoubleMatrix2D like(int rows, int columns) {
-	return new SparseDoubleMatrix2D(rows, columns);
+  return new SparseDoubleMatrix2D(rows, columns);
 }
 /**
  * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
@@ -183,7 +183,7 @@
  * @return  a new matrix of the corresponding dynamic type.
  */
 public DoubleMatrix1D like1D(int size) {
-	return new SparseDoubleMatrix1D(size);
+  return new SparseDoubleMatrix1D(size);
 }
 /**
  * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, sharing the same cells.
@@ -196,7 +196,7 @@
  * @return  a new matrix of the corresponding dynamic type.
  */
 protected DoubleMatrix1D like1D(int size, int zero, int stride) {
-	throw new InternalError(); // this method is never called since viewRow() and viewColumn are overridden properly.
+  throw new InternalError(); // this method is never called since viewRow() and viewColumn are overridden properly.
 }
 /**
  * Sets the matrix cell at coordinate <tt>[row,column]</tt> to the specified value.
@@ -210,40 +210,40 @@
  * @param    value the value to be filled into the specified cell.
  */
 public void setQuick(int row, int column, double value) {
-	//if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
-	//int index =	index(row,column);
-	//manually inlined:
-	int index = offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
+  //if (debug) if (column<0 || column>=columns || row<0 || row>=rows) throw new IndexOutOfBoundsException("row:"+row+", column:"+column);
+  //int index =  index(row,column);
+  //manually inlined:
+  int index = offset + rowOffsets[rowZero + row*rowStride] + columnOffsets[columnZero + column*columnStride];
 
-	if (value == 0)
-		this.elements.removeKey(index);
-	else 
-		this.elements.put(index, value);
+  if (value == 0)
+    this.elements.removeKey(index);
+  else 
+    this.elements.put(index, value);
 }
 /**
  * Sets up a matrix with a given number of rows and columns.
  * @param rows the number of rows the matrix shall have.
  * @param columns the number of columns the matrix shall have.
- * @throws	IllegalArgumentException if <tt>(double)columns*rows > Integer.MAX_VALUE</tt>.
+ * @throws  IllegalArgumentException if <tt>(double)columns*rows > Integer.MAX_VALUE</tt>.
  */
 protected void setUp(int rows, int columns) {
-	super.setUp(rows,columns);
-	this.rowStride = 1;
-	this.columnStride = 1;
-	this.offset = 0;
+  super.setUp(rows,columns);
+  this.rowStride = 1;
+  this.columnStride = 1;
+  this.offset = 0;
 }
 /**
 Self modifying version of viewDice().
 */
 protected AbstractMatrix2D vDice() {
-	super.vDice();
-	// swap
-	int[] tmp = rowOffsets; rowOffsets = columnOffsets; columnOffsets = tmp;
+  super.vDice();
+  // swap
+  int[] tmp = rowOffsets; rowOffsets = columnOffsets; columnOffsets = tmp;
 
-	// flips stay unaffected
+  // flips stay unaffected
 
-	this.isNoView = false;
-	return this;
+  this.isNoView = false;
+  return this;
 }
 /**
 Constructs and returns a new <i>slice view</i> representing the rows of the given column.
@@ -253,12 +253,12 @@
 <b>Example:</b> 
 <table border="0">
   <tr nowrap> 
-	<td valign="top">2 x 3 matrix: <br>
-	  1, 2, 3<br>
-	  4, 5, 6 </td>
-	<td>viewColumn(0) ==></td>
-	<td valign="top">Matrix1D of size 2:<br>
-	  1, 4</td>
+  <td valign="top">2 x 3 matrix: <br>
+    1, 2, 3<br>
+    4, 5, 6 </td>
+  <td>viewColumn(0) ==></td>
+  <td valign="top">Matrix1D of size 2:<br>
+    1, 4</td>
    </tr>
 </table>
 
@@ -268,13 +268,13 @@
 @see #viewRow(int)
 */
 public DoubleMatrix1D viewColumn(int column) {
-	checkColumn(column);
-	int viewSize = this.rows;
-	int viewZero = this.rowZero;
-	int viewStride = this.rowStride;
-	int[] viewOffsets = this.rowOffsets;
-	int viewOffset = this.offset + _columnOffset(_columnRank(column));
-	return new SelectedSparseDoubleMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
+  checkColumn(column);
+  int viewSize = this.rows;
+  int viewZero = this.rowZero;
+  int viewStride = this.rowStride;
+  int[] viewOffsets = this.rowOffsets;
+  int viewOffset = this.offset + _columnOffset(_columnRank(column));
+  return new SelectedSparseDoubleMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
 }
 /**
 Constructs and returns a new <i>slice view</i> representing the columns of the given row.
@@ -284,12 +284,12 @@
 <b>Example:</b> 
 <table border="0">
   <tr nowrap> 
-	<td valign="top">2 x 3 matrix: <br>
-	  1, 2, 3<br>
-	  4, 5, 6 </td>
-	<td>viewRow(0) ==></td>
-	<td valign="top">Matrix1D of size 3:<br>
-	  1, 2, 3</td>
+  <td valign="top">2 x 3 matrix: <br>
+    1, 2, 3<br>
+    4, 5, 6 </td>
+  <td>viewRow(0) ==></td>
+  <td valign="top">Matrix1D of size 3:<br>
+    1, 2, 3</td>
    </tr>
 </table>
 
@@ -299,13 +299,13 @@
 @see #viewColumn(int)
 */
 public DoubleMatrix1D viewRow(int row) {
-	checkRow(row);
-	int viewSize = this.columns;
-	int viewZero = columnZero;
-	int viewStride = this.columnStride;
-	int[] viewOffsets = this.columnOffsets;
-	int viewOffset = this.offset + _rowOffset(_rowRank(row));
-	return new SelectedSparseDoubleMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
+  checkRow(row);
+  int viewSize = this.columns;
+  int viewZero = columnZero;
+  int viewStride = this.columnStride;
+  int[] viewOffsets = this.columnOffsets;
+  int viewOffset = this.offset + _rowOffset(_rowRank(row));
+  return new SelectedSparseDoubleMatrix1D(viewSize,this.elements,viewZero,viewStride,viewOffsets,viewOffset);
 }
 /**
  * Construct and returns a new selection view.
@@ -315,6 +315,6 @@
  * @return  a new view.
  */
 protected DoubleMatrix2D viewSelectionLike(int[] rowOffsets, int[] columnOffsets) {
-	return new SelectedSparseDoubleMatrix2D(this.elements,rowOffsets,columnOffsets,this.offset);
+  return new SelectedSparseDoubleMatrix2D(this.elements,rowOffsets,columnOffsets,this.offset);
 }
 }



Mime
View raw message