Perhaps the command-line help could mention this? Since it is an obvious confusion factor?
----- Original Message ----- | From: "Sebastian Schelter (JIRA)" <[email protected]> | To: [email protected] | Sent: Tuesday, September 25, 2012 11:06:07 PM | Subject: [jira] [Resolved] (MAHOUT-1078) matrixmult gives wrong answer | | | [ | https://issues.apache.org/jira/browse/MAHOUT-1078?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel | ] | | Sebastian Schelter resolved MAHOUT-1078. | ---------------------------------------- | | Resolution: Not A Problem | | As one commenter already said, matrixmult computes A'B not AB. | | > matrixmult gives wrong answer | > ----------------------------- | > | > Key: MAHOUT-1078 | > URL: | > https://issues.apache.org/jira/browse/MAHOUT-1078 | > Project: Mahout | > Issue Type: Bug | > Components: Math | > Affects Versions: 0.7 | > Reporter: Paul Hubenig | > | > Create a simple matrix: | > 1 2 | > 3 4 | > package exp | > import org.apache.hadoop.conf.Configuration | > import org.apache.hadoop.fs.Path | > import org.apache.hadoop.io.{IOUtils, IntWritable, SequenceFile} | > import org.apache.mahout.math.{SequentialAccessSparseVector, | > VectorWritable, RandomAccessSparseVector} | > object MakeMatrix extends App with CommonMethods { | > val matrixFileOutput = "/Users/phubenig/matrixFile.sf" | > val conf = new Configuration() | > val fs = getFileSystem(true, conf) | > val path = new Path(matrixFileOutput) | > val arr = Array(Array(1, 2), Array(3, 4)) | > val rank = 2 | > val key = new org.apache.hadoop.io.IntWritable() | > val writer = SequenceFile.createWriter(fs, conf, path, | > classOf[IntWritable], classOf[VectorWritable]) | > for (i <- 0 until rank) { | > key.set(i) | > val v = new SequentialAccessSparseVector(rank) | > for (j <- 0 until rank) { | > v.setQuick(j, arr(i)(j)) | > } | > writer.append(key, new VectorWritable(v)) | > } | > IOUtils.closeStream(writer) | > } | > Engage mahout to square this matrix. | > $ mahout matrixmult --numRowsA 2 --numColsA 2 --numRowsB 2 | > --numColsB 2 --inputPathA matrixFile.sf --inputPathB matrixFile.sf | > Read back the result: | > I get the answer:?? | > (0, 0): 10.0 | > (0, 1): 14.0 | > (1, 0): 14.0 | > (1, 1): 20.0 | > i.e., | > 10 14 | > 14 20 | > Correct answer?? | > 1 2 1 2 7 10 | > x = | > 3 4 3 4 15 22 | > I tried mahout transpose and that seems to work. | > Am I specifying the matrix wrong somehow? | > 10 =|(1, 3)| * |(1,3)| | > 20 =|(2,4)| * |(2,4)| | > 14 = (1,3) , (2,4) | > but why is it doing this? | > Instead of two vectors in the matrix creation program, I also tried | > one vector consisting of: (1, 2, 3, 4) - matrixmult also give the | > wrong answer. | > Regardless of convention used (???) that I don't understand, here | > is no documentation and no error checking. | | -- | This message is automatically generated by JIRA. | If you think it was sent incorrectly, please contact your JIRA | administrators | For more information on JIRA, see: | http://www.atlassian.com/software/jira |
