You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2018/01/26 14:00:00 UTC
[09/37] commons-numbers git commit: Partial work on C Standard test;
pulled changes made to master
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/master
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
+ * where {@code c = cos(x) + i sin (x)}
+ *
+ * @param x {@code double} to build the cis number
+ * @return {@code Complex}
+ */
+ 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");
+ }
+ }
/**
* 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));
}
-
- /**
- * 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();
- }
}