You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gilles <gi...@harfang.homelinux.org> on 2017/04/26 00:14:14 UTC
Re: commons-numbers git commit: Partial work on C Standard test;
pulled changes made to master
Hi Eric.
Some nit-picking below...
On Tue, 25 Apr 2017 22:33:25 +0000 (UTC), ericbarnhill@apache.org
wrote:
> Repository: commons-numbers
> Updated Branches:
> refs/heads/complex-dev 410abd7fa -> 07bbda2fd
>
>
> Partial work on C Standard test; pulled changes made to master
>
>
> Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
> Commit:
>
> http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/07bbda2f
> Tree:
> http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/07bbda2f
> Diff:
> http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/07bbda2f
>
> Branch: refs/heads/complex-dev
> Commit: 07bbda2fd6f19980f102d37601e61c06d2b98283
> Parents: 410abd7
> Author: Eric Barnhill <er...@apache.org>
> Authored: Wed Apr 26 00:33:10 2017 +0200
> Committer: Eric Barnhill <er...@apache.org>
> Committed: Wed Apr 26 00:33:10 2017 +0200
>
>
> ----------------------------------------------------------------------
> .../apache/commons/numbers/complex/Complex.java | 33
> +++++++++++++-------
> 1 file changed, 22 insertions(+), 11 deletions(-)
>
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/07bbda2f/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
>
> ----------------------------------------------------------------------
> diff --git
>
> a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
>
> b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
> index 1189451..f8510a5 100644
> ---
>
> a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
> +++
>
> b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
> @@ -124,6 +124,17 @@ public class Complex implements Serializable {
> }
>
> /**
> + * For a real constructor argument x, returns a new Complex
> object c
In general, I'd suggest to make the Javadoc "lighter" by not repeating
that "new Complex object" phrase (I'd use "new instance" everywhere
it's
clear that we talk about a "Complex object").
> + * where {@code c = cos(x) + i sin (x)}
> + *
> + * @param x {@code double} to build the cis number
I'd suggest to use "angle" as parameter name.
And refer to
https://en.wikipedia.org/wiki/Cis_(mathematics)
[First time I hear of "cis"...]
> + * @return {@code Complex}
The return type is already specified by the declaration.
Again, saying "a new instance" gives a little bit more information.
> + */
> + public Complex cis(double x) {
> + return new Complex(Math.cos(x), Math.sin(x));
> + }
> +
> + /**
> * Returns projection of this complex number onto the Riemann
> sphere,
> * i.e. all infinities (including those with an NaN component)
> * project onto real infinity, as described in the
> @@ -1482,7 +1493,6 @@ public class Complex implements Serializable {
> }
> }
>
> -
> /**
> * Check that the argument is positive and throw a
> RuntimeException
> * if it is not.
> @@ -1493,6 +1503,17 @@ public class Complex implements Serializable
> {
> throw new RuntimeException("Complex: Non-positive
> argument");
> }
> }
> +
> + /**
> + * Check that the argument is positive and throw a
> RuntimeException
> + * if it is not.
> + * @param arg {@code double} to check
> + */
> + private static void checkNotNegative(double arg) {
> + if (arg <= 0) {
> + throw new RuntimeException("Complex: Non-positive
> argument");
> + }
> + }
It's much better to use an "IllegalArgumentException".
>
> /**
> * Returns {@code true} if the values are equal according to
> semantics of
> @@ -1505,14 +1526,4 @@ public class Complex implements Serializable
> {
> private static boolean equals(double x, double y) {
> return new Double(x).equals(new Double(y));
> }
This was part of a previous commit; depending on the usage, we should
perhaps look for a more efficient implementation.
Regards,
Gilles
> -
> - /**
> - * Returns an integer hash code representing the given double
> value.
> - *
> - * @param value the value to be hashed
> - * @return the hash code
> - */
> - private static int hash(double value) {
> - return new Double(value).hashCode();
> - }
> }
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org