Preface... 1 The Boost C++ Libraries Overview... 5 Math Toolkit: Special Functions Math Toolkit: Orthogonal Functions... 29

Similar documents
Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

Distance Learning Advanced C++ - Programming Models, boost and Parallel Computing

4.1.2 Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting...

SRI VENKATESWARA COLLEGE OF ENGINEERING. COURSE DELIVERY PLAN - THEORY Page 1 of 6

COURSE: DATA STRUCTURES USING C & C++ CODE: 05BMCAR17161 CREDITS: 05

Introduction to Algorithms Third Edition

Contents. Preface xvii Acknowledgments. CHAPTER 1 Introduction to Parallel Computing 1. CHAPTER 2 Parallel Programming Platforms 11

Introductory Combinatorics

Algorithm Design (8) Graph Algorithms 1/2

r=1 The Binomial Theorem. 4 MA095/98G Revision

Fundamentals of Discrete Mathematical Structures

Department of Information Technology

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned.

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

Computational Discrete Mathematics

Index. stack-based, 400 A* algorithm, 325

DESIGN AND ANALYSIS OF ALGORITHMS

M.Sc. (Computer Science) I Year Assignments for May Paper I DATA STRUCTURES Assignment I

Question Paper Code : 97044

Applied Combinatorics

Analysis of Algorithms

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: CS6402- Design & Analysis of Algorithm Year/Sem : II/IV UNIT-I INTRODUCTION

Chapter 9 Graph Algorithms

The Algorithm Design Manual

Chapter 9 Graph Algorithms

Review of course COMP-251B winter 2010

CSC 8301 Design & Analysis of Algorithms: Warshall s, Floyd s, and Prim s algorithms

Chapter 9 Graph Algorithms

DISCRETE MATHEMATICS

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Jörgen Bang-Jensen and Gregory Gutin. Digraphs. Theory, Algorithms and Applications. Springer

Table of Contents. Chapter 1: Introduction to Data Structures... 1

Data Structures in C++ Using the Standard Template Library

Department of Computer Science SEMESTER-III CC-5 (Theory): Data Structures

Data Structures and Algorithm Analysis in C++

DEPARTMENT - Mathematics. Coding: N Number. A Algebra. G&M Geometry and Measure. S Statistics. P - Probability. R&P Ratio and Proportion

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

SUGGESTION : read all the questions and their values before you start.

Graph Algorithms (part 3 of CSC 282),

Part I Basic Concepts 1

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

