MAHOUT-1696: QRDecomposition.solve(...) can return incorrect Matrix types. closes apache/mahout#124
Project: http://git-wip-us.apache.org/repos/asf/mahout/repo Commit: http://git-wip-us.apache.org/repos/asf/mahout/commit/1f9188d0 Tree: http://git-wip-us.apache.org/repos/asf/mahout/tree/1f9188d0 Diff: http://git-wip-us.apache.org/repos/asf/mahout/diff/1f9188d0 Branch: refs/heads/mahout-0.10.x Commit: 1f9188d0789640a6514e1120bf4b44061a886165 Parents: ec43b57 Author: Andrew Palumbo <[email protected]> Authored: Fri Apr 24 19:33:41 2015 -0400 Committer: Andrew Palumbo <[email protected]> Committed: Fri Apr 24 19:33:41 2015 -0400 ---------------------------------------------------------------------- CHANGELOG | 2 ++ math/src/main/java/org/apache/mahout/math/QRDecomposition.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mahout/blob/1f9188d0/CHANGELOG ---------------------------------------------------------------------- diff --git a/CHANGELOG b/CHANGELOG index 05a62cb..dc5d298 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,8 @@ Mahout Change Log Release 0.10.1 - unreleased + MAHOUT-1696: QRDecomposition.solve(...) can return incorrect Matrix types (apalumbo) + MAHOUT-1690: CLONE - Some vector dumper flags are expecting arguments. (smarthi) MAHOUT-1693: FunctionalMatrixView materializes row vectors in scala shell (apalumbo) http://git-wip-us.apache.org/repos/asf/mahout/blob/1f9188d0/math/src/main/java/org/apache/mahout/math/QRDecomposition.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/QRDecomposition.java b/math/src/main/java/org/apache/mahout/math/QRDecomposition.java index 5a3d918..db7f8d6 100644 --- a/math/src/main/java/org/apache/mahout/math/QRDecomposition.java +++ b/math/src/main/java/org/apache/mahout/math/QRDecomposition.java @@ -42,6 +42,7 @@ import java.util.Locale; public class QRDecomposition implements QR { private final Matrix q; private final Matrix r; + private final Matrix mType; private final boolean fullRank; private final int rows; private final int columns; @@ -59,6 +60,7 @@ public class QRDecomposition implements QR { rows = a.rowSize(); int min = Math.min(a.rowSize(), a.columnSize()); columns = a.columnSize(); + mType = a.like(1,1); Matrix qTmp = a.clone(); @@ -147,7 +149,7 @@ public class QRDecomposition implements QR { } int cols = B.numCols(); - Matrix x = B.like(columns, cols); + Matrix x = mType.like(columns, cols); // this can all be done a bit more efficiently if we don't actually // form explicit versions of Q^T and R but this code isn't so bad
