Dr. Dobb's Journal - April 2008 - (Page 47) d04orlov_p5ds 2/13/08 8:56 AM Page 47 GCD computation is easy with C++ templates; see Listing Four. Now you can compute the constants that were defined in Listing Two. Because these constants are derived from m, the parameter to next(max), they are also kept in a traits structure specialized on max; see Listing Five. You don’t just compute rem, last, and gcd, but also determine the dispatch ID, which is used to select one of the three variants of next(max) implementations—actually, next () because m is now a compiletime constant. The NO_LOOP variant is selected when there are no remainder values in the value_t range, and no loop is necessary. Unless a very strange platform is used, m is a power of 2. The RETRY_SAME variant is actually the SimpleRange implementation, and is selected when m and rem are relatively prime, and m cannot be reduced once a random value is rejected. Finally, the REDUCE_MAX variant is selected when m and rem share a common factor, which allows reduction of m—as in the m=684 and rem=340 example discussed previously. Because C++ doesn’t allow partial specialization for member functions, and you need partial specialization on a dispatch ID, a private class Dispatch is used. Because Dispatch is specialized on all three values of dispatch_t, only a declaration is necessary for the nonspecialized template (see Listing Six). Listings Seven and Eight show the straightforward specializations for the NO_LOOP and RETRY_SAME dispatch IDs. Listing Nine shows the REDUCE_MAX specialization, which implements the previously described buckets-based approach, with a small variation—the remainder range is not partitioned into GCD subranges, but instead a modulo GCD value is used. That is, low-order bits of rnd are used instead of the high-order bits. The Greatest Common Divisor algorithm computation is easy with C++ templates HD PHOTO N O W A V A I LA B LE F O R D O W N L O A D I S 4 0 - 6 0 % F A ST E R I N P I C TO O LS . Speed-optimized HD Photo libraries are now available within the PICTools Software Development Kit (SDK). Microsoft’s HD Photo offers higher image quality, greater preservation of data and advanced features for today’s digital imaging applications. It is a still image compression algorithm for continuous tone photographic images and features lossy, as well as lossless, compression, multiple colorspaces, a wide dynamic range, and extensive metadata support. PICTools SDKs contain low-level C libraries offering advanced image compression, decompression, and editing. Maximum code speed has been achieved through algorithm and machine code optimizations. Also available for .NET and ActiveX. Supported across: 32-bit Sun Solaris 32-bit and 64-bit Linux 32-bit and 64-bit Microsoft Windows IBM AIX Mac OS X Evaluation The supplied code (available online; see “Resource Center,” page 5) can be used to estimate the runtime optimization resulting from the use of SmartRange. The theoretical limit is 25 percent off the original runtime: Going down from the expected 2 calls to Contact us for more information. W W W . P E G A S U S I M A G I N G . C O M Pegasus is a registered trademark of Pegasus Imaging Corporation in the United States. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. April 2008 l www.ddj.com l Dr. Dobb’s Journal 47 http://www.pegasusimaging.com http://www.pegasusimaging.com http://www.ddj.com
Table of Contents Feed for the Digital Edition of Dr. Dobb's Journal - April 2008 Dr. Dobb's Journal - April 2008 Contents Hmmmm Alia Vox Developer Diaries Dr. Dobb's Excellence in Programming Award Conversations Fast String Search on Multicore Processors The Byzantine Generals Problem Optimizing Math-Intensive Applications with Fixed-Point Arithmetic Random Numbers in a Range Using Generic Programming The Agile Edge Effective Concurrency Swaine's Flames Dr. Dobb's Journal - April 2008 Dr. Dobb's Journal - April 2008 - Dr. Dobb's Journal - April 2008 (Page Cover1) Dr. Dobb's Journal - April 2008 - Dr. Dobb's Journal - April 2008 (Page Cover2) Dr. Dobb's Journal - April 2008 - Dr. Dobb's Journal - April 2008 (Page 1) Dr. Dobb's Journal - April 2008 - Dr. Dobb's Journal - April 2008 (Page 2) Dr. Dobb's Journal - April 2008 - Dr. Dobb's Journal - April 2008 (Page 3) Dr. Dobb's Journal - April 2008 - Contents (Page 4) Dr. Dobb's Journal - April 2008 - Contents (Page 5) Dr. Dobb's Journal - April 2008 - Hmmmm (Page 6) Dr. Dobb's Journal - April 2008 - Hmmmm (Page 7) Dr. Dobb's Journal - April 2008 - Hmmmm (Page 8) Dr. Dobb's Journal - April 2008 - Hmmmm (Page 9) Dr. Dobb's Journal - April 2008 - Alia Vox (Page 10) Dr. Dobb's Journal - April 2008 - Alia Vox (Page 11) Dr. Dobb's Journal - April 2008 - Developer Diaries (Page 12) Dr. Dobb's Journal - April 2008 - Developer Diaries (Page 13) Dr. Dobb's Journal - April 2008 - Developer Diaries (Page 14) Dr. Dobb's Journal - April 2008 - Developer Diaries (Page 15) Dr. Dobb's Journal - April 2008 - Dr. Dobb's Excellence in Programming Award (Page 16) Dr. Dobb's Journal - April 2008 - Dr. Dobb's Excellence in Programming Award (Page 17) Dr. Dobb's Journal - April 2008 - Conversations (Page 18) Dr. Dobb's Journal - April 2008 - Conversations (Page 19) Dr. Dobb's Journal - April 2008 - Fast String Search on Multicore Processors (Page 20) Dr. Dobb's Journal - April 2008 - Fast String Search on Multicore Processors (Page 21) Dr. Dobb's Journal - April 2008 - Fast String Search on Multicore Processors (Page 22) Dr. Dobb's Journal - April 2008 - Fast String Search on Multicore Processors (Page 23) Dr. Dobb's Journal - April 2008 - Fast String Search on Multicore Processors (Page 24) Dr. Dobb's Journal - April 2008 - Fast String Search on Multicore Processors (Page 25) Dr. Dobb's Journal - April 2008 - Fast String Search on Multicore Processors (Page 26) Dr. Dobb's Journal - April 2008 - Fast String Search on Multicore Processors (Page 27) Dr. Dobb's Journal - April 2008 - Fast String Search on Multicore Processors (Page 28) Dr. Dobb's Journal - April 2008 - Fast String Search on Multicore Processors (Page 29) Dr. Dobb's Journal - April 2008 - The Byzantine Generals Problem (Page 30) Dr. Dobb's Journal - April 2008 - The Byzantine Generals Problem (Page 31) Dr. Dobb's Journal - April 2008 - The Byzantine Generals Problem (Page 32) Dr. Dobb's Journal - April 2008 - The Byzantine Generals Problem (Page 33) Dr. Dobb's Journal - April 2008 - The Byzantine Generals Problem (Page 34) Dr. Dobb's Journal - April 2008 - The Byzantine Generals Problem (Page 35) Dr. Dobb's Journal - April 2008 - The Byzantine Generals Problem (Page 36) Dr. Dobb's Journal - April 2008 - The Byzantine Generals Problem (Page 37) Dr. Dobb's Journal - April 2008 - Optimizing Math-Intensive Applications with Fixed-Point Arithmetic (Page 38) Dr. Dobb's Journal - April 2008 - Optimizing Math-Intensive Applications with Fixed-Point Arithmetic (Page 39) Dr. Dobb's Journal - April 2008 - Optimizing Math-Intensive Applications with Fixed-Point Arithmetic (Page 40) Dr. Dobb's Journal - April 2008 - Optimizing Math-Intensive Applications with Fixed-Point Arithmetic (Page 41) Dr. Dobb's Journal - April 2008 - Optimizing Math-Intensive Applications with Fixed-Point Arithmetic (Page 42) Dr. Dobb's Journal - April 2008 - Optimizing Math-Intensive Applications with Fixed-Point Arithmetic (Page 43) Dr. Dobb's Journal - April 2008 - Random Numbers in a Range Using Generic Programming (Page 44) Dr. Dobb's Journal - April 2008 - Random Numbers in a Range Using Generic Programming (Page 45) Dr. Dobb's Journal - April 2008 - Random Numbers in a Range Using Generic Programming (Page 46) Dr. Dobb's Journal - April 2008 - Random Numbers in a Range Using Generic Programming (Page 47) Dr. Dobb's Journal - April 2008 - Random Numbers in a Range Using Generic Programming (Page 48) Dr. Dobb's Journal - April 2008 - The Agile Edge (Page 49) Dr. Dobb's Journal - April 2008 - The Agile Edge (Page 50) Dr. Dobb's Journal - April 2008 - The Agile Edge (Page 51) Dr. Dobb's Journal - April 2008 - Effective Concurrency (Page 52) Dr. Dobb's Journal - April 2008 - Effective Concurrency (Page 53) Dr. Dobb's Journal - April 2008 - Effective Concurrency (Page 54) Dr. Dobb's Journal - April 2008 - Effective Concurrency (Page 55) Dr. Dobb's Journal - April 2008 - Swaine's Flames (Page 56) Dr. Dobb's Journal - April 2008 - Swaine's Flames (Page Cover3) Dr. Dobb's Journal - April 2008 - Swaine's Flames (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.