Repository: mahout
Updated Branches:
  refs/heads/master 63b765abb -> 99fd9ba4f


MAHOUT-1575 - Allow 2 extra passes for conjugate gradient


Project: http://git-wip-us.apache.org/repos/asf/mahout/repo
Commit: http://git-wip-us.apache.org/repos/asf/mahout/commit/99fd9ba4
Tree: http://git-wip-us.apache.org/repos/asf/mahout/tree/99fd9ba4
Diff: http://git-wip-us.apache.org/repos/asf/mahout/diff/99fd9ba4

Branch: refs/heads/master
Commit: 99fd9ba4f9673b2b2d30c2b403aaa294503cc2a2
Parents: 63b765a
Author: Ted Dunning <[email protected]>
Authored: Sat Jun 7 15:09:10 2014 -0700
Committer: Ted Dunning <[email protected]>
Committed: Sat Jun 7 15:09:10 2014 -0700

----------------------------------------------------------------------
 .../mahout/math/solver/ConjugateGradientSolver.java      | 11 ++++++-----
 .../solver/DistributedConjugateGradientSolver.java       |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mahout/blob/99fd9ba4/math/src/main/java/org/apache/mahout/math/solver/ConjugateGradientSolver.java
----------------------------------------------------------------------
diff --git 
a/math/src/main/java/org/apache/mahout/math/solver/ConjugateGradientSolver.java 
b/math/src/main/java/org/apache/mahout/math/solver/ConjugateGradientSolver.java
index a530ad7..02bde9b 100644
--- 
a/math/src/main/java/org/apache/mahout/math/solver/ConjugateGradientSolver.java
+++ 
b/math/src/main/java/org/apache/mahout/math/solver/ConjugateGradientSolver.java
@@ -31,9 +31,10 @@ import org.slf4j.LoggerFactory;
  * standard conjugate gradient and pre-conditioned conjugate gradient. 
  * 
  * <p>Conjugate gradient requires the matrix A in the linear system Ax = b to 
be symmetric and positive
- * definite. For convenience, this implementation allows the input matrix to 
be be non-symmetric, in
- * which case the system A'Ax = b is solved. Because this requires only one 
pass through the matrix A, it
- * is faster than explicitly computing A'A, then passing the results to the 
solver.
+ * definite. For convenience, this implementation could be extended relatively 
easily to handle the
+ * case where the input matrix to be be non-symmetric, in which case the 
system A'Ax = b would be solved.
+ * Because this requires only one pass through the matrix A, it is faster than 
explicitly computing A'A,
+ * then passing the results to the solver.
  * 
  * <p>For inputs that may be ill conditioned (often the case for highly sparse 
input), this solver
  * also accepts a parameter, lambda, which adds a scaled identity to the 
matrix A, solving the system
@@ -79,7 +80,7 @@ public class ConjugateGradientSolver {
    * 
    */
   public Vector solve(VectorIterable a, Vector b) {
-    return solve(a, b, null, b.size(), DEFAULT_MAX_ERROR);
+    return solve(a, b, null, b.size() + 2, DEFAULT_MAX_ERROR);
   }
   
   /**
@@ -96,7 +97,7 @@ public class ConjugateGradientSolver {
    * 
    */
   public Vector solve(VectorIterable a, Vector b, Preconditioner precond) {
-    return solve(a, b, precond, b.size(), DEFAULT_MAX_ERROR);
+    return solve(a, b, precond, b.size() + 2, DEFAULT_MAX_ERROR);
   }
   
 

http://git-wip-us.apache.org/repos/asf/mahout/blob/99fd9ba4/mrlegacy/src/main/java/org/apache/mahout/math/hadoop/solver/DistributedConjugateGradientSolver.java
----------------------------------------------------------------------
diff --git 
a/mrlegacy/src/main/java/org/apache/mahout/math/hadoop/solver/DistributedConjugateGradientSolver.java
 
b/mrlegacy/src/main/java/org/apache/mahout/math/hadoop/solver/DistributedConjugateGradientSolver.java
index c641746..d6ebf16 100644
--- 
a/mrlegacy/src/main/java/org/apache/mahout/math/hadoop/solver/DistributedConjugateGradientSolver.java
+++ 
b/mrlegacy/src/main/java/org/apache/mahout/math/hadoop/solver/DistributedConjugateGradientSolver.java
@@ -93,7 +93,7 @@ public class DistributedConjugateGradientSolver extends 
ConjugateGradientSolver
     int numCols = Integer.parseInt(AbstractJob.getOption(parsedArgs, 
"--numCols"));
     int maxIterations = parsedArgs.containsKey("--maxIter")
         ? Integer.parseInt(AbstractJob.getOption(parsedArgs, "--maxIter"))
-        : numCols;
+        : numCols + 2;
     double maxError = parsedArgs.containsKey("--maxError") 
         ? Double.parseDouble(AbstractJob.getOption(parsedArgs, "--maxError"))
         : ConjugateGradientSolver.DEFAULT_MAX_ERROR;

Reply via email to