mirror of https://github.com/apache/lucene.git
SOLR-13146: Allow derivatives to be computed for the oscillate Stream Evaluator
This commit is contained in:
parent
571ae2670a
commit
28953a3afc
|
@ -44,14 +44,17 @@ public class OscillateEvaluator extends RecursiveNumericEvaluator implements Man
|
|||
|
||||
|
||||
HarmonicOscillator pf = new HarmonicOscillator(amp, om, phase);
|
||||
double[] x = new double[128];
|
||||
|
||||
List list = new ArrayList();
|
||||
for(int i=0; i<128; i++) {
|
||||
double yvalue= pf.value(i);
|
||||
list.add(yvalue);
|
||||
x[i] = i;
|
||||
}
|
||||
|
||||
return new VectorFunction(pf, list);
|
||||
|
||||
VectorFunction func = new VectorFunction(pf, list);
|
||||
func.addToContext("x", x);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2782,7 +2782,8 @@ public class MathExpressionTest extends SolrCloudTestCase {
|
|||
" e=harmfit(a)," +
|
||||
" f=getAmplitude(e)," +
|
||||
" g=getAngularFrequency(e)," +
|
||||
" h=getPhase(e))";
|
||||
" h=getPhase(e)," +
|
||||
" i=derivative(a))";
|
||||
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
|
||||
paramsLoc.set("expr", cexpr);
|
||||
paramsLoc.set("qt", "/stream");
|
||||
|
@ -2810,6 +2811,11 @@ public class MathExpressionTest extends SolrCloudTestCase {
|
|||
assertEquals(amp.doubleValue(), 10, .1);
|
||||
assertEquals(freq.doubleValue(), .3, .1);
|
||||
assertEquals(pha.doubleValue(), 2.9, .1);
|
||||
|
||||
List<Number> der = (List<Number>)tuples.get(0).get("i");
|
||||
assertEquals(der.size(), 128);
|
||||
assertEquals(der.get(0).doubleValue(), -0.7177479876419472, 0);
|
||||
assertEquals(der.get(127).doubleValue(), 0.47586800641412696, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue