Re: complex arithmetic in D: multiple questions

2018-03-09 Thread J-S Caux via Digitalmars-d-learn
On Friday, 9 March 2018 at 13:56:33 UTC, Nicholas Wilson wrote: - I would expect the D `Complex!double` case to work faster than the `real` one. Why is it the other way around? [I can accept (and use) D with Complex!real running 1/3 the speed of C++ (but with increased accuracy), but I'd also

complex arithmetic in D: multiple questions

2018-03-09 Thread J-S Caux via Digitalmars-d-learn
Please bear with me, this is a long question! To explain, I'm a scientist considering switching from C++ to D, but before I do, I need to ensure that I can: - achieve execution speeds comparable to C++ (for the same accuracy; I can accept a slight slowdown, call it 30%, to get a few more

Re: log for complex

2018-03-07 Thread J-S Caux via Digitalmars-d-learn
On Wednesday, 7 March 2018 at 10:28:23 UTC, Simen Kjærås wrote: On Wednesday, 7 March 2018 at 10:10:49 UTC, J-S Caux wrote: On Wednesday, 7 March 2018 at 08:04:36 UTC, Simen Kjærås wrote: auto log(T)(Complex!T x) { import std.math : log; return Complex!T(log(abs(x)), arg(x)); } Yes

Re: log for complex

2018-03-07 Thread J-S Caux via Digitalmars-d-learn
On Wednesday, 7 March 2018 at 08:04:36 UTC, Simen Kjærås wrote: On Wednesday, 7 March 2018 at 07:42:37 UTC, J-S Caux wrote: Simple question: how do I get the log of a complex number? If I try the simple logtest = log(complex(1.0, 2.0)) I get the compiler error Error: function

log for complex

2018-03-06 Thread J-S Caux via Digitalmars-d-learn
Simple question: how do I get the log of a complex number? If I try the simple logtest = log(complex(1.0, 2.0)) I get the compiler error Error: function core.stdc.math.log(double x) is not callable using argument types (Complex!double) Some basic functions are described in

Re: Speed of math function atan: comparison D and C++

2018-03-06 Thread J-S Caux via Digitalmars-d-learn
On Tuesday, 6 March 2018 at 07:12:57 UTC, Robert M. Münch wrote: On 2018-03-05 20:11:06 +, H. S. Teoh said: Walter has been adamant that we should always compute std.math.* functions with the `real` type, which on x86 maps to the non-IEEE 80-bit floats. However, 80-bit floats have been

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread J-S Caux via Digitalmars-d-learn
On Monday, 5 March 2018 at 09:48:49 UTC, Uknown wrote: Depending on your platform, the size of `double` could be different between C++ and D. Could you check that the size and precision are indeed the same? Also, benchmark method is just as important as benchmark code. Did you use DMD or LDC

Re: Speed of math function atan: comparison D and C++

2018-03-04 Thread J-S Caux via Digitalmars-d-learn
On Monday, 5 March 2018 at 05:40:09 UTC, rikki cattermole wrote: On 05/03/2018 6:35 PM, J-S Caux wrote: I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared the raw speed of atan between C++

Speed of math function atan: comparison D and C++

2018-03-04 Thread J-S Caux via Digitalmars-d-learn
I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared the raw speed of atan between C++ (Apple LLVM version 7.3.0 (clang-703.0.29)) and D (dmd v2.079.0, also ldc2 1.7.0) by doing long loops of