Boost logo

Boost :

Subject: Re: [boost] [xint] Utility question, how to implement...
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-03-07 10:03:37


Chad Nelson wrote:
> Rene Rivera <grafikrobot_at_[hidden]> wrote:
>
> > So I guess the key question, for the purposes of your
> > library design, is: Is it possible to implement the
> > Barret reduction as your library stands at the moment,
> > without access to implementation details?
>
> For that matter, pretty much everything in the library is implemented
> in terms of addition, subtraction, multiplication, division, modulus,
> comparisons, and the occasional bit-manipulation function or
> is_odd/is_even. All of which are in the public interface. Lower-level
> access might occasionally allow for a faster implementation, but it's
> almost never required. (I'd go so far as to say never, but there's an
> exception to every rule.)

That is, of course, very likely. The hidden part of the question is whether such an algorithm can be implemented efficiently without needing access to the internals.

Note, this is the same thing being asked related to expression templates. The idea there is to reduce a non-trivial sequence of operations to some provided public function that does a combination of operations in one call taking advantage of the internals. IOW, if you provide a function that does "add two numbers and multiply the result by a third" implemented in some manner that is more efficient than the naive sequence, then you can use ETs to recognize that pattern (product of a sum and a third value) and call the special function rather than apply the naive sequence of operations. By recognizing common multi-step-in-one patterns, providing functions for those patterns, and using ETs to trigger their use, you enable more efficiency without needing to grant access to the internals for new algorithms desirous of that efficiency.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk