commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NUMBERS-10) Revamp "Complex" representation ?
Date Tue, 21 Feb 2017 23:12:44 GMT

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

Gilles commented on NUMBERS-10:
-------------------------------

I assume that you refer to the handling of a {{Complex}} NaN (and not to the class as a whole).
If you do not have a better alternative, then, of course, keep the same design decision.

A question is whether such a NaN is useful in actual code, beyond signalling a failure.
I mean, are there algorithms that can recover when passed such a {{Complex}} instance?
If not, I wonder whether it would not be better to throw an exception.
Alternatively, we should explore the cost and benefit of handling this NaN instance as is
done with an [Optional|https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html]
value.

> Revamp "Complex" representation ?
> ---------------------------------
>
>                 Key: NUMBERS-10
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-10
>             Project: Commons Numbers
>          Issue Type: Wish
>            Reporter: Gilles
>              Labels: API, design, review
>             Fix For: 1.0
>
>         Attachments: CartesianRepresentation.java, Complex.java, MixedRepresentation.java,
PolarRepresentation.java
>
>
> This is a proposal to enhance the internal representation of complex numbers.
> The purpose is to allow usage of both cartesian and polar representations, with the aim
that calculations are performed (transparently) with the one that will be more accurate and/or
faster. 
> The API would certainly be improved, from
> {code}
>         final Complex c1 = Complex.valueOf(1, 2);
>         final Complex c2 = ComplexUtils.polar2Complex(2, 7);
>         final Complex r = c1.add(c2);
>  {code}
> with the current code, to
> {code}
>         final Complex c1 = Complex.createCartesian(1, 2);
>         final Complex c2 = Complex.createPolar(2, 7);
>         final Complex r = c1.add(c2);
> {code}
> Please refer to the attached files (they are self-documenting, but of course, Javadoc
must be added if the proposal is validated).
> Would there be merit in pursuing in that direction?
> Or is there any show-stopper?



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message