Hi,
I'll try as you said meanwhile following is how I prototyped matrix
multiplication. Hope it'll satisfy your matrix multiplication need.
------
import org.apache.mahout.math.Matrix;
import org.apache.mahout.math.SequentialAccessSparseVector;
import org.apache.mahout.math.SparseMatrix;
import org.apache.mahout.math.Vector;
public class MatrixMult {
public static void main(String[] args) {
int n = 0;
int m = 1;
Vector vector = new SequentialAccessSparseVector(n);
Matrix matrix = new SparseMatrix(2,2);//(new int[] {2, 2});
matrix.set(0, new double[]{2.0,2.0});
matrix.set(1, new double[]{2.0,2.0});
Matrix productMatrix = matrix.times(matrix);
//Vector product = productMatrix.getColumn(0);
}
}
Regards,
On Mon, Jan 14, 2013 at 4:05 PM, Stuti Awasthi <[email protected]> wrote:
> Hi Ashish,
>
> Im running the job like this :
>
> mahout matrixmult --inputPathA --numRowsA <Rowno of MatrixA> --numColsA
> <Column no of MatrixA> --inputPathB <Inputpath of MatrixB> --numRowsB
> <Rowno of MatrixB> --numColsB <Column no of MatrixB> --tempDir
> <temporaryDir path>
>
> And getting the errors of InputFormat in mapper as mapper expects
> <TupleWritable> format. Now here Im not sure that what should be the keys
> and Value<TupleWritable> as Input to mapper to get this job working.
>
> -Stuti
>
>
> -----Original Message-----
> From: ashish negi [mailto:[email protected]]
> Sent: Monday, January 14, 2013 2:29 PM
> To: [email protected]
> Subject: Re: MatrixMultiplicationJob Input query
>
> Could you tell how are you trying to run the job?
>
> Regards,
>
> On Mon, Jan 14, 2013 at 1:42 PM, Stuti Awasthi <[email protected]>
> wrote:
>
> > Hi Ashish,
> > I tried to run the "matrixmult" example of Mahout but getting errors
> > in input format. I want to create the input file of matrix in the
> > format which is required by MatrixMultiplicationJob for further
> > processing. Im facing issues in creating that file as I have doubts
> > that what will be the key and values for the input file. Anybody's help
> will be appreciated.
> >
> > Thanks
> > Stuti
> >
> > -----Original Message-----
> > From: ashish negi [mailto:[email protected]]
> > Sent: Monday, January 14, 2013 1:04 PM
> > To: [email protected]
> > Subject: Re: MatrixMultiplicationJob Input query
> >
> > Hi Stuti,
> >
> > I am not with specific answer of your question but why don't you try
> > few examples to guess the algorithm or browse source code.
> >
> > Regards,
> > Ashish
> >
> > On Mon, Jan 14, 2013 at 12:20 PM, Stuti Awasthi <[email protected]
> > >wrote:
> >
> > > Hi,
> > > I want to execute MatrixMultiplicationJob provided in Mahout. I
> > > understand that the input file should be in SequenceFileFormat with
> > > input Key as IntWritable and Value as TupleWritable.
> > >
> > > If my matrix is 2x3 like :
> > >
> > > A = 1 2 3
> > > 4 5 6
> > >
> > > What should I keep as key and value in SequenceFileFormat so that I
> > > can provide it in MatrixMultiplicationJob as input. Sorry for the
> > > basic question but Im new to Mahout and not finding much details of
> > > MatrixMultiplicationJob execution.
> > >
> > > Thanks
> > > Stuti
> > >
> > >
> > > ::DISCLAIMER::
> > >
> > > --------------------------------------------------------------------
> > > --
> > > --------------------------------------------------------------------
> > > --
> > > --------
> > >
> > > The contents of this e-mail and any attachment(s) are confidential
> > > and intended for the named recipient(s) only.
> > > E-mail transmission is not guaranteed to be secure or error-free as
> > > information could be intercepted, corrupted, lost, destroyed, arrive
> > > late or incomplete, or may contain viruses in transmission. The e
> > > mail and its contents (with or without referred errors) shall
> > > therefore not attach any liability on the originator or HCL or its
> affiliates.
> > > Views or opinions, if any, presented in this email are solely those
> > > of the author and may not necessarily reflect the views or opinions
> > > of HCL or its affiliates. Any form of reproduction, dissemination,
> > > copying, disclosure, modification, distribution and / or publication
> > > of this message without the prior written consent of authorized
> > > representative of HCL is strictly prohibited. If you have received
> > > this email in error please delete it and notify the sender
> > > immediately.
> > > Before opening any email and/or attachments, please check them for
> > > viruses and other defects.
> > >
> > >
> > > --------------------------------------------------------------------
> > > --
> > >
> > ----------------------------------------------------------------------
> > --------
> > >
> >
>