Errata for "C++ and Object Oriented Numeric Computing for Scientists and Engineers", Daoqi Yang, Springer-Verlag, New York, 2001, ISBN: 0-387-98990-0.



If you find more errors in the book or have any suggestions on how to improve this book, please send them to me at: d_q_yang@yahoo.com. I feel grateful to those readers who have sent me comments and encouraged me to write a solution manual for the book (and other related books). Many of the items below are pointed out by Nicholas Brealey (nick@orpwood.demon.co.uk).

Pages and Lines

Errors

Corrections

Page ix, line -10

www.math.wayne.eud

www.math.wayne.edu

Page 3, lines 26,27

while a single character appear

while a single character must appear

Page 28, lines 22,25,31

reminder

remainder

Page 34, lines 33,36

... << &n;

... << &n << '\n';

Page 35, line 1

implemented using large integers

usually implemented using large integers

Page 55, line 1

double mt[2][5]

double mt[2][5];

Page 63, line 17

delete[] should

delete[] must

Page 66, line 16

*(*mx+i)+j), or *(&mx[0][0]+m*i+j).

*(*mx+i)+j).

Page 71, line 16

(sizeof(int*) bytes)

(sizeof(stack*) bytes)

Page 80, line -3

a, b,

const_cast<const double** const>(a), b,

Page 93, line 10

log2

log10

Page 96, lines -5 and -7

(a, 9, x)

(a, 8, x)

Page 101, line 16

library <assert.h>

library header <assert.h> or <cassert>

Page 128, line 1 and 3

__plusplus

__cplusplus

Page 144, line 28

(char* or const char*)

(const char*)

Page 155, line -16

ios::in

ios_base::in

Page 210, line 1

Cmpx operator++()

Cmpx& operator++()

Page 210, line 4

inline Cmpx Cmpx::operator++() {

inline Cmpx& Cmpx::operator++() {

Page 212, line16

space need be

space needs to be

Page 234, line 16

vec

v

Page 238, line 19

template <> friend

friend

Page 244, line 6

return strcmp(a,b)

return strcmp(a,b) < 0

Page 244, line 25

return strcmp(a,b)

return strcmp(a,b) < 0

Page 247, line 20

friend T dot(const

T dot(const

Page 256, line 34

{\it valarray}<size_t> vz(z,2);

valarray<size_t> vz(z,2);

Page 261, line 6

SumFcn

SumFcn<doulbe>

Page 262, line 11

BinOp2, op2

BinOp2 op2

Page 263, line -12

a2 - a0 - a1, ... , an-1 - a0 - a1 - ... - an-2

a2 - a1, ... , an-1 - an-2

Page 271, line 10

u[1]*v[0]

u[1]*v[1]

Page 305, line 9

pt2d->d

pd12->d

Page 307, line 12

// when $pa$ is not null pointer

// when pa is not null pointer

Page 307, line 14

// when $pa$ is null pointer

// when pa is null pointer

Page 323, after line 17

class Overflow: public MVErr {};

Page 323, line 18

class IntOverflow: public MVErr {};

class IntOverflow: public Overflow{};

Page 323, line 19

class FloatOverflow: public MVErr {};

class FloatOverflow: public Overflow{};

page 323, line 20

class Overflow: public IntOverflow. public FloatOverflow {};

(delete line.)

page 433, line 23

extern, 52

extern, 27, 52



Notes

Page vii, line 2: There should be a footnote giving number and title of the C++ standard (ISO/IEC 14882, Standard for the C++ Programming Language).

Page 22, line 9 and throughout the book: It is probably cleaner to use <cmath> instead of <math.h> in new ISO C++ code. With some non-standard compilers it may be necessary to use <math.h> while with other non-standard compilers it may be necessary to use <cmath>.

Page 45, line 18. It would be better to use a new style cast because these are safer and are described later in the book:
Replace (long double)fc by static_cast<long double>(fc).

Page 55, line 16. Most Fortran programmers would argue that C++ multidimensional arrays are inferior to multidimensional Fortran arrays which are much higher level objects and include most of the features of valarrays plus multidimensional indexing. Even in Fortran 77, Fortran multidimensional arrays are superior to C++ multidimensional arrays because Fortran allows them to be used as dummy arguments to procedures with the sizes of the arrays specified by other dummy arguments. The size of a C++ multidimensional array must be known at compile time.

Pages 57 to 60. The amount of space devoted to unions is excessive. Their use should be discouraged in favour of safer types of polymorphism.

Page 60, Pointers. The ISO C++ standard does not require that the the sizes of all pointers are the same and there are some machines for which it make sense to have different sizes of pointers for different types. I believe that old Cray computers addressed memory in terms of 64-bit words and would pack 8 8-bit characters into a word for arrays of characters. A char* could consist of the address of the word containing the character and the offset indicating the position of the character within the word. So the size of a char* could be bigger than the size of a double*.

Page 62, line 10. It should be emphasised that if you use [] with new you must use [] with the corresponding delete and if you don't have [] with new you must not use [] with the corresponding delete.

Page 66, line 16. The storage for mx is allocated in multiple new statements and it is not necessarily contiguous. The last form *(&mx[0][0]+m*i+j) is therefore wrong.

Page 130, line 10. g() is not declared static (deprecated) and has not been put in an unnamed namespace (preferred) so it can be used in other files if the other file includes a declaration:
void g(double);

Page 134 and 135. The example program should use endl instead of "\n" because this will flush output. The text should warn that using clock() to time programs is not reliable because, for example, clock_t may be a 32 bit signed integer and CLOCKS_PER_SEC may be 1000000 which leads to overflow in about half an hour.

Page 138 Creating a Library. On some systems the user must use an option with the C++ compiler to create an archive. The standard Unix ar command may not work with C++ because of complexities associated with templates.

Page 144, C-Style Strings. It should be pointed out that c_str() returns a pointer to an array of characters with a 0 terminator character. data() does not add the 0 terminator.

Page 146 to 149. This section should describe I/O manipulators:
cout.setf(ios_base::oct, ios_base::basefield);
cout << i << " " << i << '\n';
could be replaced by:
cout << oct << i << " " << i << '\n';