Total No. of Questions : 18] [Total No. of Pages : 02. M.Sc. DEGREE EXAMINATION, DEC First Year COMPUTER SCIENCE.

About the Author. Dependency Chart. Chapter 1: Logic and Sets 1. Chapter 2: Relations and Functions, Boolean Algebra, and Circuit Design

n 2 ( ) ( ) + n is in Θ n logn

Solving problems on graph algorithms

Virtual University of Pakistan

DATA STRUCTURES THROUGH C++

Problem 1. Which of the following is true of functions =100 +log and = + log? Problem 2. Which of the following is true of functions = 2 and =3?

Konigsberg Bridge Problem

( ) n 3. n 2 ( ) D. Ο

CS521 \ Notes for the Final Exam

Reference Sheet for CO142.2 Discrete Mathematics II

Review for Midterm Exam

Contents. I The Basic Framework for Stationary Problems 1

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

JAVA PROGRAMMING. Unit-3 :Creating Gui Using The Abstract Windowing Toolkit:

RBGL: R interface to boost graph library

Chapter 1 Introduction

L.J. Institute of Engineering & Technology Semester: VIII (2016)

Parallel Graph Algorithms

Notation Index. Probability notation. (there exists) (such that) Fn-4 B n (Bell numbers) CL-27 s t (equivalence relation) GT-5.

END-TERM EXAMINATION

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1

MATHEMATICAL STRUCTURES FOR COMPUTER SCIENCE

SECOND SEMESTER BCA : Syllabus Copy

ENGINEERING PROBLEM SOLVING WITH C++

Introduction to Parallel & Distributed Computing Parallel Graph Algorithms

THE DESIGN AND ANALYSIS OF COMPUTER ALGORITHMS

Graph Algorithms. Parallel and Distributed Computing. Department of Computer Science and Engineering (DEI) Instituto Superior Técnico.

Discrete Mathematics SECOND EDITION OXFORD UNIVERSITY PRESS. Norman L. Biggs. Professor of Mathematics London School of Economics University of London

DR. JIVRAJ MEHTA INSTITUTE OF TECHNOLOGY

Contents. I Basics 1. Copyright by SIAM. Unauthorized reproduction of this article is prohibited.

Graph Algorithms (part 3 of CSC 282),

9. Which situation is true regarding a cascading cut that produces c trees for a Fibonacci heap?

UNIT I Linux Utilities

OBJECT ORIENTED DATA STRUCTURE & ALGORITHMS


Communication Networks I December 4, 2001 Agenda Graph theory notation Trees Shortest path algorithms Distributed, asynchronous algorithms Page 1

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

LOGIC AND DISCRETE MATHEMATICS

F. THOMSON LEIGHTON INTRODUCTION TO PARALLEL ALGORITHMS AND ARCHITECTURES: ARRAYS TREES HYPERCUBES

DEPARTMENT OF COMPUTER APPLICATIONS B.C.A. - FIRST YEAR ( REGULATION) SECOND SEMESTER LESSON PLAN SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

Porting the NAS-NPB Conjugate Gradient Benchmark to CUDA. NVIDIA Corporation

Lecture 4: Graph Algorithms

Notation Index 9 (there exists) Fn-4 8 (for all) Fn-4 3 (such that) Fn-4 B n (Bell numbers) CL-25 s ο t (equivalence relation) GT-4 n k (binomial coef

( ) 1 B. 1. Suppose f x

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

M.Sc. (Previous) DEGREE EXAMINATION, MAY (Examination at the end of First Year) Computer Science. Paper - I : DATA STRUCTURES

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

Honors Precalculus: Solving equations and inequalities graphically and algebraically. Page 1

Shortest path problems

LINUX INTERNALS & NETWORKING Weekend Workshop

Michel Raynal. Distributed Algorithms for Message-Passing Systems

Minimum Spanning Trees

HiQ Analysis, Visualization, and Report Generation

Written exam for EE2T21 (Part B) Data Communications Networking

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

Transcription:

Preface... 1 Goals of this Book... 1 Structure of the Book... 1 For whom is this Book?... 1 Using the Boost Libraries... 2 Practical Hints and Guidelines... 2 What s Next?... 2 1 The Boost C++ Libraries Overview... 5 1.1 Library Classification... 5 1.2 Essential Libraries... 6 1.3 Supporting Libraries... 7 2 Math Toolkit: Special Functions... 10 2.1 Introduction and Objectives... 10 2.2 An Overview of the Math Toolkit Special Functions... 10 2.3 Gamma Functions... 11 2.3.1 Gamma Function... 11 2.3.2 Incomplete Gamma Functions and their Inverses... 12 2.4 Beta and Error Functions... 14 2.5 Incomplete Beta Functions and their Inverses... 15 2.6 Factorials and Binomial Coefficients... 15 2.7 The Error Function and its Inverse... 17 2.8 Bessel Functions... 18 2.9 Elliptic Integral Functions... 20 2.9.1 Elliptic Integrals of the First, Second and Third Kinds... 20 2.9.2 Complete Elliptic Integrals... 20 2.10 Other Functions... 22 2.10.1 Zeta Function... 22 2.10.2 Exponential Integrals... 22 2.10.3 Inverse Hyperbolic Functions... 22 2.11 Sinus Cardinal and Hyperbolic Sinus Cardinal Functions... 23 2.12 Rounding, Truncation and Integer Conversions... 24 2.13 Applications and Relationships with STL and Boost... 28 2.14 Summary and Conclusions... 28 3 Math Toolkit: Orthogonal Functions... 29 3.1 Introduction and Objectives... 29 3.2 An Introduction to Orthogonal Polynomials... 29 3.3 Common Properties... 29 3.4 Laguerre and Hermite Polynomials... 33 3.5 Spherical Harmonics... 35 3.6 Chebychev Polynomials... 36 3.7 Computing the Roots of Bessel Functions... 37 3.8 Statistics Distributions... 39 3.9 Summary and Conclusions... 42 4 Date and Time... 43 4.1 Introduction and Objectives... 43 4.2 Overview of Concepts and Functionality... 43 4.3 Gregorian Time... 44 4.3.1 Date... 44

ii Table of Contents 4.3.2 Date Duration... 47 4.3.3 Date Period... 49 4.3.4 Date Iterators... 52 4.4 Creating User-defined Utilities... 53 4.4.1 A generic Date Iterator using Boost Variant... 53 4.4.2 General Schedules of Date Period... 55 4.4.3 International Money Market (IMM) Dates in Trading Systems... 56 4.5 Posix Time System... 57 4.6 Local Time... 59 4.7 Date Generators and Algorithms... 60 4.8 Date/Time I/O and Serialisation... 61 4.9 Set-Like Operations... 63 4.10 Application Areas... 64 4.11 Summary and Conclusions... 64 5 Some Building Block Data Structures and Libraries... 66 5.1 Introduction and Objectives... 66 5.2 Timer Library... 66 5.3 Uuid (Universally Unique Identifiers)... 68 5.3.1 Creating Uuids... 68 5.3.2 Other Functionality... 69 5.4 Dynamic Bitset and STL Bitsets... 70 5.4.1 Boolean Operations... 72 5.4.2 Type Conversions... 73 5.4.3 dynamic_bitset... 73 5.4.4 Applications of Dynamic Bitsets... 73 5.5 Circular Buffer... 74 5.5.1 The Boost Circular Buffer Class... 75 5.5.2 Using Circular Buffer: Producer-Consumer Pattern... 77 5.6 Summary and Conclusions... 80 6 Matrix Algebra in Boost Part I: ublas Data Structures... 81 6.1 Introduction and Objectives... 81 6.2 BLAS (Basic Linear Algebra Subprograms)... 81 6.2.1 BLAS Level 1... 82 6.2.2 BLAS Level 2... 82 6.2.3 BLAS Level 3... 82 6.3 Dense Vectors... 83 6.3.1 Creating and Accessing Dense Vectors... 84 6.3.2 Special Dense Vectors... 85 6.4 Sparse Vectors... 86 6.4.1 Mapped Vector... 86 6.4.2 Compressed Vector... 88 6.4.3 Coordinate Vector... 89 6.5 Dense Matrices... 89 6.5.1 Creating and Accessing Dense Matrices... 90 6.5.2 Special Dense Matrices... 91 6.6 Other Kinds of Matrices... 92 6.6.1 Sparse Matrices... 92 6.6.2 Triangular Matrices... 94 6.6.3 Triangular Adaptor... 94 6.7 Summary and Conclusions... 95

iii 7 Matrix Algebra in Boost Part II: Advanced Features and Applications... 96 7.1 Introduction and Objectives... 96 7.2 Patterned Matrices... 96 7.2.1 Symmetric Matrices... 96 7.2.2 Hermitian Matrices... 99 7.2.3 Banded Matrices... 100 7.3 Vector and Matrix Proxies... 101 7.3.1 Vector Range... 101 7.3.2 Vector Slice... 102 7.3.3 Matrix Proxies: Rows and Columns... 102 7.3.4 Matrix Views: What are Options?... 103 7.4 Vector Expressions... 105 7.5 Matrix Expressions... 108 7.6 Applying ublas: Solving Linear Systems of Equations... 110 7.6.1 Conjugate Gradient Method (CGM)... 110 7.6.2 LU Decomposition... 112 7.6.3 Cholesky Decomposition... 114 7.7 Applications of ublas... 117 7.8 Summary and Conclusions... 117 8 An Introduction to Network Programming Concepts and Protocols... 118 8.1 Introduction and Objectives... 118 8.2 Overview of OSI and TCP/IP Protocols and Services... 118 8.3 Internet Addresses... 120 8.3.1 Some Special IP Addresses... 121 8.4 Internet Addresses in Boost... 121 8.4.1 Implementing Endpoints... 123 8.5 Domain Name System (DNS)... 124 8.6 Client-Server Model of Interaction... 125 8.6.1 Connectionless and Connection-Oriented Servers... 126 8.7 The Socket Interface... 126 8.8 Protocol for Acknowledgement and Retransmission... 127 8.9 Summary and Conclusions... 128 9 Boost ASIO: Synchronous Operations... 129 9.1 Introduction... 129 9.1.1 Testing Network Applications and Troubleshooting... 130 9.2 DNS... 131 9.2.1 Reverse DNS... 133 9.3 Buffers... 133 9.4 UDP... 135 9.4.1 Example: UDP Echo Server... 136 9.4.2 Example: UDP Echo Client... 137 9.5 TCP... 138 9.5.1 Example: TCP Echo Server... 138 9.5.2 Example: TCP Echo Client... 141 9.5.3 Using Socket IOStreams to improve Ease of Use... 142 9.6 Summary and Conclusions... 144 10 Boost ASIO: Asynchronous Operations... 145 10.1 Introduction... 145 10.2 Timers... 146 10.2.1 Synchronous Deadline Timer... 146

iv Table of Contents 10.2.2 Asynchronous Deadline Timer... 146 10.2.3 Binding Arguments... 147 10.2.4 Binding to Member Functions... 148 10.2.5 Thread Pooling and Synchronising Threads... 149 10.3 Asynchronous UDP Server... 151 10.4 Asynchronous TCP Server... 153 10.4.1 The ASyncEchoServer Class... 154 10.4.2 The ASyncConnection Class... 155 10.5 Thread-Pooled Asynchronous TCP Server... 157 10.6 CRC Checksums and Time-outs... 159 10.6.1 Message and CRC... 159 10.6.2 Heartbeats and Time-outs... 162 10.6.3 Sending messages... 163 10.6.4 Echo Client Implementation... 163 10.7 Summary and Conclusions... 173 11 Boost Interprocess: IPC Mechanisms... 174 11.1 Introduction and Objectives... 174 11.2 Persistence of IPC Mechanisms... 174 11.3 Shared Memory... 175 11.4 Memory Mapped File... 178 11.5 Advanced Mapped Regions... 179 11.5.1 Pointers in Mapped Regions... 179 11.5.2 Static Members in Mapped Regions... 182 11.6 Managed Memory Segments... 183 11.6.1 Managed Shared Memory... 183 11.6.2 Managed Memory Mapped File... 184 11.6.3 Allocating Memory Fragments in Managed Memory... 185 11.6.4 Allocating Objects in Managed Memory... 185 11.6.5 Synchronisation of Object Construction and Retrieving... 187 11.6.6 Composite Objects... 187 11.6.7 Synchronising Composite Object Creation... 190 11.6.8 Using Allocators... 191 11.6.9 Other Allocators... 195 11.6.10 STL Compatible Containers... 195 11.6.11 Managed External Buffer and Managed Heap Memory... 198 11.6.12 Other Managed Segment Functionality... 201 11.7 Summary and Conclusions... 201 12 Boost Interprocess II: Process Synchronisation... 202 12.1 Introduction and Objectives... 202 12.2 Mutexes... 202 12.2.1 Mutex Operations... 203 12.2.2 Named Mutex... 203 12.2.3 Anonymous Mutex... 204 12.2.4 Scoped Lock... 206 12.3 Condition Variables... 208 12.4 Message Queue... 212 12.5 Semaphores... 213 12.6 Upgradable Mutexes... 217 12.6.1 Introduction to Upgradable Mutexes... 217 12.6.2 Upgradable Mutexes in Boost Interprocess... 218

v 12.6.3 Lock Transfer... 221 12.7 Summary and Conclusions... 222 13 Interval Arithmetic... 223 13.1 Introduction and Objectives... 223 13.2 What is Interval Analysis, Interval Arithmetic, Interval Mathematics?... 223 13.3 Interval Arithmetic: Mathematical Foundations... 226 13.4 Boost Interval Library: Functionality and Initial Examples... 227 13.5 Application: Matrix Computations with Intervals... 230 13.6 Function Evaluation in Interval... 232 13.7 Advanced Functions and Related Data Structures... 234 13.8 Solution of Nonlinear Equations... 236 13.9 Summary and Conclusions... 238 14 User-defined Memory Allocation: Boost Pool... 239 14.1 Introduction and Objectives... 239 14.2 Dynamic Memory Allocation in C++ and STL Allocator Requirements... 239 14.3 Pool Concepts... 240 14.3.1 Simple Segregated Storage Concept... 241 14.4 Pool... 242 14.5 Singleton Pool... 244 14.6 Object Pool... 246 14.7 Pool Allocator and Fast Pool Allocator... 247 14.8 Summary and Conclusions... 248 15 An Introduction to Graph Theory and Graph Algorithms... 249 15.1 Introduction and Objectives... 249 15.2 Directed and Undirected Graphs; Terms and Definitions... 249 15.2.1 Further Properties of Graphs and Digraphs... 250 15.2.2 Paths and Connectivity... 251 15.2.3 Special Types of Graphs... 252 15.3 Graph Data Structures... 253 15.4 Operations on Graphs... 256 15.5 Minimum Spanning Tree (MST) Problems... 256 15.6 Depth-First and Breadth-First Searches in Graphs... 258 15.7 Shortest Path Problems... 259 15.8 Connected Components... 261 15.9 Applications of Graph Theory... 262 15.9.1 Project Planning... 262 15.9.2 Some Specific Graphs... 265 15.9.3 Eulerian, de Bruijn and Hamiltonian Digraphs... 266 15.9.4 Random Graphs... 267 15.10 Flow Networks... 268 15.11 Summary and Conclusions... 270 16 The Boost Graph Library Data Structures and Fundamental Algorithms... 271 16.1 Introduction and Objectives... 271 16.2 An Overview of the Functionality in BGL... 271 16.3 Boost Property Map Library... 271 16.3.1 Boost Property Map Category Tags and Traits... 272 16.3.2 Property Map Types... 273 16.4 An Introduction to Data Structures in BGL... 274 16.5 Auxiliary Classes... 278

vi Table of Contents 16.6 Minimum Spanning Tree (MST) Algorithms... 281 16.6.1 Kruskal Algorithm... 281 16.6.2 Prim Algorithm... 282 16.7 Shortest Path Algorithms... 283 16.7.1 Dijkstra s Algorithm... 283 16.7.2 Bellman-Ford Algorithm... 285 16.8 Summary and Conclusions... 287 17 The Boost Graph Library (BGL) Advanced Algorithms... 288 17.1 Introduction and Objectives... 288 17.2 More Shortest-Path Algorithms... 288 17.2.1 Floyd-Warshall Algorithm... 288 17.2.2 Johnson Algorithm... 289 17.2.3 Transitive Closure... 291 17.3 Connected Component Algorithms... 292 17.3.1 Connected Components... 292 17.3.2 Biconnected Components and Articulation Points... 296 17.3.3 Incremental Connected Components... 297 17.3.4 Strong Components... 300 17.4 Graph Structure Comparison... 301 17.4.1 Isomorphic Graphs... 301 17.5 Extending Algorithms with Visitor... 304 17.6 Basic Graph Algorithms... 305 17.7 Other Graph Algorithms in BGL... 306 17.7.1 Sparse Matrix Ordering Algorithms... 307 17.7.2 Random Graphs... 309 17.8 Summary and Conclusions... 310 18 Interval Container Library... 311 18.1 Introduction and Objectives... 311 18.2 Overview of the ICL... 311 18.3 What Kinds of Intervals?... 311 18.3.1 Statically Bound Interval Types... 313 18.3.2 Modelling Intervals by Parameter Variation... 314 18.3.3 Intervals and Temporal Types... 315 18.4 Interval Sets and Interval Maps... 316 18.5 Interval Combining Styles... 318 18.5.1 Splitting Interval Containers... 318 18.5.2 Separating Interval Containers... 319 18.5.3 Iterators for Interval Sets and Maps... 320 18.6 Some 101 Examples... 320 18.7 Applying ICL to Managements Information Systems (MIS)... 322 18.7.1 Daily Planning... 324 18.8 Summary and Conclusions... 325 19 Boost Functional Factory... 326 19.1 Introduction and Objectives... 326 19.2 An Overview of GOF Patterns... 326 19.2.1 Strengths and Limitations of GOF Patterns... 328 19.3 An Example: Traditional Windows Factories... 328 19.4 Boost Functional Factory... 330 19.5 Function Factory with Smart Pointers... 331 19.6 R-Value Arguments... 332

vii 19.7 Allocators... 332 19.8 Value Factory... 333 19.9 Factory with Algorithms... 334 19.10 Summary and Conclusions... 334 Bibliography... 335 Index... 336 Book Registration Form Boost Volume II... 343 User Agreement... 345