Remove complex and imaginary types?

Bill Baxter dnewsgroup at billbaxter.com
Mon Jan 7 19:13:29 PST 2008


Georg Wrede wrote:
> Don Clugston wrote:
>> Suppose you're writing a generic function product(T)(T[]) which 
>> returns T[0]*T[1]*T[2]*... What's the return type?
>> Suppose T is idouble. Then if the number of elements in T is odd, the 
>> return type should be idouble, but if it's even, the return type 
>> should be double!
> 
> I definitely don't pretend to understand any of that, but shouldn't it 
> all follow the pertinent trails of mathematics?
> 
> As in, case one, idouble; case two, double -- and the latter should 
> probably be an idouble where one of the parts of the result De Facto 
> makes it double, while still technically being an idouble.
> 
> Any further calculation that wants to perceive a difference, might then 
> start with checking whether the argument is "in practice a double, or 
> really idouble".

The bottom line is that there really is no useful mathematics that can 
be performed using only imaginary numbers.  If to do anything more than 
add, subtract, or multiply by a (real!) scalar they become complex.  If 
you have any imaginary numbers in a numerical code it means you're 
working in the complex plane.  I don't think there is even a 
mathematical symbol reserved for the set of pure imaginary numbers.  For 
reals there's the double-barred R, for complex numbers there's 
double-barred C, but there's no double barred "I" as far as I know.  It 
just isn't useful, because, as Don says, its not closed under the common 
mathematical operations.

--bb



More information about the Digitalmars-d mailing list