Package org.apache.mahout.clustering.spectral.VectorMatrixMultiplicationJob

Examples of org.apache.mahout.clustering.spectral.VectorMatrixMultiplicationJob.VectorMatrixMultiplicationMapper


  private static final double [][] MATRIX = { {1, 1}, {2, 3} };
  private static final double [] VECTOR = {9, 16};
 
  @Test
  public void testVectorMatrixMultiplicationMapper() throws Exception {
    VectorMatrixMultiplicationMapper mapper = new VectorMatrixMultiplicationMapper();
    Configuration conf = getConfiguration();
   
    // set up all the parameters for the job
    Vector toSave = new DenseVector(VECTOR);
    DummyRecordWriter<IntWritable, VectorWritable> writer = new
      DummyRecordWriter<IntWritable, VectorWritable>();
    Mapper<IntWritable, VectorWritable, IntWritable, VectorWritable>.Context
      context = DummyRecordWriter.build(mapper, conf, writer);
    mapper.setup(toSave);
   
    // run the job
    for (int i = 0; i < MATRIX.length; i++) {
      Vector v = new RandomAccessSparseVector(MATRIX[i].length);
      v.assign(MATRIX[i]);
      mapper.map(new IntWritable(i), new VectorWritable(v), context);
    }
   
    // check the results
    assertEquals("Number of map results", MATRIX.length, writer.getData().size());
    for (int i = 0; i < MATRIX.length; i++) {
View Full Code Here

TOP

Related Classes of org.apache.mahout.clustering.spectral.VectorMatrixMultiplicationJob.VectorMatrixMultiplicationMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.