Examples of VectorFunction


Examples of org.apache.mahout.math.function.VectorFunction

    }
  }

  @Test
  public void testAggregateCols() {
    Vector v = test.aggregateColumns(new VectorFunction() {
      @Override
      public double apply(Vector v) {
        return v.zSum();
      }
    });
View Full Code Here

Examples of org.apache.mahout.math.function.VectorFunction

  }

  @Test
  public void testAggregate() {
    double total = test.aggregate(Functions.PLUS, Functions.IDENTITY);
    assertEquals(test.aggregateRows(new VectorFunction() {
      @Override
      public double apply(Vector v) {
        return v.zSum();
      }
    }).zSum(), total, EPSILON);
View Full Code Here

Examples of org.apache.mahout.math.function.VectorFunction

    }
  }

  @Test
  public void testAggregateRows() {
    Vector v = test.aggregateRows(new VectorFunction() {
      public double apply(Vector v) {
        return v.zSum();
      }
    });
View Full Code Here

Examples of org.apache.mahout.math.function.VectorFunction

    }
  }

  @Test
  public void testAggregateCols() {
    Vector v = test.aggregateColumns(new VectorFunction() {
      public double apply(Vector v) {
        return v.zSum();
      }
    });
View Full Code Here

Examples of org.apache.mahout.math.function.VectorFunction

  }

  @Test
  public void testAggregate() {
    double total = test.aggregate(Functions.PLUS, Functions.IDENTITY);
    assertEquals(test.aggregateRows(new VectorFunction() {
      public double apply(Vector v) {
        return v.zSum();
      }
    }).zSum(), total, EPSILON);
  }
View Full Code Here

Examples of org.apache.mahout.math.function.VectorFunction

   * @param combiner A function that combines the results of the mapper.
   * @param mapper   A function to apply to each element.
   * @return The result.
   */
  public double aggregate(final BinaryFunction combiner, final UnaryFunction mapper) {
    return aggregateRows(new VectorFunction() {
      public double apply(Vector v) {
        return v.aggregate(combiner, mapper);
      }
    }).aggregate(combiner, Functions.IDENTITY);
  }
View Full Code Here

Examples of org.apache.mahout.math.function.VectorFunction

   * @param mapper   A function to apply to each element.
   * @return The result.
   */
  @Override
  public double aggregate(final DoubleDoubleFunction combiner, final DoubleFunction mapper) {
    return aggregateRows(new VectorFunction() {
      @Override
      public double apply(Vector v) {
        return v.aggregate(combiner, mapper);
      }
    }).aggregate(combiner, Functions.IDENTITY);
View Full Code Here

Examples of org.apache.mahout.math.function.VectorFunction

    }
    return new DenseMatrix(data);
  }

  private void normalize(Matrix source, final double range) {
    final double max = source.aggregateColumns(new VectorFunction() {
      @Override
      public double apply(Vector column) {
        return column.maxValue();
      }
    }).maxValue();

    final double min = source.aggregateColumns(new VectorFunction() {
      @Override
      public double apply(Vector column) {
        return column.minValue();
      }
    }).minValue();
View Full Code Here

Examples of org.apache.mahout.math.function.VectorFunction

      x.viewRow(row).assign(c.viewPart(0, 5));
      row++;
    }

    // Verify that each column looks right. Should contain zeros except for a single 6.
    final Vector columnNorms = x.aggregateColumns(new VectorFunction() {
      @Override
      public double apply(Vector f) {
        // Return the sum of three discrepancy measures.
        return Math.abs(f.minValue()) + Math.abs(f.maxValue() - 6) + Math.abs(f.norm(1) - 6);
      }
View Full Code Here

Examples of org.apache.mahout.math.function.VectorFunction

    }
  }

  @Test
  public void testAggregateRows() {
    Vector v = test.aggregateRows(new VectorFunction() {
      @Override
      public double apply(Vector v) {
        return v.zSum();
      }
    });
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.