C++ for Mathematicians An Introduction for Students and Professionals | Edward Scheinerman

Computer Programming and IT Books ITBooksHub.com
Click Here To Download Book
Pages 521
Views 4200
Size 30.2 MB
Download 287
Table Of Contents

I Procedures

1 The Basics

1.1 What is C++?

1.2 Hello C++

1.3 Exercises

2 Number

2.1 The integer types

2.2 The real number types

2.3 The bool and char types

2.4 Checking the size and capacity of the different types

2.5 Standard operations

2.6 Comparisons and Boolean operations

2.7 Complex numbers

2.8 Naming variables

2.9 Exercises

3 Greatest Common Diviso

3.1 The problem

3.2 A first approach

3.3 Euclid’s method

3.4 Looping with for, while, and do

3.5 An exhaustive approach to the GCD problem

3.6 Extended gcd, call by reference, and overloading

3.7 Exercises

4 Random Number

4.1 Pseudo random number generation

4.2 Uniform random values

4.3 More on pseudo random number generation

4.4 A Monte Carlo program for the GCD problem

4.5 Normal random values

4.6 Exercises

5 Array

5.1 Euler’s totient

5.2 Array fundamentals

5.3 A procedure to factor integers

5.4 A procedure to calculate Euler’s totient

5.5 The Sieve of Eratosthenes: new and delete[]

5.6 A faster totient

5.7 Computi

for large n

5.8 The answer

5.9 Exercises

II Object

6 Points in the Plan

6.1 Data and methods

6.2 Declaring the Point class

6.3 Data hiding

6.4 Constructors

6.5 Assignment and conversion

6.6 Methods

6.7 Procedures using arguments of type Point

6.8 Operators

6.9 Exercises

7 Pythagorean Triples

7.1 Generating Pythagorean triples

7.2 Designing a primitive Pythagorean triple class

7.3 Implementation of the PTriple class

7.4 Finding and sorting the triples

7.5 Exercises

8 Containers

8.1 Sets

8.2 Set iterators

8.3 Multisets

8.4 Adjustable arrays via the vector class

8.5 Ordered pairs

8.6 Maps

8.7 Lists, stacks, and assorted queues

8.7.1 Lists

8.7.2 Stacks

8.7.3 Queues

Table of Contents

8.7.4 Deques

8.7.5 Priority queues

8.8 Exercises

9 Modular Arithmetic

9.1 Designing the Mod type

9.2 The code

9.3 The default modulus: Static class variables and methods

9.4 Constructors and get/set methods

9.5 Comparison operators

9.6 Arithmetic operators

9.7 Writing Mod objects to output streams

9.8 A main to demonstrate the Mod class

9.9 Exercises

10 The Projective Plane

10.1 Introduction to the projective plane

10.2 Designing the classes PPoint and PLine

10.3 Inheritance

10.4 Protected class members

10.5 Class and file organization for PPoint and PLine

10.6 The parent class PObject

10.7 The classes PPoint and PLine

10.8 Discovering and repairing a bug

10.9 Pappus revisited

10.10 Exercises

11 Permutations

11.1 Ulam’s problem

11.2 Designing the Permutation class

11.2.1 Data

11.2.2 Constructors and destructors

11.2.3 Copy and assign

11.2.4 Basic inspection and modification methods

11.2.5 Permutation operations

11.2.6 Comparison operators

11.2.7 Output

11.2.8 The code file Permutation.c

11.3 Finding monotone subsequences

11.4 Exercises

12 Polynomials

12.1 Procedure templates

12.2 Class templates

12.2.1 Using class templates

12.2.2 Creating class templates

12.3 The Polynomial class template

12.3.1 Data

12.3.2 Constructors

12.3.3 Get and set methods

12.3.4 Function methods

12.3.5 Equality

12.3.6 Arithmetic

12.3.7 Output to the screen

12.3.8 GCD

12.3.9 The code

12.4 The GCD problem revisited

12.5 Working in binary

12.5.1 Signed versus unsigned integers

