Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
June 14, 2011 [Issue 6154] New: std.math.abs on std.complex numbers too | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6154 Summary: std.math.abs on std.complex numbers too Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2011-06-14 05:03:13 PDT --- I'd like std.math.abs to perform what std.complex.Complex!T.abs does. So I will be able to use it functionally (currently std.math.abs is able to work on the built-in complex numbers too). This means I'd like this code to work: import std.stdio, std.math, std.algorithm, std.complex; void main() { alias Complex!double C; C[] array2 = [C(1,2), C(2,4)]; auto m2 = map!abs(array2); writeln(m2); } In DMD 2.053 similar code with built-in complex numbers works: import std.stdio, std.math, std.algorithm; void main() { cdouble[] array1 = [1+2i, 2+4i]; auto m1 = map!abs(array1); writeln(m1); } In DMD 2.053 if you want to do the same with complex numbers you need to write: import std.stdio, std.math, std.algorithm, std.complex; void main() { alias Complex!double C; C[] array2 = [C(1,2), C(2,4)]; auto m2 = map!((c){ return c.abs(); })(array2); writeln(m2); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 14, 2011 [Issue 6154] std.math.abs on std.complex numbers too | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6154 kennytm@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kennytm@gmail.com --- Comment #1 from kennytm@gmail.com 2011-06-14 06:26:44 PDT --- (In reply to comment #0) > In DMD 2.053 if you want to do the same with complex numbers you need to write: > > import std.stdio, std.math, std.algorithm, std.complex; > void main() { > alias Complex!double C; > C[] array2 = [C(1,2), C(2,4)]; > auto m2 = map!((c){ return c.abs(); })(array2); > writeln(m2); > } auto m2 = map!`a.abs()`(array2); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 14, 2011 [Issue 6154] std.math.abs on std.complex numbers too | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6154 --- Comment #2 from bearophile_hugs@eml.cc 2011-06-14 10:01:24 PDT --- (In reply to comment #1) > auto m2 = map!`a.abs()`(array2); Right. But std.math.abs has to work on complex numbers too, as before, for polymorphism, and for a serious integration of complex numbers in Phobos. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 14, 2011 [Issue 6154] std.math.abs on std.complex numbers too | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6154 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-06-14 11:03:40 PDT --- (In reply to comment #2) > (In reply to comment #1) > > > auto m2 = map!`a.abs()`(array2); > > Right. But std.math.abs has to work on complex numbers too, as before, No, it does not, and will not. BTW that approach would lead to executable bloat. > for polymorphism, and for a serious integration of complex numbers in Phobos. No. This is what overload sets are for. Complex must not be given special treatment ahead of user-defined types. Otherwise, user-defined types become second-class citizens. (std.math.abs is a bit of a problem at the moment, there are a couple of functions in std.math which have range versions, which IMHO have no business being in there). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 14, 2011 [Issue 6154] std.math.abs on std.complex numbers too | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6154 --- Comment #4 from kennytm@gmail.com 2011-06-14 13:22:08 PDT --- (In reply to comment #2) > (In reply to comment #1) > > > auto m2 = map!`a.abs()`(array2); > > Right. But std.math.abs has to work on complex numbers too, as before, for polymorphism, and for a serious integration of complex numbers in Phobos. Right, but why must it be std.math.abs? Putting the free function as std.complex.abs works too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 15, 2011 [Issue 6154] std.math.abs on std.complex numbers too | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6154 --- Comment #5 from bearophile_hugs@eml.cc 2011-06-15 13:04:17 PDT --- (In reply to comment #4) > Putting the free function as std.complex.abs works too. OK. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 04, 2013 [Issue 6154] std.math.abs on std.complex numbers too | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6154 Lars T. Kyllingstad <bugzilla@kyllingen.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@kyllingen.net Resolution| |FIXED --- Comment #6 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2013-08-04 05:51:12 PDT --- std.complex.abs() was added in May 2012. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation