C++ for Scientists - Technische Universität Dresden
C++ for Scientists - Technische Universität Dresden C++ for Scientists - Technische Universität Dresden
256 CHAPTER 12. REAL-WORLD PROGRAMMING By supplying the required parameters at construction time it is possible to homogenize the interface of the operator(). This methodology also allows the continued use of the old data structures in the initial phases of transition, while not being so constrictive as to hamper future developments. The functions for the state transitions are treated similarly to those for the rate calculation. Both are then fused in a scattering pack to form the complete scattering model and to ensure consistency of the rate and state transition calculations and which also models the runtime concept as can be seen in the following part of code: template struct scattering pack { // ... scattering rate type rate calculation; transition type state transition; scattering pack (const parameter type& parameters) : rate calculation(parameters), state transition(parameters) {} template numeric type rate(const StateType& state) const { return rate calculation(state); } template void transition(StateType& state) { state transition(state); } } The blend of runtime and compile time mechanisms allows the storage of all scattering models within a single container, e.g. std::vector, which can be iterated over in order to evaluate them. typedef std::vector scatter container type ; scatter container type scatter container ; scatter container.push back(scattering model) ; For the development of new collision models easy extendability, even without recompilations, is also a highly important issue. This approach allows the addition of scattering models at runtime and to expose an interface to an interpreted language such as, e.g., Python [?]. In case a highly optimized version is desired, the runtime container (here the std::vector) may be exchanged by a compile time container, which is also readily available from the GSSE and provides the compiler with further opportunities for optimizations at the expense of runtime adaptability.
12.1. TRANSCENDING LEGACY APPLICATIONS 257 12.1.2 Reuse Something Appropriate While the described approach initially slightly increases the burden of implementation, due to the fact, that wrappers need to be provided, it gives a transition path to integrate legacy codes into an up to date frame while at the same time not to abandoning the experience associated with it. The invested effort allows to raise the level of abstraction, which in turn allows to increase the benefits obtained from the advances in compiler technologies. This in turn inherently allows an optimization for several platforms without the need for massive human effort, which was needed in previous approaches. In this particular case, encapsulating the reliance on global variables of the functions implementing the scattering models to the wrapping structures, parallelization efforts are greatly facilitated, which are increasingly important with the continued increase of computing cores per CPU. Furthermore the results can easily be verified as code parts a gradually moved to newer implementations, the only stringent requirement being link compatibility with C ++. This test and verification can be taken a step further in case the original implementation is written in ANSI C, due to the high compatibility of it to C ++. It is possible to weave parts of the new implementation into the older code. Providing the opportunity to get very a fine grained comparison not only of final results, but of all the intermediates as well. Such swift verification of implementations allows to also speed up the steps necessary to verify calculated results with subsequent or contemporary experiments, which should not be neglected, in order to keep physical models and their numerical representations strongly rooted in reality.
- Page 206 and 207: 206 CHAPTER 7. EFFECTIVE PROGRAMMIN
- Page 208 and 209: 208 CHAPTER 7. EFFECTIVE PROGRAMMIN
- Page 210 and 211: 210 CHAPTER 7. EFFECTIVE PROGRAMMIN
- Page 212 and 213: 212 CHAPTER 7. EFFECTIVE PROGRAMMIN
- Page 214 and 215: 214 CHAPTER 7. EFFECTIVE PROGRAMMIN
- Page 216 and 217: 216 CHAPTER 7. EFFECTIVE PROGRAMMIN
- Page 218 and 219: 218 CHAPTER 7. EFFECTIVE PROGRAMMIN
- Page 220 and 221: 220 CHAPTER 7. EFFECTIVE PROGRAMMIN
- Page 222 and 223: 222 CHAPTER 7. EFFECTIVE PROGRAMMIN
- Page 225 and 226: Finite World of Computers Chapter 8
- Page 227 and 228: 8.2. MORE NUMBERS AND BASIC STRUCTU
- Page 229 and 230: 8.2. MORE NUMBERS AND BASIC STRUCTU
- Page 231 and 232: 8.4. THE OTHER WAY AROUND 231 As ca
- Page 233 and 234: How to Handle Physics on the Comput
- Page 235 and 236: Programming tools Chapter 10 In thi
- Page 237 and 238: 10.2. DEBUGGING 237 T& glas::contin
- Page 239 and 240: 10.3. VALGRIND 239 Stepi and Nexti
- Page 241 and 242: 10.5. UNIX AND LINUX 241 • top: l
- Page 243 and 244: C ++ Libraries for Scientific Compu
- Page 245 and 246: 11.3. BOOST.BINDINGS 245 • Math a
- Page 247 and 248: 11.3. BOOST.BINDINGS 247 #include
- Page 249 and 250: 11.4. MATRIX TEMPLATE LIBRARY 249 c
- Page 251 and 252: 11.7. GEOMETRIC LIBRARIES 251 11.7.
- Page 253 and 254: Real-World Programming Chapter 12 1
- Page 255: 12.1. TRANSCENDING LEGACY APPLICATI
- Page 259 and 260: Parallelism Chapter 13 13.1 Multi-T
- Page 261 and 262: 13.2. MESSAGE PASSING 261 int main
- Page 263 and 264: Numerical exercises Chapter 14 In t
- Page 265 and 266: 14.1. COMPUTING AN EIGENFUNCTION OF
- Page 267 and 268: 14.1. COMPUTING AN EIGENFUNCTION OF
- Page 269 and 270: 14.1. COMPUTING AN EIGENFUNCTION OF
- Page 271 and 272: 14.1. COMPUTING AN EIGENFUNCTION OF
- Page 273 and 274: 14.3. THE SOLUTION OF A SYSTEM OF D
- Page 275 and 276: 14.4. GOOGLE’S PAGE RANK 275 Taki
- Page 277 and 278: 14.5. THE BISECTION METHOD FOR FIND
- Page 279 and 280: 14.6. THE NEWTON-RAPHSON METHOD FOR
- Page 281 and 282: 14.7. SEQUENTIAL NOISE REDUCTION OF
- Page 283 and 284: 14.7. SEQUENTIAL NOISE REDUCTION OF
- Page 285 and 286: Programmierprojekte Kapitel 15 Die
- Page 287 and 288: 15.6. MATRIX-SKALIERUNG 287 Siehe h
- Page 289 and 290: 15.10. ANWENDUNG MTL4 AUF TYPEN MIT
- Page 291 and 292: Acknowledgement Chapter 16 Special
- Page 293: Bibliography [AG04] David Abrahams
12.1. TRANSCENDING LEGACY APPLICATIONS 257<br />
12.1.2 Reuse Something Appropriate<br />
While the described approach initially slightly increases the burden of implementation, due<br />
to the fact, that wrappers need to be provided, it gives a transition path to integrate legacy<br />
codes into an up to date frame while at the same time not to abandoning the experience<br />
associated with it. The invested ef<strong>for</strong>t allows to raise the level of abstraction, which in turn<br />
allows to increase the benefits obtained from the advances in compiler technologies. This in<br />
turn inherently allows an optimization <strong>for</strong> several plat<strong>for</strong>ms without the need <strong>for</strong> massive human<br />
ef<strong>for</strong>t, which was needed in previous approaches.<br />
In this particular case, encapsulating the reliance on global variables of the functions implementing<br />
the scattering models to the wrapping structures, parallelization ef<strong>for</strong>ts are greatly<br />
facilitated, which are increasingly important with the continued increase of computing cores<br />
per CPU.<br />
Furthermore the results can easily be verified as code parts a gradually moved to newer implementations,<br />
the only stringent requirement being link compatibility with C ++. This test and<br />
verification can be taken a step further in case the original implementation is written in ANSI<br />
C, due to the high compatibility of it to C ++. It is possible to weave parts of the new implementation<br />
into the older code. Providing the opportunity to get very a fine grained comparison<br />
not only of final results, but of all the intermediates as well.<br />
Such swift verification of implementations allows to also speed up the steps necessary to verify<br />
calculated results with subsequent or contemporary experiments, which should not be neglected,<br />
in order to keep physical models and their numerical representations strongly rooted in reality.