Package org.apache.mahout.math

Examples of org.apache.mahout.math.RandomAccessSparseVector.assign()


  }

  @Test
  public void testMatrixTimesSquaredVector() throws Exception {
    Vector v = new RandomAccessSparseVector(50);
    v.assign(1.0);
    Matrix m = SolverTest.randomSequentialAccessSparseMatrix(100, 90, 50, 20, 1.0);
    DistributedRowMatrix dm = randomDistributedMatrix(100, 90, 50, 20, 1.0, false);

    Vector expected = m.timesSquared(v);
    Vector actual = dm.timesSquared(v);
View Full Code Here


    Path baseTmpDirPath = getTestTempDirPath("testpaths");   
    Path inputPath = new Path(baseTmpDirPath, "input");
    Path outputPath = new Path(baseTmpDirPath, "output");

    Vector v = new RandomAccessSparseVector(50);
    v.assign(1.0);

    Configuration timesSquaredJobConf1 = TimesSquaredJob.createTimesSquaredJobConf(v, inputPath, outputPath);
    Configuration customTimesSquaredJobConf1 = TimesSquaredJob.createTimesSquaredJobConf(initialConf, v, inputPath, outputPath);

    assertNull(timesSquaredJobConf1.get(TEST_PROPERTY_KEY));
View Full Code Here

 
  @Test
  public void testTimesVectorTempDirDeletion() throws Exception {
    Configuration conf = new Configuration();
    Vector v = new RandomAccessSparseVector(50);
    v.assign(1.0);
    DistributedRowMatrix dm = randomDistributedMatrix(100, 90, 50, 20, 1.0, false);

    Path outputPath = dm.getOutputTempPath();
    FileSystem fs = outputPath.getFileSystem(conf);
View Full Code Here

  @Test
  public void testTimesSquaredVectorTempDirDeletion() throws Exception {
    Configuration conf = new Configuration();
    Vector v = new RandomAccessSparseVector(50);
    v.assign(1.0);
    DistributedRowMatrix dm = randomDistributedMatrix(100, 90, 50, 20, 1.0, false);

    Path outputPath = dm.getOutputTempPath();
    FileSystem fs = outputPath.getFileSystem(conf);
View Full Code Here

  public static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = new ArrayList<VectorWritable>();
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
View Full Code Here

 
  public static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
 
View Full Code Here

 
  private static List<VectorWritable> getPoints() {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : RAW) {
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
View Full Code Here

  private static List<VectorWritable> getPoints() {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : RAW) {
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
View Full Code Here

  private static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
View Full Code Here

      context = DummyRecordWriter.build(mapper, conf, writer);
   
    // perform the mapping
    for (int i = 0; i < RAW_DIMENSIONS; i++) {
      RandomAccessSparseVector toAdd = new RandomAccessSparseVector(RAW_DIMENSIONS);
      toAdd.assign(RAW[i]);
      mapper.map(new IntWritable(i), new VectorWritable(toAdd), context);
    }
   
    // check the number of the results
    assertEquals("Number of map results", RAW_DIMENSIONS,
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.