Re: Avoiding C++ Templates In Cipher Implementation
From: Paul Schlyter (pausch_at_saaf.se)
Date: 05/28/03
- Next message: Paul Rubin: "Re: electronic-ID and key-generation"
- Previous message: Peter Gullberg: "Re: electronic-ID and key-generation"
- In reply to: Dann Corbit: "Re: Avoiding C++ Templates In Cipher Implementation"
- Next in thread: Dann Corbit: "Re: Avoiding C++ Templates In Cipher Implementation"
- Reply: Dann Corbit: "Re: Avoiding C++ Templates In Cipher Implementation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 28 May 2003 07:40:41 +0000 (UTC)
In article <bb0eat0hkp@enews3.newsguy.com>,
Dann Corbit <dcorbit@connx.com> wrote:
> "Paul Schlyter" <pausch@saaf.se> wrote in message
..................
>> Why on earth would one want a "complex long long" data type? I'm not
>> aware of even one single problem where complex numbers with
>> integer-only real and imaginary parts would be useful....
>
> A problem where the real and imaginary parts are always integral. Perhaps
> (for instance) modelling a 2-d lattice of some kind. Your inability to
> imagine a reason for something does not negate its possibility.
True of course -- and that's why I asked....
>> But if we're really going to get absurd, why not also define complex
>> types where the real and imaginary parts can be of different numerical
>> types? Then we'd have (notation is realType/imaginaryType):
>
> Actually, it would not be difficult to do so. You would simply have two
> replaceable parameters instead of one. Not sure that I see the utilty there.
Perhaps (for instance) modelling some lattice with evenly spaced
parallell lines of some kind? Your inability to imagine a reason for
something does not negate its possibility. :-)
> It would be better to create a data type that encompasses all of the data
> types and use that as the replacement parameter for the template.
>
>> complex int/int
> [snip of long and intentionally silly list]
>> complex <some floating-point bignum type>/<some floating-point bignum
> type>
>>
>> ...and to make this package really useful, we'd need to implement
>> not just the four arithmetic operations but also square roots,
>> powers, and log/exp/trig/hyperbolic functions for all these different
>> kinds of complex data types......
>
> No we wouldn't. We would have to write a single template and we would
> instantly have the use of all of the above.
:-) ....OK, but we'd want full precision for the bignum floating-point
data type, right? To ensure that, this single template would have to
implement this algorithm, and it would have to be used for all data
types. Sure, it would produce the correct result for e.g. a float or
a double, but it would become so slow that no-one would want to use it.
> If you wanted (for whatever reason) that sort of functionality without
> templates, THEN you would have to implement a new class for each type.
At least one would have to implement a different algorithm for each
type -- at least if one wanted the best accuracy _and_ an efficient
implementation....
>> Quite a useful package, eh? <g>
>
> No real extra utility over the standard complex template that I can see.
> There is a reason that templates were chosen for the STL. They are (without
> question) the method of choice for abstract data types using C++.
If the abstract data types don't vary too wildly, yes....
-- ---------------------------------------------------------------- Paul Schlyter, Swedish Amateur Astronomer's Society (SAAF) Grev Turegatan 40, S-114 38 Stockholm, SWEDEN e-mail: pausch at saaf dot se WWW: http://hem.passagen.se/pausch/index.html http://home.tiscali.se/~pausch/
- Next message: Paul Rubin: "Re: electronic-ID and key-generation"
- Previous message: Peter Gullberg: "Re: electronic-ID and key-generation"
- In reply to: Dann Corbit: "Re: Avoiding C++ Templates In Cipher Implementation"
- Next in thread: Dann Corbit: "Re: Avoiding C++ Templates In Cipher Implementation"
- Reply: Dann Corbit: "Re: Avoiding C++ Templates In Cipher Implementation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|