Book contents
- Frontmatter
- Contents
- Preface
- Part I Numerical Software
- Part II Developing Software
- Part III Efficiency in Time, Efficiency in Memory
- 11 Be algorithm aware
- 12 Computer architecture and efficiency
- 13 Global vs. local optimization
- 14 Grabbing memory when you need it
- 15 Memory bugs and leaks
- Part IV Tools
- Part V Design Examples
- Appendix A Review of vectors and matrices
- Appendix B Trademarks
- References
- Index
11 - Be algorithm aware
Published online by Cambridge University Press: 28 January 2010
- Frontmatter
- Contents
- Preface
- Part I Numerical Software
- Part II Developing Software
- Part III Efficiency in Time, Efficiency in Memory
- 11 Be algorithm aware
- 12 Computer architecture and efficiency
- 13 Global vs. local optimization
- 14 Grabbing memory when you need it
- 15 Memory bugs and leaks
- Part IV Tools
- Part V Design Examples
- Appendix A Review of vectors and matrices
- Appendix B Trademarks
- References
- Index
Summary
Be aware of algorithms that can be useful to you. There are many textbooks on algorithms and data structure. One of the more encyclopedic is the book by Cormen, Leiserson, Rivest, and Stein [23].
Scientific and engineering software almost always needs to be efficient in both time and memory. You should first consider optimizing at a high level, choosing data structures and algorithms that are inherently efficient. At a lower level, you should understand how computers work, and how to efficiently use modern computer architectures.
Choosing good algorithms and data structures is the foundation of designing efficient software. Without this, no amount of low-level tweaking of the code will make it run fast. This is especially true for large problems. By tuning your code you could gain an improvement of anything from, say, a factor of two to a factor of ten, in the speed of an algorithm. But moving from an algorithm that is O(n3) in time and O(n2) in memory to one that is O(n2) in time and O(n) in memory can give you a much greater benefit, especially if n ≍ 10 000 or larger. Sometimes you can get approximate algorithms that are fast, but the speed will depend on how accurately you want the answer. Here you need to know the problem well in order to see how large an error can be tolerated.
Numerical algorithms
Since the development of electronic digital computers (and even well before then) there has been a great deal of development of numerical algorithms. Many are highly efficient, accurate, and robust.
- Type
- Chapter
- Information
- Writing Scientific SoftwareA Guide to Good Style, pp. 149 - 155Publisher: Cambridge University PressPrint publication year: 2006