commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <>
Subject Re: [nabla] INVOKEVIRTUAL not handled yet
Date Sat, 08 Oct 2011 21:42:29 GMT
On 10/8/11 2:24 PM, Luc Maisonobe wrote:
> Phil Steitz <> a écrit :
>> I am getting RTE with message above when I try to run the example
>> under "updating the base and differentiated objects" in the docs. 
>> Is this example supposed to work with the code in trunk?  Also, I am
> I'll look at this tomorrow, but I think for now you need to have a standalone function,
it cannot be split
> as a main function calling subfunctions. The only allowed calls are the static methods
from Math/StrictMath.
> I did not add our own FastMath, but it is trivial to do.
> Another limitation is that your function cannot store intermediate results as clas attributes

Thanks, Luc!  What I was trying to illustrate was partial
derivatives, which IIUC you need something like that example to do. 
The following almost works:
   public void testPartialDerivatives() throws Exception {
        PartialFunction function = new PartialFunction(1);
        final UnivariateDerivative derivative = new
        DifferentialPair t = DifferentialPair.newVariable(1);
        Assert.assertEquals(3, derivative.f(t).getFirstDerivative(), 0);
        Assert.assertEquals(2, derivative.f(t).getValue(), 0);
        Assert.assertEquals(4, derivative.f(t).getFirstDerivative(), 0);
        Assert.assertEquals(3, derivative.f(t).getValue(), 0);


public class PartialFunction implements UnivariateDifferentiable {
    private double x;
    public PartialFunction(double x) {
        this.x = x;
    public void setX(double x) {
        this.x = x;
    public double getX() {
        return x;
    public double f(double y) {
        return x * y + y * y;

But I end up with java.lang.VerifyError: (class:
method: f signature:
Incompatible type for getting or setting field
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(
    at java.lang.Class.getDeclaredConstructors(
    at ExampleTest.testPartialDerivatives(
> You can look at the junit tests for what is supported.  Simple expressions, calls to
traditional functions like sin, cos, exp ...,
> Simple loops and conditionals, local automatic variables should all work (I hope ...)

Yep, I have gotten all of this to work.  Even "knows" the chain rule :)

>> assuming
>> s/ForwardAlgorithmicDifferentiator/ForwardModeAlgorithmicDifferentiator
>> throughout.  Correct?
> Yes, the name was changed because a distant goal will be to also support reverse mode,
which is especially
> useful when computing gradients (i.e. when one scalar function depends on many inputs
and we want all partial
> derivatives).
> Luc
>> Phil
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message