Package cern.colt.function

Examples of cern.colt.function.DoubleFunction


/**
* Constructs a function that returns <tt>a < b ? 1 : 0</tt>.
* <tt>a</tt> is a variable, <tt>b</tt> is fixed.
*/
public static DoubleFunction less(final double b) {
  return new DoubleFunction() {
    public final double apply(double a) { return a < b ? 1 : 0; }
  };
}
View Full Code Here


/**
* Constructs a function that returns <tt><tt>Math.log(a) / Math.log(b)</tt></tt>.
* <tt>a</tt> is a variable, <tt>b</tt> is fixed.
*/
public static DoubleFunction lg(final double b) {
  return new DoubleFunction() {
    private final double logInv = 1 / Math.log(b); // cached for speed
    public final double apply(double a) { return Math.log(a) * logInv; }
  };
}
View Full Code Here

/**
* Constructs a function that returns <tt>Math.max(a,b)</tt>.
* <tt>a</tt> is a variable, <tt>b</tt> is fixed.
*/
public static DoubleFunction max(final double b) {
  return new DoubleFunction() {
    public final double apply(double a) { return Math.max(a,b); }
  };
}
View Full Code Here

/**
* Constructs a function that returns <tt>Math.min(a,b)</tt>.
* <tt>a</tt> is a variable, <tt>b</tt> is fixed.
*/
public static DoubleFunction min(final double b) {
  return new DoubleFunction() {
    public final double apply(double a) { return Math.min(a,b); }
  };
}
View Full Code Here

/**
* Constructs a function that returns <tt>a % b</tt>.
* <tt>a</tt> is a variable, <tt>b</tt> is fixed.
*/
public static DoubleFunction mod(final double b) {
  return new DoubleFunction() {
    public final double apply(double a) { return a % b; }
  };
}
View Full Code Here

/**
* Constructs a function that returns <tt>a + b</tt>.
* <tt>a</tt> is a variable, <tt>b</tt> is fixed.
*/
public static DoubleFunction plus(final double b) {
  return new DoubleFunction() {
    public final double apply(double a) { return a + b; }
  };
}
View Full Code Here

/**
* Constructs a function that returns <tt>Math.pow(a,b)</tt>.
* <tt>a</tt> is a variable, <tt>b</tt> is fixed.
*/
public static DoubleFunction pow(final double b) {
  return new DoubleFunction() {
    public final double apply(double a) { return Math.pow(a,b); }
  };
}
View Full Code Here

* precision = 0.01 rounds 0.012 --> 0.01, 0.018 --> 0.02
* precision = 10   rounds 123   --> 120 , 127   --> 130
* </pre>
*/
public static DoubleFunction round(final double precision) {
  return new DoubleFunction() {
    public final double apply(double a) { return Math.rint(a/precision)*precision; }
  };
}
View Full Code Here

  protected final DoubleFunction randomGenerator;
  protected final int size;
 
  public TestSolverRandomly(final Random conf, int s) {
    size = s;
    randomGenerator = new DoubleFunction() {
      private final Random rnd = conf;
     
      public double apply(double argument) {
        return rnd.nextDouble()*10;
      }
 
View Full Code Here

 
  @Test
  public final void testMediumSizeSparseMatrix_takes_35sec()
  {
    final int size=1500;//(int)Math.sqrt(Integer.MAX_VALUE)-1;
    DoubleFunction randomGenerator = new DoubleFunction() {
      private final Random rnd = new Random(0);
     
      public double apply(@SuppressWarnings("unused"double argument) {
        return rnd.nextDouble()*10;
      }
 
View Full Code Here

TOP

Related Classes of cern.colt.function.DoubleFunction

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.