Re: Problem with using std.math: abs and std.complex: abs at the same time

2019-09-19 Thread berni via Digitalmars-d-learn
On Thursday, 19 September 2019 at 11:16:12 UTC, Simen Kjærås wrote: Might I ask what specifically you're working on? Of course. It's about issue 15881 (and 15763), namely approxEqual not always doing, what people think it should do. (As a side note: I stumbled over this, when I wanted to file

Re: Problem with using std.math: abs and std.complex: abs at the same time

2019-09-19 Thread Simen Kjærås via Digitalmars-d-learn
r to put this in std/complex.d anyway, but then code duplication would be necessary). You could perfectly well place MergeOverloads inside whatever function you make, thus not polluting std.math: float abs(float f) { return f < 0 ? -f : f; } unittest { import std.complex : complex, c

Re: Problem with using std.math: abs and std.complex: abs at the same time

2019-09-19 Thread berni via Digitalmars-d-learn
On Thursday, 19 September 2019 at 07:26:17 UTC, Simen Kjærås wrote: That does indeed fail to compile, and there's no easy way to introduce the module-level abs() function to the scope. Again though, MergeOverloads to the rescue: I'm not sure, if MergeOverloads will be accepted into std/math.d.

Re: Problem with using std.math: abs and std.complex: abs at the same time

2019-09-19 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 18 September 2019 at 13:24:05 UTC, berni wrote: On Wednesday, 18 September 2019 at 12:37:28 UTC, Simen Kjærås wrote: How to resolve this, though? The simplest solution is to not use selective imports: import std.math; import std.complex; writeln(abs(complex(1.0,1.0

Re: Problem with using std.math: abs and std.complex: abs at the same time

2019-09-18 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Sep 18, 2019 at 12:37:28PM +, Simen Kjærås via Digitalmars-d-learn wrote: [...] > template MergeOverloads(T...) { > alias MergeOverloads = T[0]; > static if (T.length > 1) { > alias MergeOverloads = MergeOverloads!(T[1..$]); > } > } > > I would however label that a

Re: Problem with using std.math: abs and std.complex: abs at the same time

2019-09-18 Thread berni via Digitalmars-d-learn
On Wednesday, 18 September 2019 at 12:37:28 UTC, Simen Kjærås wrote: How to resolve this, though? The simplest solution is to not use selective imports: import std.math; import std.complex; writeln(abs(complex(1.0,1.0))); writeln(abs(1.0)); That works. But: I'm tryi

Re: Problem with using std.math: abs and std.complex: abs at the same time

2019-09-18 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 18 September 2019 at 12:03:28 UTC, berni wrote: The following code doesn't compile: import std.stdio; void main() { import std.complex: abs, complex; import std.math: abs; auto a = complex(1.0,1.0); auto b = 1.0; writeln(abs(a)); writeln(abs(b)); }

Re: Problem with using std.math: abs and std.complex: abs at the same time

2019-09-18 Thread Daniel Kozak via Digitalmars-d-learn
On Wed, Sep 18, 2019 at 2:05 PM berni via Digitalmars-d-learn wrote: > > The following code doesn't compile: > > >import std.stdio; > > > >void main() > >{ > >import std.complex: abs, complex; > >import std.math: abs; > &g

Re: Problem with using std.math: abs and std.complex: abs at the same time

2019-09-18 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 18 September 2019 at 12:03:28 UTC, berni wrote: The following code doesn't compile: import std.stdio; void main() { import std.complex: abs, complex; import std.math: abs; auto a = complex(1.0,1.0); auto b = 1.0; writeln(abs(a)); writeln(abs(b)); }

Problem with using std.math: abs and std.complex: abs at the same time

2019-09-18 Thread berni via Digitalmars-d-learn
The following code doesn't compile: import std.stdio; void main() { import std.complex: abs, complex; import std.math: abs; auto a = complex(1.0,1.0); auto b = 1.0; writeln(abs(a)); writeln(abs(b)); } The error message depends on the order of the two import state

A small difference between cdouble and std.complex

2013-11-18 Thread bearophile
This shows a difference between the deprecated built-in complex numbers and std.complex: void main() { import std.complex: complex; const cdouble cd; pragma(msg, typeof(cd.re)); const acc = complex(1, 2); pragma(msg, typeof(acc.re)); } It prints: double const(double) Is

Re: std.complex will replace the built-in types

2012-08-19 Thread Jonathan M Davis
On Sunday, August 19, 2012 20:28:35 teo wrote: > I read at http://dlang.org/phobos/std_complex.html that "Complex will > eventually replace the built-in types cfloat, cdouble, creal, ifloat, > idouble, and ireal". > > Can someone elaborate why? What is wrong with the above types? I think that it

std.complex will replace the built-in types

2012-08-19 Thread teo
I read at http://dlang.org/phobos/std_complex.html that "Complex will eventually replace the built-in types cfloat, cdouble, creal, ifloat, idouble, and ireal". Can someone elaborate why? What is wrong with the above types?

Re: std.complex

2010-05-11 Thread eles
er, I think it should be defined as Complex!real (0,1); I hope it will be automatically downsized to Complex!int if the left value is a Complex!int and so on. I vote for defining it in std.complex for the folowing reasons: - it will enforce coding discipline and standardize code among libraries and

Re: std.complex

2010-05-11 Thread Lars T. Kyllingstad
IMO it looks a lot better: auto z = fromPolar(2.23, 1.107); > even in C99 one could write "complex double z=1+2*I" (but "I" is a > defined symbol) - instead of "Complex!double(2,3)" If you want that, just define immutable I = Complex!float(0, 1); Perha

Re: std.complex

2010-05-11 Thread eles
Maybe I am wrong, but my feeling is that if the complex numbers were a native type (like creal&co. are now), then it would have been possible to have a dedicated formatting (just like %f, %d and %s are) for writefln. Putting the type into the library seems to forbid some very nice things: - init

Re: std.complex

2010-05-11 Thread Lars T. Kyllingstad
On Tue, 11 May 2010 11:51:34 +, eles wrote: > the following test case also works: > > Compiling > > import std.stdio; > import std.complex; > > Complex!(double) x,y; > > int main(){ > writefln("salut!\n"); > x.re=1; > x.im

Re: std.complex

2010-05-11 Thread eles
the following test case also works: Compiling import std.stdio; import std.complex; Complex!(double) x,y; int main(){ writefln("salut!\n"); x.re=1; x.im=1; y=x.conj(); writefln("x=%f+%f*i\n",x.re,x.im); writefln(&qu

Re: std.complex

2010-05-11 Thread eles
Confirmation: in the new beta, the test case for the std.complex compiles on windows xp with dmd 2.046beta. I cannot post on the D.phobos newsgroup, but I post the confirmation here. I did not test it further. Compiling import std.complex; int main(){ return 0; } results in: C:\dmd2

Re: std.complex

2010-05-09 Thread eles
Thank you, Don. I saw your post on the http://news.gmane.org/ gmane.comp.lang.d.dmd.beta group. I'll wait for the next release. Does anybody knows about when the http://d.puremagic.com/issues/ show_bug.cgi?id=2460 (DMD bug 2460) will be addressed?

Re: std.complex

2010-05-09 Thread Don
eles wrote: Hello, I just installed dmd 2.045 (unarchived in c:\dmd2) and put c: \dmd2\windows2\bin on path. Compiling the following: import std.complex; int main(){ return 0; } fails with: C:\dmd2>dmd test.d OPTLINK (R) for Win32 Release 8.00.2 Copyright (C) Digital Mars 1

Re: std.complex

2010-05-09 Thread Lars T. Kyllingstad
On Sun, 09 May 2010 18:57:08 +, eles wrote: > actually, i think 2.045 was the second (after 2.044) release to include > std.complex. You are right, what's in Phobos now is the new std.complex. > as i understand, std.complex should replace the native types cfloat, > creal,

Re: std.complex

2010-05-09 Thread eles
actually, i think 2.045 was the second (after 2.044) release to include std.complex. as i understand, std.complex should replace the native types cfloat, creal, ifloat, ireal etc. i was eager to test the new std.complex. it seems that some work is still needed. maybe someone could submit a bug

Re: std.complex

2010-05-09 Thread Robert Clipsham
On 09/05/10 14:41, div0 wrote: Though I think there's been discussion about the whole complex number support. Not sure what's going off but I think it's going to overhauled or replaced, so you'd be better off not using std.complex std.complex has just undergone its major r

Re: std.complex

2010-05-09 Thread div0
; > int main(){ > writefln("hello!\n"); > return 0; > } > > results in: > > C:\dmd2>dmd test.d > > C:\dmd2>test > hello! > > So, the problem is somewhere in std.complex. Doesn't work even with 2.028. For some reason complex

Re: std.complex

2010-05-09 Thread eles
d2>test hello! So, the problem is somewhere in std.complex.

Re: std.complex

2010-05-08 Thread Robert Clipsham
On 09/05/10 02:27, eles wrote: Hello, I just installed dmd 2.045 (unarchived in c:\dmd2) and put c: \dmd2\windows2\bin on path. Compiling the following: import std.complex; int main(){ return 0; } fails with: C:\dmd2>dmd test.d OPTLINK (R) for Win32 Release 8.00.2 Copyright

std.complex

2010-05-08 Thread eles
Hello, I just installed dmd 2.045 (unarchived in c:\dmd2) and put c: \dmd2\windows2\bin on path. Compiling the following: import std.complex; int main(){ return 0; } fails with: C:\dmd2>dmd test.d OPTLINK (R) for Win32 Release 8.00.2 Copyright (C) Digital Mars 1989-2009

Re: Wht std.complex is needed?

2009-05-17 Thread Bill Baxter
nly difference should be that you need to import std.complex (if that even). If changing to a library introduces any reduction in functionality beyond that I don't think it would go through. --bb

Re: Wht std.complex is needed?

2009-05-16 Thread bearophile
MikeWh: > Why in the world would complex types be dropped from D? Andrei wants to cut them away from the language. And his power in the design of the language is great. So saying such things here isn't going to help much. So you can send him an email, for example. He will probably answer you tha

Re: Wht std.complex is needed?

2009-05-16 Thread MikeWh
;>> Doesn't D already has the built-in types cfloat, cdouble, creal, >>> ifloat, idouble, and ireal?What's the advantage having complex class >>> instead? > > The intention is that cfloat, cdouble,... will be deprecated eventually. > > I don

Re: Wht std.complex is needed?

2009-04-06 Thread Don
Steven Schveighoffer wrote: On Mon, 06 Apr 2009 09:50:35 -0400, Don wrote: Steven Schveighoffer wrote: On Mon, 06 Apr 2009 08:36:18 -0400, Don wrote: Sam Hu wrote: Thank you! Anothe silly question then:What's the disadvantage to have the built-in type of i-type? Regards, Sam It's a v

Re: Wht std.complex is needed?

2009-04-06 Thread Joel C. Salomon
bearophile wrote: > A better question can be: "What's the advantage of having a built-in > imaginary type?" :-) > You can find an answer here, from page 11: > http://www.eecs.berkeley.edu/~wkahan/JAVAhurt.pdf > But maybe those ideas aren't much true anymore today. Why could you not make a struct

Re: Wht std.complex is needed?

2009-04-06 Thread Steven Schveighoffer
On Mon, 06 Apr 2009 09:50:35 -0400, Don wrote: Steven Schveighoffer wrote: On Mon, 06 Apr 2009 08:36:18 -0400, Don wrote: Sam Hu wrote: Thank you! Anothe silly question then:What's the disadvantage to have the built-in type of i-type? Regards, Sam It's a very nasty type. It supports

Re: Wht std.complex is needed?

2009-04-06 Thread Don
Steven Schveighoffer wrote: On Mon, 06 Apr 2009 08:36:18 -0400, Don wrote: Sam Hu wrote: Thank you! Anothe silly question then:What's the disadvantage to have the built-in type of i-type? Regards, Sam It's a very nasty type. It supports *, but isn't closed under *. Which is really annoyi

Re: Wht std.complex is needed?

2009-04-06 Thread Daniel Keep
Steven Schveighoffer wrote: > On Mon, 06 Apr 2009 08:36:18 -0400, Don wrote: > >> Sam Hu wrote: >>> Thank you! >>> Anothe silly question then:What's the disadvantage to have the >>> built-in type of i-type? >>> Regards, >>> Sam >> >> It's a very nasty type. It supports *, but isn't closed unde

Re: Wht std.complex is needed?

2009-04-06 Thread Steven Schveighoffer
On Mon, 06 Apr 2009 08:36:18 -0400, Don wrote: Sam Hu wrote: Thank you! Anothe silly question then:What's the disadvantage to have the built-in type of i-type? Regards, Sam It's a very nasty type. It supports *, but isn't closed under *. Which is really annoying for generic programming.

Re: Wht std.complex is needed?

2009-04-06 Thread Don
Sam Hu wrote: Thank you! Anothe silly question then:What's the disadvantage to have the built-in type of i-type? Regards, Sam It's a very nasty type. It supports *, but isn't closed under *. Which is really annoying for generic programming. idouble x = 2i; x *= x; // oops, this isn't imagina

Re: Wht std.complex is needed?

2009-04-06 Thread Don
bearophile wrote: Sam Hu: Doesn't D already has the built-in types cfloat, cdouble, creal, ifloat, idouble, and ireal?What's the advantage having complex class instead? The intention is that cfloat, cdouble,... will be deprecated eventually. I don't think std.complex sh

Re: Wht std.complex is needed?

2009-04-06 Thread bearophile
Sam Hu Wrote: >What's the disadvantage to have the built-in type of i-type?< I think the answer is: It's another type added to the language, with its specific semantics, so it adds a bit of complexity to the language. And most people today don't seem to use complex types in D1 much, so they thin

Re: Wht std.complex is needed?

2009-04-06 Thread Sam Hu
Thank you! Anothe silly question then:What's the disadvantage to have the built-in type of i-type? Regards, Sam

Re: Wht std.complex is needed?

2009-04-06 Thread bearophile
Sam Hu: > Doesn't D already has the built-in types cfloat, cdouble, creal, ifloat, > idouble, and ireal?What's the advantage having complex class instead? Some people have discussed/complained that complex types aren't worth being built-ins, so the *struct* Complex of s

Wht std.complex is needed?

2009-04-06 Thread Sam Hu
Hello everyone! Doesn't D already has the built-in types cfloat, cdouble, creal, ifloat, idouble, and ireal?What's the advantage having complex class instead? Thanks and best regards, Sam