tailieunhanh - Lecture Programming principles and practice using C++: Chapter 24 - Bjarne Stroustrup

This lecture is an overview of the fundamental tools and techniques for numeric computation. For some, numerics are everything. For many, numerics are occasionally essential. Here, we present the basic problems of size, precision, truncation, and error handling in standard mathematical functions. We present multidimensional matrices and the standard library complex numbers. | Chapter 24 Numerics Bjarne Stroustrup Abstract This lecture is an overview of the fundamental tools and techniques for numeric computation. For some, numerics are everything. For many, numerics are occasionally essential. Here, we present the basic problems of size, precision, truncation, and error handling in standard mathematical functions. We present multidimensional matrices and the standard library complex numbers. Stroustrup/PPP - Nov'13 Overview Precision, overflow, sizes, errors Matrices Random numbers Complex numbers Please note: Again, we are exploring how to express the fundamental notions of an application domain in code Numerical computation, especially linear algebra We are showing the basic tools only. The computational techniques for using these tools well, say in engineering calculations, you’ll have to learn elsewhere That’s “domain knowledge” beyond the scope of this presentation Stroustrup/PPP - Nov'13 Precision, etc. When we | Chapter 24 Numerics Bjarne Stroustrup Abstract This lecture is an overview of the fundamental tools and techniques for numeric computation. For some, numerics are everything. For many, numerics are occasionally essential. Here, we present the basic problems of size, precision, truncation, and error handling in standard mathematical functions. We present multidimensional matrices and the standard library complex numbers. Stroustrup/PPP - Nov'13 Overview Precision, overflow, sizes, errors Matrices Random numbers Complex numbers Please note: Again, we are exploring how to express the fundamental notions of an application domain in code Numerical computation, especially linear algebra We are showing the basic tools only. The computational techniques for using these tools well, say in engineering calculations, you’ll have to learn elsewhere That’s “domain knowledge” beyond the scope of this presentation Stroustrup/PPP - Nov'13 Precision, etc. When we use the built-in types and usual computational techniques, numbers are stored in fixed amounts of memory Floating-point numbers are (only) approximations of real numbers float x = ; float sum = 0; for (int i=0; i Stroustrup/PPP - Nov'13 Sizes The exact sizes of C++ built-in types depends on the hardware and the compiler These sizes are for Windows using Microsoft , GCC on Linux, and others sizeof(x) gives you the size of x in bytes By definition, sizeof(char)==1 Unless you have a very good reason for something else, stick to bool, char, int, and double char int short double float long int* Stroustrup/PPP - Nov'13 Sizes, overflow, truncation // when you .