mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jman...@apache.org
Subject svn commit: r905927 - in /lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math: DenseVector.java RandomAccessSparseVector.java SequentialAccessSparseVector.java
Date Wed, 03 Feb 2010 08:06:02 GMT
Author: jmannix
Date: Wed Feb  3 08:05:57 2010
New Revision: 905927

URL: http://svn.apache.org/viewvc?rev=905927&view=rev
Log:
Copy constructors with the option of shallow copy.  Nice for wrapping a vector in a writable
subclass, for example.

Modified:
    lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/DenseVector.java
    lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java
    lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SequentialAccessSparseVector.java

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/DenseVector.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/DenseVector.java?rev=905927&r1=905926&r2=905927&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/DenseVector.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/DenseVector.java Wed Feb
 3 08:05:57 2010
@@ -46,6 +46,10 @@
     this.values = shallowCopy ? values : values.clone();
   }
 
+  public DenseVector(DenseVector values, boolean shallowCopy) {
+    this(values.values, shallowCopy);
+  }
+
   public DenseVector(String name, double[] values) {
     super(name);
     this.values = values.clone();

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java?rev=905927&r1=905926&r2=905927&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java
(original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/RandomAccessSparseVector.java
Wed Feb  3 08:05:57 2010
@@ -63,6 +63,11 @@
     }
   }
 
+  public RandomAccessSparseVector(RandomAccessSparseVector other, boolean shallowCopy) {
+    super(other.getName(), other.size());
+    values = shallowCopy ? other.values : (OpenIntDoubleHashMap)other.values.clone() ;
+  }
+
   @Override
   protected Matrix matrixLike(int rows, int columns) {
     int[] cardinality = {rows, columns};

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SequentialAccessSparseVector.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SequentialAccessSparseVector.java?rev=905927&r1=905926&r2=905927&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SequentialAccessSparseVector.java
(original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SequentialAccessSparseVector.java
Wed Feb  3 08:05:57 2010
@@ -59,6 +59,11 @@
     }
   }
 
+  public SequentialAccessSparseVector(SequentialAccessSparseVector other, boolean shallowCopy)
{
+    super(other.getName(), other.size());
+    values = shallowCopy ? other.values : other.values.clone();
+  }
+
   public SequentialAccessSparseVector(SequentialAccessSparseVector other) {
     this(other.getName(), other.size(), other.getNumNondefaultElements());
     values = other.values.clone();



Mime
View raw message