public double apply(int i, int j, double value) { return function.apply(value); } }
public double apply(int i, int j, double value) { return function.apply(value); } }
public boolean apply(int key, double value) { put(key,function.apply(value)); return true; } }
public boolean apply(int key, double value) { put(key, function.apply(value)); return true; } });
public boolean apply(int key, double value) { put(key,function.apply(value)); return true; } }
public final double apply(double a, double b) { return g.apply(h.apply(a,b)); } };
public final double apply(double a, double b) { return g.apply(h.apply(a,b)); } };
/** Assigns the result of a function to each value; <tt>v[i] = function(v[i])</tt>. @param function a function object taking as argument the current association's value. */ public void assign(cern.colt.function.DoubleFunction function) { // specialization for speed if (function instanceof cern.jet.math.Mult) { // x[i] = mult*x[i] double multiplicator = ((cern.jet.math.Mult)function).multiplicator; if (multiplicator==1) return; if (multiplicator==0) { clear(); return; } for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL) values[i] *= multiplicator; } } else { // the general case x[i] = f(x[i]) for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL) values[i] = function.apply(values[i]); } } } /**
/** Assigns the result of a function to each value; <tt>v[i] = function(v[i])</tt>. @param function a function object taking as argument the current association's value. */ public void assign(cern.colt.function.DoubleFunction function) { // specialization for speed if (function instanceof cern.jet.math.Mult) { // x[i] = mult*x[i] double multiplicator = ((cern.jet.math.Mult)function).multiplicator; if (multiplicator==1) return; if (multiplicator==0) { clear(); return; } for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL) values[i] *= multiplicator; } } else { // the general case x[i] = f(x[i]) for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL) values[i] = function.apply(values[i]); } } } /**
/** * Assigns the result of a function to each value; * <tt>v[i] = function(v[i])</tt>. * * @param function * a function object taking as argument the current association's * value. */ public void assign(cern.colt.function.DoubleFunction function) { // specialization for speed if (function instanceof cern.jet.math.Mult) { // x[i] = mult*x[i] double multiplicator = ((cern.jet.math.Mult) function).multiplicator; if (multiplicator == 1) return; if (multiplicator == 0) { clear(); return; } for (int i = table.length; i-- > 0;) { if (state[i] == FULL) values[i] *= multiplicator; } } else { // the general case x[i] = f(x[i]) for (int i = table.length; i-- > 0;) { if (state[i] == FULL) values[i] = function.apply(values[i]); } } }
elems[i] = function.apply(elems[i]); i += s;
elems[i] = function.apply(elems[i]); i += s;
/** * Demonstrates usage of this class. */ public static void demo1() { cern.jet.math.Functions F = cern.jet.math.Functions.functions; double a = 0.5; double b = 0.2; double v = Math.sin(a) + Math.pow(Math.cos(b),2); System.out.println(v); DoubleDoubleFunction f = F.chain(F.plus,F.sin,F.chain(F.square,F.cos)); //DoubleDoubleFunction f = F.chain(plus,sin,F.chain(square,cos)); 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)); } /**
/** * Demonstrates usage of this class. */ public static void demo1() { cern.jet.math.Functions F = cern.jet.math.Functions.functions; double a = 0.5; double b = 0.2; double v = Math.sin(a) + Math.pow(Math.cos(b),2); System.out.println(v); DoubleDoubleFunction f = F.chain(F.plus,F.sin,F.chain(F.square,F.cos)); //DoubleDoubleFunction f = F.chain(plus,sin,F.chain(square,cos)); 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)); } /**
/** Applies a function to each cell and aggregates the results. Returns a value <tt>v</tt> such that <tt>v==a(size())</tt> where <tt>a(i) == aggr( a(i-1), f(get(i)) )</tt> and terminators are <tt>a(1) == f(get(0)), a(0)==Double.NaN</tt>. <p> <b>Example:</b> <pre> cern.jet.math.Functions F = cern.jet.math.Functions.functions; matrix = 0 1 2 3 // Sum( x[i]*x[i] ) matrix.aggregate(F.plus,F.square); --> 14 </pre> For further examples, see the <a href="package-summary.html#FunctionObjects">package doc</a>. @param aggr an aggregation function taking as first argument the current aggregation and as second argument the transformed current cell value. @param f a function transforming the current cell value. @return the aggregated measure. @see cern.jet.math.Functions */ public double aggregate(cern.colt.function.DoubleDoubleFunction aggr, cern.colt.function.DoubleFunction f) { if (size==0) return Double.NaN; double a = f.apply(getQuick(size-1)); for (int i=size-1; --i >= 0; ) { a = aggr.apply(a, f.apply(getQuick(i))); } return a; } /**
/** Applies a function to each cell and aggregates the results. Returns a value <tt>v</tt> such that <tt>v==a(size())</tt> where <tt>a(i) == aggr( a(i-1), f(get(i)) )</tt> and terminators are <tt>a(1) == f(get(0)), a(0)==Double.NaN</tt>. <p> <b>Example:</b> <pre> cern.jet.math.Functions F = cern.jet.math.Functions.functions; matrix = 0 1 2 3 // Sum( x[i]*x[i] ) matrix.aggregate(F.plus,F.square); --> 14 </pre> For further examples, see the <a href="package-summary.html#FunctionObjects">package doc</a>. @param aggr an aggregation function taking as first argument the current aggregation and as second argument the transformed current cell value. @param f a function transforming the current cell value. @return the aggregated measure. @see cern.jet.math.Functions */ public double aggregate(cern.colt.function.DoubleDoubleFunction aggr, cern.colt.function.DoubleFunction f) { if (size==0) return Double.NaN; double a = f.apply(getQuick(size-1)); for (int i=size-1; --i >= 0; ) { a = aggr.apply(a, f.apply(getQuick(i))); } return a; } /**