[ 
https://issues.apache.org/jira/browse/NUMBERS-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17699060#comment-17699060
 ] 

Sentaro Onizuka commented on NUMBERS-193:
-----------------------------------------

Hi,
Based on the answers to my 
[question|https://www.mail-archive.com/[email protected]/msg73497.html], I 
have considered the following directions.
 # First, using a JMH benchmark, test whether object creation and garbage 
collection affect the performance.
This is a necessary evaluation to implement the DD class as an immutable class 
like BigDecimal.
 ## Copy the DD class into a JMH project and add OO methods that create a new 
instance for all operations.
 ## Compare performance with and without the OO method. For performance 
comparisons, use the Kolmogorov-Smirnov p-value computation from statistics. I 
recognize that this is to execute the 
[testOneLarge|https://github.com/apache/commons-statistics/blob/31103db1687f69e2875e5e3d9bd0ce1c670627d0/commons-statistics-inference/src/test/java/org/apache/commons/statistics/inference/KolmogorovSmirnovDistributionTest.java#L706]
 method in KolmogorovSmirnovDistributionTest.java.
 # Next, implement the DD class as a new number module, like complex numbers 
and fractions.
 ## In the c++ library, operators for four arithmetic operations are 
implemented, but I cannot implement them in java because operator overloading 
is not supported.
Therefore, I would implement the API for the four arithmetic operations as 
methods of the immutable class. That is, the API consists of methods acting on 
the current instance and returning a new instance.
 ## Identify what APIs are provided in the statistics and C++ libraries and 
implement other necessary APIs. The API provided by the c++ reference 
implementation can be found mainly in dd_real.h. ( I've already focused on what 
API is in the c++ library.)
 # Finally, I will need to test the implemented API.



What do you think about the direction?

> This is where I would start with an API design. E.g. what OO API does the c++ 
> reference implementation provide?
Also, I have focused on what API is in the c++ library. What else is needed for 
API design?


Best regards, 

> Add support for extended precision floating-point numbers
> ---------------------------------------------------------
>
>                 Key: NUMBERS-193
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-193
>             Project: Commons Numbers
>          Issue Type: New Feature
>            Reporter: Alex Herbert
>            Priority: Major
>              Labels: full-time, gsoc2023, part-time
>
> Add implementations of extended precision floating point numbers.
> An extended precision floating point number is a series of floating-point 
> numbers that are non-overlapping such that:
> {noformat}
> double-double (a, b):
> |a| > |b|
> a == a + b{noformat}
> Common representations are double-double and quad-double (see for example 
> David Bailey's paper on a quad-double library: 
> [QD|https://www.davidhbailey.com/dhbpapers/qd.pdf]).
> Many computations in the Commons Numbers and Statistics libraries use 
> extended precision computations where the accumulated error of a double would 
> lead to complete cancellation of all significant bits; or create intermediate 
> overflow of integer values.
> This project would formalise the code underlying these use cases with a 
> generic library applicable for use in the case where the result is expected 
> to be a finite value and using Java's BigDecimal and/or BigInteger negatively 
> impacts performance.
> An example would be the average of long values where the intermediate sum 
> overflows or the conversion to a double loses bits:
> {code:java}
> long[] values = {Long.MAX_VALUE, Long.MAX_VALUE}; 
> System.out.println(Arrays.stream(values).average().getAsDouble()); 
> System.out.println(Arrays.stream(values).mapToObj(BigDecimal::valueOf)
>     .reduce(BigDecimal.ZERO, BigDecimal::add)
>     .divide(BigDecimal.valueOf(values.length)).doubleValue());
> long[] values2 = {Long.MAX_VALUE, Long.MIN_VALUE}; 
> System.out.println(Arrays.stream(values2).asDoubleStream().average().getAsDouble());
>  System.out.println(Arrays.stream(values2).mapToObj(BigDecimal::valueOf)
>     .reduce(BigDecimal.ZERO, BigDecimal::add)
>     .divide(BigDecimal.valueOf(values2.length)).doubleValue());
> {code}
> Outputs:
> {noformat}
> -1.0
> 9.223372036854776E18
> 0.0
> -0.5{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to