On 12/12/2019 14:57, Gilles Sadowski wrote:
Le jeu. 12 déc. 2019 à 15:20, Alex Herbert <alex.d.herb...@gmail.com> a écrit :
On 12/12/2019 13:50, Gilles Sadowski wrote:
Hello.
Le jeu. 12 déc. 2019 à 10:04, Alex Herbert <alex.d.herb...@gmail.com> a écrit :
There is a factory constructor:
Complex.ofReal(double)
For completeness I think we should add:
Complex.ofImaginary(double)
I wonder whether we should remove "ofReal".
It's a shortcut that does not save a lot of typing, IMHO not worth adding
to the API.
I like the ofReal() constructor. I was leaning on the other side for
completeness. So I already added ofImaginary(). But both could be removed.
It allows construction of a Complex from a double using lambda
functions, e.g. for streams:
List<Complex> numbers = Arrays.stream(new double[] {0, 1, 2})
.mapToObj(Complex::ofImaginary)
.collect(Collectors.toList());
It may be useful and does not add much bloat to the API.
Yet, id' rather wait until we have a compelling use-case.
It's easy to add to the API; impossible to remove from it...
The above example falls in the realm of the "ComplexList"
discussed in another thread. And such factories will likely
be defined there, e.g.
---CUT---
double[] re = new double[] {1, 2, 3};
double[] im = new double[] {4, 5, 6};
ComplexList numbers = ComplexList.ofCartesian(re, im);
---CUT---
and
---CUT---
double[] interleaved = new double[][] {1, 4, 2, 5, 3, 6};
ComplexList numbers = ComplexList.ofCartesian(interleaved);
---CUT---
etc.
OK. I'll remove ofReal() and ofImaginary().
They can always be added later.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org