C++ for Scientists - Technische Universität Dresden
C++ for Scientists - Technische Universität Dresden C++ for Scientists - Technische Universität Dresden
252 CHAPTER 11. C++ LIBRARIES FOR SCIENTIFIC COMPUTING
Real-World Programming Chapter 12 12.1 Transcending Legacy Applications Legacy application has been written in plain ANSI C or are available as Fortran libraries. It is therefore highly desirable to rejuvenate the implementation which is already available so that it utilizes advanced technologies and techniques while at the same time keeping as much of the already obtained experience and trust related to the original code base. One approach for the transition is possible by an evolutionary fashion initially including as much of the old implementation as possible and gradually replacing it to bring it up to date. The following examples are based on a particle simulator, where to important concepts can be separated: scattering mechanisms (physical behaviour of particles at boundaries (TODO: PS)) and physical model descriptions (how particles interact (TODO: PS) ). All available scattering mechanisms are implemented as individual functions, which are called subsequently. The scattering models require a variable set of parameters, which leads to non-homogeneous interfaces in the functions representing them. To alleviate this to some extent global variables have been employed completely eliminating any aspirations of data encapsulation and posing a serious problem for attempts for parallelization to take advantage of modern multi-core CPUs. The code has the very simple and repetitive structure: double sum = 0; double current rate = generate random number(); if (A key == on) { sum = A rate(state, parameters); if (current rate < sum) { counter→ A[state→ valley]++; state after A (st, p); return; } } sum += B rate (state, state 2, parameters); 253
- Page 202 and 203: 202 CHAPTER 7. EFFECTIVE PROGRAMMIN
- Page 204 and 205: 204 CHAPTER 7. EFFECTIVE PROGRAMMIN
- 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: 11.7. GEOMETRIC LIBRARIES 251 11.7.
- Page 255 and 256: 12.1. TRANSCENDING LEGACY APPLICATI
- Page 257 and 258: 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
Real-World Programming<br />
Chapter 12<br />
12.1 Transcending Legacy Applications<br />
Legacy application has been written in plain ANSI C or are available as Fortran libraries. It is<br />
there<strong>for</strong>e highly desirable to rejuvenate the implementation which is already available so that<br />
it utilizes advanced technologies and techniques while at the same time keeping as much of<br />
the already obtained experience and trust related to the original code base. One approach<br />
<strong>for</strong> the transition is possible by an evolutionary fashion initially including as much of the old<br />
implementation as possible and gradually replacing it to bring it up to date.<br />
The following examples are based on a particle simulator, where to important concepts can be<br />
separated: scattering mechanisms (physical behaviour of particles at boundaries (TODO: PS))<br />
and physical model descriptions (how particles interact (TODO: PS) ). All available scattering<br />
mechanisms are implemented as individual functions, which are called subsequently. The scattering<br />
models require a variable set of parameters, which leads to non-homogeneous interfaces<br />
in the functions representing them. To alleviate this to some extent global variables have been<br />
employed completely eliminating any aspirations of data encapsulation and posing a serious<br />
problem <strong>for</strong> attempts <strong>for</strong> parallelization to take advantage of modern multi-core CPUs. The<br />
code has the very simple and repetitive structure:<br />
double sum = 0;<br />
double current rate = generate random number();<br />
if (A key == on)<br />
{<br />
sum = A rate(state, parameters);<br />
if (current rate < sum)<br />
{<br />
counter→ A[state→ valley]++;<br />
state after A (st, p);<br />
return;<br />
}<br />
}<br />
sum += B rate (state, state 2, parameters);<br />
253