Package org.apache.mahout.math.function

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


   * @param g a unary function.
   * @param h a binary function.
   * @return the unary function <tt>g( h(a,b) )</tt>.
   */
  public static IntIntFunction chain(final IntFunction g, final IntIntFunction h) {
    return new IntIntFunction() {

      public int apply(int a, int b) {
        return g.apply(h.apply(a, b));
      }
    };
View Full Code Here


   * @param g a unary function.
   * @param h a unary function.
   * @return the binary function <tt>f( g(a), h(b) )</tt>.
   */
  public static IntIntFunction chain(final IntIntFunction f, final IntFunction g, final IntFunction h) {
    return new IntIntFunction() {

      public int apply(int a, int b) {
        return f.apply(g.apply(a), h.apply(b));
      }
    };
View Full Code Here

public class MatricesTest extends MahoutTestCase {

  @Test
  public void testFunctionalView() {
    Matrix m = Matrices.functionalMatrixView(5, 6, new IntIntFunction() {
      @Override
      public double apply(int row, int col) {
        assertTrue(row < 5);
        assertTrue(col < 6);
        return row + col;
View Full Code Here

   *
   * @param m original matrix
   * @return transposed view of original matrix
   */
  public static final Matrix transposedView(final Matrix m) {
    IntIntFunction tf = new IntIntFunction() {
      @Override
      public double apply(int row, int col) {
        return m.getQuick(col, row);
      }
    };
View Full Code Here

   * @param seed The seed for the matrix.
   * @return Gaussian {@link IntIntFunction} generating matrix view with normal values
   */
  public static final IntIntFunction gaussianGenerator(final long seed) {
    final Random rnd = RandomUtils.getRandom(seed);
    IntIntFunction gaussianGF = new IntIntFunction() {
      @Override
      public double apply(int first, int second) {
        rnd.setSeed(seed ^ (((long) first << 32) | (second & 0xffffffffl)));
        return rnd.nextGaussian();
      }
View Full Code Here

   *
   * @param seed
   * @return Uniform {@link IntIntFunction} generator
   */
  public static final IntIntFunction uniformSymmetricGenerator(final int seed) {
    return new IntIntFunction() {
      private byte[] data = new byte[8];

      @Override
      public double apply(int row, int column) {
        long d = ((long) row << Integer.SIZE) | (column & 0xffffffffl);
View Full Code Here

public class MatricesTest extends MahoutTestCase {

  @Test
  public void testFunctionalView() {
    Matrix m = Matrices.functionalMatrixView(5, 6, new IntIntFunction() {
      @Override
      public double apply(int row, int col) {
        assertTrue(row < 5);
        assertTrue(col < 6);
        return row + col;
View Full Code Here

   *
   * @param m original matrix
   * @return transposed view of original matrix
   */
  public static final Matrix transposedView(final Matrix m) {
    IntIntFunction tf = new IntIntFunction() {
      @Override
      public double apply(int row, int col) {
        return m.getQuick(col, row);
      }
    };
View Full Code Here

   * @param seed The seed for the matrix.
   * @return Gaussian {@link IntIntFunction} generating matrix view with normal values
   */
  public static final IntIntFunction gaussianGenerator(final long seed) {
    final Random rnd = RandomUtils.getRandom(seed);
    IntIntFunction gaussianGF = new IntIntFunction() {
      @Override
      public double apply(int first, int second) {
        rnd.setSeed(seed ^ (((long) first << 32) | (second & 0xffffffffl)));
        return rnd.nextGaussian();
      }
View Full Code Here

   *
   * @param seed
   * @return Uniform {@link IntIntFunction} generator
   */
  public static final IntIntFunction uniformSymmetricGenerator(final int seed) {
    return new IntIntFunction() {
      private byte[] data = new byte[8];

      @Override
      public double apply(int row, int column) {
        long d = ((long) row << Integer.SIZE) | (column & 0xffffffffl);
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.function.IntIntFunction

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.