12.5.2 Bit operations

12.5.3 The bitset class template

12.5.4 Class templates with non-type arguments

12.6 Exercises

13 Using Other Packages

13.1 Arbitrary precision arithmetic: The GMP package

13.2 Linear algebra

13.2.1 Two-dimensional arrays in C++

13.2.2 The TNT and JAMA packages

13.2.3 The newmat package

13.3 Other packages

13.4 Exercises

14 Strings, Input/Output, and Visualization

14.1 Character arrays

14.2 The string class

14.2.1 Initialization

14.2.2 Fundamental operations

14.2.3 Searching

14.2.4 Converting between string and

14.3 Command line arguments

14.4 Reading and writing data in files

14.4.1 Opening files for input/output

14.4.2 Reading and writing

Table of Content

14.4.3 Detecting the end of an input file

14.4.4 Other methods for input

14.5 String streams

14.6 Formatting

14.6.1 Setting precision

14.6.2 Showing all digits

14.6.3 Setting the width

14.6.4 Other manipulators

14.7 A class to parse files

14.8 Visualization

14.8.1 Introducing and installing the plotutils package

14.8.2 Drawing with plotutils—a first example

14.8.3 Pascal’s triangle modulo two

14.8.4 Tracing the motion of a point moving randomly in a triangle

14.8.5 Drawing Paley graphs

14.9 Exercises

15 Odds and Ends

15.1 The switch statement

15.2 Labels and the goto statement

15.3 Exception handling

15.3.1 The basics of try, throw, and catch

15.3.2 Other features of the exception-handling system

15.4 Friends

15.5 Other ways to create types

15.5.1 Structures

15.5.2 Enumerations

15.5.3 Unions

15.5.4 Using typedef

15.6 Pointers

15.6.1 Pointer basics

15.6.2 Dereferencing

15.6.3 Arrays and pointer arithmetic

15.6.4 new and delete revisited

15.6.5 Why use pointers?

15.7 Exercises

A Your C++ Computing Environment

A.1 Programming with a command window and a text editor

A.1.1 What you need and how to get it (for free)

A.1.2 Editing program files

A.1.3 Compiling and running your program

A.1.4 Compiler options

A.1.5 Introduction to make

A.2 Programming with an integrated development environment

A.2.1 Visual C++ for Windows

A.2.2 Xcode for Macintosh OS X

A.3 General advice on debugging

B Documentation with Doxygen

B.1 Doxygen comments

B.1.1 Documenting files

B.1.2 Documenting procedures

B.1.3 Documenting classes, data, and methods

B.2 Using Doxygen

B.2.1 Configuring Doxygen

B.2.2 Running Doxygen

B.2.3 More features

C C++ Reference

C.1 Variables and types

C.1.1 Fundamental types

C.1.2 Standard classes/templates

C.1.3 Declaring variables

C.1.4 Static variables and scope

C.1.5 Constants and the keyword const

C.1.6 Arrays

C.2 Operations

C.2.1 Assignment

C.2.2 Arithmetic

C.2.3 Comparison operators

C.2.4 Logical operators

C.2.5 Bit operators

C.2.6 Potpourri

C.3 Control statements

C.3.1 if-else

C.3.2 Looping: for, while, and do

C.3.3 switch

C.3.4 goto

C.3.5 Exceptions

C.4 Procedures

C.4.1 File organization

C.4.2 Call by value versus call by reference

C.4.3 Array (and pointer) arguments

C.4.4 Default values for arguments

C.4.5 Templates

C.4.6 inline procedures

C.5 Classes

C.5.1 Overview and file organization

C.5.2 Constructors and destructors

C.5.3 Operators

C.5.4 Copy and assign

C.5.5 static data and methods

C.5.6 this

C.5.7 Friends

C.5.8 Class templates

C.5.9 Inheritance

C.6 Standard functions

C.6.1 Mathematical functions

C.6.2 Mathematical constants

C.6.3 Character procedures

C.6.4 Other useful functions

D Answers