Numbers-17: added some missing methods for ComplexUtils
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/d8766052 Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/d8766052 Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/d8766052 Branch: refs/heads/master Commit: d8766052e1f10c146fb112495abe74795d390f75 Parents: 387f4e0 Author: Eric Barnhill <ericbarnh...@apache.org> Authored: Thu Aug 3 13:09:32 2017 +0200 Committer: Eric Barnhill <ericbarnh...@apache.org> Committed: Thu Aug 3 13:09:32 2017 +0200 ---------------------------------------------------------------------- .../commons/numbers/complex/ComplexUtils.java | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/d8766052/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java ---------------------------------------------------------------------- diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java index e41709c..529521d 100644 --- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java +++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java @@ -338,6 +338,24 @@ public class ComplexUtils { } /** + * Converts a 2D real {@code float[][]} array to a 2D {@code Complex[][]} + * array. + * + * @param d 2D array + * @return 2D {@code Complex} array + * + * @since 1.0 + */ + public static Complex[][] real2Complex(float[][] d) { + final int w = d.length; + final Complex[][] c = new Complex[w][]; + for (int n = 0; n < w; n++) { + c[n] = ComplexUtils.real2Complex(d[n]); + } + return c; + } + + /** * Converts a 3D real {@code double[][][]} array to a {@code Complex [][][]} * array. * @@ -356,6 +374,24 @@ public class ComplexUtils { } /** + * Converts a 3D real {@code float[][][]} array to a {@code Complex [][][]} + * array. + * + * @param d 3D complex interleaved array + * @return 3D {@code Complex} array + * + * @since 1.0 + */ + public static Complex[][][] real2Complex(float[][][] d) { + final int w = d.length; + final Complex[][][] c = new Complex[w][][]; + for (int x = 0; x < w; x++) { + c[x] = ComplexUtils.real2Complex(d[x]); + } + return c; + } + + /** * Converts a 4D real {@code double[][][][]} array to a {@code Complex [][][][]} * array. *