Package cern.colt.function

Examples of cern.colt.function.DoubleFunction


System.out.println(matrix.aggregate(F.mult,F.identity));
//--> 0

// Product( x[i] ) of all x[i] > limit
final double limit = 1;
DoubleFunction f = new DoubleFunction() {
  public final double apply(double a) { return a>limit ? a : 1; }
};
System.out.println(matrix.aggregate(F.mult,f));
//--> 6
View Full Code Here


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

*
* @param function a binary function taking operands in the form <tt>function.apply(c,var)</tt>.
* @return the unary function <tt>function(c,var)</tt>.
*/
public static DoubleFunction bindArg1(final DoubleDoubleFunction function, final double c) {
  return new DoubleFunction() {
    public final double apply(double var) { return function.apply(c,var); }
  };
}
View Full Code Here

*
* @param function a binary function taking operands in the form <tt>function.apply(var,c)</tt>.
* @return the unary function <tt>function(var,c)</tt>.
*/
public static DoubleFunction bindArg2(final DoubleDoubleFunction function, final double c) {
  return new DoubleFunction() {
    public final double apply(double var) { return function.apply(var,c); }
  };
}
View Full Code Here

* @param g a unary function.
* @param h a unary function.
* @return the unary function <tt>g( h(a) )</tt>.
*/
public static DoubleFunction chain(final DoubleFunction g, final DoubleFunction h) {
  return new DoubleFunction() {
    public final double apply(double a) { return g.apply(h.apply(a)); }
  };
}
View Full Code Here

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

}
/**
* Constructs a function that returns the constant <tt>c</tt>.
*/
public static DoubleFunction constant(final double c) {
  return new DoubleFunction() {
    public final double apply(double a) { return c; }
  };
}
View Full Code Here

  System.out.println(f.apply(a,b));
  DoubleDoubleFunction g = new DoubleDoubleFunction() {
    public final double apply(double x, double y) { return Math.sin(x) + Math.pow(Math.cos(y),2); }
  };
  System.out.println(g.apply(a,b));
  DoubleFunction m = F.plus(3);
  DoubleFunction n = F.plus(4);
  System.out.println(m.apply(0));
  System.out.println(n.apply(0));
}
View Full Code Here

/**
* 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 equals(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>a > b ? 1 : 0</tt>.
* <tt>a</tt> is a variable, <tt>b</tt> is fixed.
*/
public static DoubleFunction greater(final double b) {
  return new DoubleFunction() {
    public final double apply(double a) { return a > b ? 1 : 0; }
  };
}
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.