octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #45264] ov-java.cc-tst fails with openjdk-7 jr


From: Adrian V.
Subject: [Octave-bug-tracker] [bug #45264] ov-java.cc-tst fails with openjdk-7 jre 32 bit on octave 4.0.0
Date: Sun, 07 Jun 2015 23:53:07 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0

Follow-up Comment #5, bug #45264 (project octave):

It was actually the CastException in comment #1 that made me suspect there
might be an unintended cast from double to float. The cast could lead both to
the test failure and to the observed loss of precision introduced in octave
4.0.0.

Below I'll provide a minimal example to show what is described in comment #4.


----
Java class: myjavapackage/Myclass.java:

package myjavapackage;

/**
 * Minimal example
 */
public class Myclass {
    
    private double[] t;
    
    public Myclass(double[] t) {
        this.t = t;
    }
        
    /**
     * Print the array
     */
    public void list() {
        for (double entry : t) System.out.println(entry);
    }
    
    /**
     * Return the array
     */
    public double[] gett() {
        return t;
    }
}


Test on *octave 3.8.1* (Ubuntu 32bit). _Works as expected_:

GNU Octave, version 3.8.1
Copyright (C) 2014 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "i686-pc-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> format long
octave:2> t = [0.123456789123456; 0.234567891234567; 0.345678912345678]
t =

   0.123456789123456
   0.234567891234567
   0.345678912345678

octave:3> javaaddpath('.')
octave:4> # Pass (double precision) vector to java
octave:4> jobj = javaObject("myjavapackage.Myclass",t);
octave:5> # See what java received
octave:5> jobj.list
0.123456789123456
0.234567891234567
0.345678912345678
ans = [](0x0)
octave:6> jobj.list
0.123456789123456
0.234567891234567
0.345678912345678
ans = [](0x0)
octave:7> # Get the vector back
octave:7> t2 = java2mat(jobj.gett)
t2 =

   0.123456789123456   0.234567891234567   0.345678912345678

octave:8> 
octave:8> # t and t2 should be the same
octave:8> t2' - t
ans =

   0
   0
   0

octave:9> 


Test on *octave 4.0.0* (OpenSuse 34bit). _Looses precision when passing double
to java_:

GNU Octave, version 4.0.0
Copyright (C) 2015 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-suse-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

>> format long
>> t = [0.123456789123456; 0.234567891234567; 0.345678912345678]
t =

   0.123456789123456
   0.234567891234567
   0.345678912345678

>> javaaddpath('.')
>> # Pass (double precision) vector to java
>> jobj = javaObject("myjavapackage.Myclass",t);
>> # See what java received
>> jobj.list
0.12345679104328156
0.23456789553165436
0.3456789255142212
ans = [](0x0)
>> # Get the vector back
>> t2 = jobj.gett
t2 =

   0.123456791043282
   0.234567895531654
   0.345678925514221

>> 
>> # t and t2 should be the same
>> t2 - t
ans =

   1.91982554853531e-09
   4.29708735261158e-09
   1.31685432003259e-08

>> 

----

The test shows that the precision is lost when passing the vector from octave
to java.


I tried to find the changes in octave code that could cause the change. As I
don't know the code base and beeing familiar with java only I had no success.
Could someone check if it is related to changeset 20122:81fcf4aa9e03 ? In the
current file libinterp/octave-value/ov-java.cc at lines 1284-1308 I don't see
anything about double type, might it be missing (just a random guess)?


I hope this information is useful.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45264>

_______________________________________________
  Nachricht gesendet von/durch Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]