ebook img

Guide to Scientific Computing in C++ PDF

254 Pages·2012·1.28 MB·english
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Guide to Scientific Computing in C++

Joe Pitt-Francis (cid:2) Jonathan Whiteley Guide to Scientific Computing in C++ Dr.JoePitt-Francis Dr.JonathanWhiteley DepartmentofComputerScience DepartmentofComputerScience UniversityofOxford UniversityofOxford Oxford,UK Oxford,UK ISSN1863-7310 UndergraduateTopicsinComputerScience ISBN978-1-4471-2735-2 e-ISBN978-1-4471-2736-9 DOI10.1007/978-1-4471-2736-9 SpringerLondonDordrechtHeidelbergNewYork BritishLibraryCataloguinginPublicationData AcataloguerecordforthisbookisavailablefromtheBritishLibrary LibraryofCongressControlNumber:2012931858 ©Springer-VerlagLondonLimited2012 SpringerispartofSpringerScience+BusinessMedia(www.springer.com) Preface ManybookshavebeenwrittenontheC++programminglanguage,varyingacross aspectrumfromtheverypracticaltotheverytheoretical.This bookcertainlylies at the practical end of this spectrum, and has a particular focus for the practical treatmentofthislanguage:scientificcomputing. Traditionally, Fortran and MATLAB®1 have been the languages of choice for scientificcomputingapplications.Therecentdevelopmentofcomplexmathemati- calmodels—infieldsasdiverseasbiology,finance,andmaterialsscience,toname butafew—hasdrivenaneedforsoftwarepackagesthatallowcomputationalsim- ulationsbasedonthesemodels.Thecomplexityoftheunderlyingmodels,together withtheneedtoexchangecodebetweencoworkers,hasmotivatedprogrammersto developobject-orientedcode(oftenwritteninC++)forthesesimulationpackages. Thecomputationaldemandsofthesesimulationsmayrequiresoftwaretobewrit- tenforparallelcomputingfacilities,typicallyusingtheMessagePassingInterface (MPI).Theneedtotrainprogrammersintheskillstoprogramapplicationssuchas theseledtothedevelopmentofagraduatelevelcourseC++forScientificComput- ing,taughtbytheauthorsofthisbook,attheUniversityofOxford. This book provides a guide to C++ programming in scientific computing. In contrast to many other books on C++, features of the language are demonstrated mainlyusingexamplesdrawnfromscientificcomputing.Object-orientationisfirst mentioned in Chap. 1 where we briefly describe what this phrase—and other re- lated terms such as inheritance—mean, before postponing any further discussion ofobject-orientationorrelatedtopicsuntilChap.6.Intheinterveningchaptersun- til object-orientation reappears, we present what is best described as “procedural programminginC++”,coveringvariables,flowofcontrol,inputandoutput,point- ers (including dynamic allocation of memory), functions and reference variables. ArmedwiththisgroundinginC++wethenintroduceclassesinChaps.6and7.In thesetwochapters,wherethemainfeaturesofobject-orientationareshowcased,we initially,forthesakeofclarity,abandonourprincipleofusingexamplesdrawnfrom scientificcomputing.Oncethetopicshavebeenpresentedhowever,weresumeour strategy of demonstrating concepts through scientific computing examples. More advancedC++featuressuchastemplatesandexceptionsareintroducedinChaps.8 and9.HavingintroducedthefeaturesofC++requiredforscientificcomputing,the 1MATLABisaregisteredtrademarkofTheMathWorks,Inc. remainderofthebookfocusesontheapplicationofthesefeatures.InChap.10,we begintodevelopacollectionofclassesforlinearalgebracalculations:theseclasses are then developed further in the exercises at the end of this chapter. Chapter 11 presentsanintroductiontoparallelcomputingusingMPI.Finally,inChap.12,we discuss how an object-oriented library for solving second order differential equa- tionsmaybeconstructed.Theimportanceofaclearprogrammingstyletominimise theintroductionoferrorsintocodeisstressedthroughoutthebook. Thisbookisaimedatprogrammersofalllevelsofexpertisewhowishtowrite scientific computing programs in C++. Experience with a computer to the level wherefilescanbestoredandeditedisexpected.Abasicknowledgeofmathematics, suchasoperationsbetweenvectorsandmatrices,andtheNewton–Raphsonmethod forfindingtherootsofnonlinearequationswouldbeanadvantage. Thematerialpresentedherehasbeenenhancedsignificantlybydiscussionsabout C++withcolleagues,toonumeroustolisthere,intheDepartmentofComputerSci- enceattheUniversityofOxford.Aspecialmentionmust,however,bemadeofthe Chaste2 programming team: particular gratitude should be expressed to Jonathan Cooper for readily sharing with us his impressively wide and deep knowledge of theC++language.Othermembersoftheteamwhohavesignificantlyhelpedclarify ourthoughtsontheC++languageareMiguelBernabeu,JamesOsborne,PrasPath- manathanandJamesSouthern.WeshouldalsothankstudentsfromboththeM.Sc. in Mathematical Modelling and Scientific Computing and the Doctoral Training CentresattheUniversityofOxfordforunwittinglyaidingourunderstandingofthe languagethroughaskingpertinentquestions. Finally,itisalwaysimportanttoremember—especiallywhendebuggingapar- ticularly tiresome code—that there is far more to life than C++ programming for scientific computing. We would both like to thank our families for their love and support,especiallyduringthewritingofthisbook. Oxford,UK JoePitt-Francis JonathanWhiteley 2TheCancer,HeartAndSoftTissueEnvironment(Chaste)isanobject-orientedpackage,written in C++, for simulations in the field of biology. More details on this package may be found at http://www.cs.ox.ac.uk/chaste/. Contents 1 GettingStarted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 ABriefIntroductiontoC++ . . . . . . . . . . . . . . . . . . . . . 1 1.1.1 C++is“Object-Oriented” . . . . . . . . . . . . . . . . . . 1 1.1.2 WhyYouShouldWriteScientificProgramsinC++ . . . . 2 1.1.3 WhyYouShouldNotWriteScientificProgramsinC++ . . 4 1.1.4 ScopeofThisBook . . . . . . . . . . . . . . . . . . . . . 4 1.2 AFirstC++Program . . . . . . . . . . . . . . . . . . . . . . . . 5 1.3 CompilingaC++Program. . . . . . . . . . . . . . . . . . . . . . 6 1.3.1 IntegratedDevelopmentEnvironments . . . . . . . . . . . 6 1.3.2 CompilingattheCommandLine . . . . . . . . . . . . . . 7 1.3.3 CompilerFlags. . . . . . . . . . . . . . . . . . . . . . . . 8 1.4 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.4.1 BasicNumericalVariables. . . . . . . . . . . . . . . . . . 10 1.4.2 OtherNumericalVariables . . . . . . . . . . . . . . . . . 12 1.4.3 MathematicalOperationsonNumericalVariables . . . . . 13 1.4.4 DivisionofIntegers . . . . . . . . . . . . . . . . . . . . . 15 1.4.5 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 1.4.6 ASCIICharacters . . . . . . . . . . . . . . . . . . . . . . 17 1.4.7 BooleanVariables . . . . . . . . . . . . . . . . . . . . . . 17 1.4.8 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 1.5 SimpleInputandOutput . . . . . . . . . . . . . . . . . . . . . . . 19 1.5.1 BasicConsoleOutput . . . . . . . . . . . . . . . . . . . . 19 1.5.2 KeyboardInput . . . . . . . . . . . . . . . . . . . . . . . 20 1.6 TheassertStatement . . . . . . . . . . . . . . . . . . . . . . . 21 1.7 Tips:DebuggingCode . . . . . . . . . . . . . . . . . . . . . . . . 22 1.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2 FlowofControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.1 TheifStatement . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.1.1 ASingleifStatement . . . . . . . . . . . . . . . . . . . 26 2.1.2 Example:CodeforaSingleifStatement . . . . . . . . . 27 2.1.3 if–elseStatements . . . . . . . . . . . . . . . . . . . . 27 2.1.4 MultipleifStatements . . . . . . . . . . . . . . . . . . . 27 2.1.5 NestedifStatements . . . . . . . . . . . . . . . . . . . . 28 2.1.6 BooleanVariables . . . . . . . . . . . . . . . . . . . . . . 28 2.2 LogicalandRelationalOperators . . . . . . . . . . . . . . . . . . 29 2.3 ThewhileStatement . . . . . . . . . . . . . . . . . . . . . . . . 30 2.4 LoopsUsingtheforStatement . . . . . . . . . . . . . . . . . . . 32 2.4.1 Example:CalculatingtheScalarProductofTwoVectors . . 34 2.5 TheswitchStatement . . . . . . . . . . . . . . . . . . . . . . . 34 2.6 Tips:LoopsandBranches . . . . . . . . . . . . . . . . . . . . . . 35 2.6.1 Tip1:ACommonNoviceCodingError . . . . . . . . . . 35 2.6.2 Tip2:CountingfromZero. . . . . . . . . . . . . . . . . . 36 2.6.3 Tip3:EqualityVersusAssignment . . . . . . . . . . . . . 37 2.6.4 Tip4:NeverEndingwhileLoops . . . . . . . . . . . . . 38 2.6.5 Tip5:ComparingTwoFloatingPointNumbers . . . . . . 39 2.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3 FileInputandOutput . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3.1 RedirectingConsoleOutputtoFile . . . . . . . . . . . . . . . . . 43 3.2 WritingtoFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 3.2.1 SettingthePrecisionoftheOutput . . . . . . . . . . . . . 46 3.3 ReadingfromFile . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3.4 ReadingfromtheCommandLine . . . . . . . . . . . . . . . . . . 49 3.5 Tips:ControllingOutputFormat . . . . . . . . . . . . . . . . . . 50 3.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 4 Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 4.1 PointersandtheComputer’sMemory . . . . . . . . . . . . . . . . 55 4.1.1 Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . 55 4.1.2 PointerVariables . . . . . . . . . . . . . . . . . . . . . . . 56 4.1.3 ExampleUseofPointers . . . . . . . . . . . . . . . . . . 56 4.1.4 WarningsontheUseofPointers. . . . . . . . . . . . . . . 57 4.2 DynamicAllocationofMemoryforArrays . . . . . . . . . . . . . 58 4.2.1 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 4.2.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 4.2.3 IrregularlySizedMatrices . . . . . . . . . . . . . . . . . . 61 4.3 Tips:Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 4.3.1 Tip1:PointerAliasing. . . . . . . . . . . . . . . . . . . . 62 4.3.2 Tip2:SafeDynamicAllocation . . . . . . . . . . . . . . . 63 4.3.3 Tip3:EverynewHasadelete . . . . . . . . . . . . . . 63 4.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5 Blocks,FunctionsandReferenceVariables. . . . . . . . . . . . . . . 65 5.1 Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 5.2.1 SimpleFunctions . . . . . . . . . . . . . . . . . . . . . . 66 5.2.2 ReturningPointerVariablesfromaFunction . . . . . . . . 69 5.2.3 UseofPointersasFunctionArguments . . . . . . . . . . . 70 5.2.4 SendingArraystoFunctions . . . . . . . . . . . . . . . . 71 5.2.5 Example:AFunctiontoCalculatetheScalarProductof TwoVectors . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.3 ReferenceVariables . . . . . . . . . . . . . . . . . . . . . . . . . 74 5.4 DefaultValuesforFunctionArguments . . . . . . . . . . . . . . . 75 5.5 FunctionOverloading . . . . . . . . . . . . . . . . . . . . . . . . 76 5.6 DeclaringFunctionsWithoutPrototypes . . . . . . . . . . . . . . 78 5.7 FunctionPointers . . . . . . . . . . . . . . . . . . . . . . . . . . 79 5.8 RecursiveFunctions . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.9 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 5.10 Tips:CodeDocumentation . . . . . . . . . . . . . . . . . . . . . 83 5.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 6 AnIntroductiontoClasses . . . . . . . . . . . . . . . . . . . . . . . . 87 6.1 TheRaisond’ÊtreforClasses . . . . . . . . . . . . . . . . . . . . 87 6.1.1 ProblemsThatMayAriseWhenUsingModules . . . . . . 88 6.1.2 Abstraction,EncapsulationandModularityPropertiesof Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 6.2 AFirstExampleSimpleClass:AClassofBooks . . . . . . . . . . 89 6.2.1 BasicFeaturesofClasses . . . . . . . . . . . . . . . . . . 89 6.2.2 HeaderFiles . . . . . . . . . . . . . . . . . . . . . . . . . 91 6.2.3 SettingandAccessingVariables . . . . . . . . . . . . . . . 92 6.2.4 CompilingMultipleFiles . . . . . . . . . . . . . . . . . . 94 6.2.5 AccessPrivileges . . . . . . . . . . . . . . . . . . . . . . 96 6.2.6 IncludingFunctionImplementationsinHeaderFiles . . . . 97 6.2.7 ConstructorsandDestructors . . . . . . . . . . . . . . . . 98 6.2.8 PointerstoClasses . . . . . . . . . . . . . . . . . . . . . . 103 6.3 ThefriendKeyword . . . . . . . . . . . . . . . . . . . . . . . 103 6.4 ASecondExampleClass:AClassofComplexNumbers. . . . . . 105 6.4.1 OperatorOverloading . . . . . . . . . . . . . . . . . . . . 105 6.4.2 TheClassofComplexNumbers . . . . . . . . . . . . . . . 106 6.5 SomeAdditionalRemarksonOperatorOverloading . . . . . . . . 112 6.6 Tips:CodingtoaStandard. . . . . . . . . . . . . . . . . . . . . . 112 6.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 7 InheritanceandDerivedClasses . . . . . . . . . . . . . . . . . . . . 117 7.1 Inheritance,ExtensibilityandPolymorphism . . . . . . . . . . . . 117 7.2 Example:AClassofE-booksDerivedfromaClassofBooks . . . 118 7.3 AccessPrivilegesforDerivedClasses . . . . . . . . . . . . . . . . 120 7.4 ClassesDerivedfromDerivedClasses . . . . . . . . . . . . . . . 121 7.5 Run-TimePolymorphism . . . . . . . . . . . . . . . . . . . . . . 122 7.6 TheAbstractClassPattern . . . . . . . . . . . . . . . . . . . . . . 124 7.7 Tips:UsingaDebugger . . . . . . . . . . . . . . . . . . . . . . . 126 7.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 8 Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 8.1 TemplatestoControlDimensionsandVerifySizes . . . . . . . . . 131 8.2 TemplatesforPolymorphism . . . . . . . . . . . . . . . . . . . . 133 8.3 ABriefSurveyoftheStandardTemplateLibrary . . . . . . . . . . 134 8.3.1 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 8.3.2 Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 8.4 Tips:TemplateCompilation . . . . . . . . . . . . . . . . . . . . . 139 8.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 9 ErrorsandExceptions . . . . . . . . . . . . . . . . . . . . . . . . . . 141 9.1 Preconditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 9.1.1 Example:TwoImplementationsofaGraphicsFunction . . 142 9.2 ThreeLevelsofErrors . . . . . . . . . . . . . . . . . . . . . . . . 143 9.3 IntroducingtheException . . . . . . . . . . . . . . . . . . . . . . 144 9.4 UsingExceptions . . . . . . . . . . . . . . . . . . . . . . . . . . 145 9.5 Tips:Test-DrivenDevelopment . . . . . . . . . . . . . . . . . . . 146 9.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 10 DevelopingClassesforLinearAlgebraCalculations . . . . . . . . . 151 10.1 RequirementsoftheLinearAlgebraClasses . . . . . . . . . . . . 151 10.2 ConstructorsandDestructors . . . . . . . . . . . . . . . . . . . . 156 10.2.1 TheDefaultConstructor . . . . . . . . . . . . . . . . . . . 156 10.2.2 TheCopyConstructor . . . . . . . . . . . . . . . . . . . . 156 10.2.3 ASpecialisedConstructor . . . . . . . . . . . . . . . . . . 157 10.2.4 Destructor . . . . . . . . . . . . . . . . . . . . . . . . . . 157 10.3 AccessingPrivateClassMembers . . . . . . . . . . . . . . . . . . 157 10.3.1 AccessingtheSizeofaVector. . . . . . . . . . . . . . . . 158 10.3.2 OverloadingtheSquareBracketOperator . . . . . . . . . . 158 10.3.3 Read-OnlyAccesstoVectorEntries. . . . . . . . . . . . . 158 10.3.4 OverloadingtheRoundBracketOperator . . . . . . . . . . 158 10.4 OperatorOverloadingforVectorOperations . . . . . . . . . . . . 158 10.4.1 TheAssignmentOperator . . . . . . . . . . . . . . . . . . 159 10.4.2 UnaryOperators . . . . . . . . . . . . . . . . . . . . . . . 159 10.4.3 BinaryOperators. . . . . . . . . . . . . . . . . . . . . . . 159 10.5 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 10.5.1 MembersVersusFriends. . . . . . . . . . . . . . . . . . . 159 10.6 Tips:MemoryDebuggingTools . . . . . . . . . . . . . . . . . . . 160 10.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 11 AnIntroductiontoParallelProgrammingUsingMPI. . . . . . . . . 165 11.1 DistributedMemoryArchitectures . . . . . . . . . . . . . . . . . 165 11.2 InstallingMPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 11.3 AFirstProgramUsingMPI . . . . . . . . . . . . . . . . . . . . . 167 11.3.1 EssentialMPIFunctions . . . . . . . . . . . . . . . . . . . 168 11.3.2 CompilingandRunningMPICode . . . . . . . . . . . . . 169 11.4 BasicMPICommunication . . . . . . . . . . . . . . . . . . . . . 171 11.4.1 Point-to-PointCommunication . . . . . . . . . . . . . . . 171 11.4.2 CollectiveCommunication . . . . . . . . . . . . . . . . . 174 11.5 ExampleMPIApplications . . . . . . . . . . . . . . . . . . . . . 180 11.5.1 SummationofSeries . . . . . . . . . . . . . . . . . . . . . 180 11.5.2 ParallelLinearAlgebra . . . . . . . . . . . . . . . . . . . 182 11.6 Tips:DebuggingaParallelProgram . . . . . . . . . . . . . . . . . 186 11.6.1 Tip1:MakeanAbstractProgram . . . . . . . . . . . . . . 186 11.6.2 Tip2:DatatypeMismatch . . . . . . . . . . . . . . . . . . 186 11.6.3 Tip3:IntermittentDeadlock. . . . . . . . . . . . . . . . . 187 11.6.4 Tip4:AlmostCollectiveCommunication . . . . . . . . . . 187 11.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 12 DesigningObject-OrientedNumericalLibraries . . . . . . . . . . . 193 12.1 DevelopingtheLibraryforOrdinaryDifferentialEquations . . . . 194 12.1.1 ModelProblems . . . . . . . . . . . . . . . . . . . . . . . 194 12.1.2 FiniteDifferenceApproximationtoDerivatives . . . . . . 195 12.1.3 ApplicationofFiniteDifferenceMethodstoBoundary ValueProblems . . . . . . . . . . . . . . . . . . . . . . . 197 12.1.4 ConcludingRemarksonBoundaryValueProblemsinOne Dimension . . . . . . . . . . . . . . . . . . . . . . . . . . 199 12.2 DesigningaLibraryforSolvingBoundaryValueProblems . . . . 200 12.2.1 TheClassSecondOrderOde . . . . . . . . . . . . . . . 200 12.2.2 TheClassBoundaryConditions . . . . . . . . . . . . 201 12.2.3 TheClassFiniteDifferenceGrid . . . . . . . . . . 202 12.2.4 TheClassBvpOde . . . . . . . . . . . . . . . . . . . . . 203 12.2.5 UsingtheClassBvpOde . . . . . . . . . . . . . . . . . . 205 12.3 ExtendingtheLibrarytoTwoDimensions . . . . . . . . . . . . . 205 12.3.1 ModelProblemforTwoDimensions . . . . . . . . . . . . 207 12.3.2 FiniteDifferenceMethodsforBoundaryValueProblems inTwoDimensions . . . . . . . . . . . . . . . . . . . . . 207 12.3.3 SettingUptheLinearSystemfortheModelProblem . . . 209 12.3.4 DevelopingtheClassesRequired . . . . . . . . . . . . . . 210 12.4 Tips:UsingWell-WrittenLibraries . . . . . . . . . . . . . . . . . 210 12.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 AppendixA LinearAlgebra. . . . . . . . . . . . . . . . . . . . . . . . . 213 A.1 VectorsandMatrices . . . . . . . . . . . . . . . . . . . . . . . . . 213 A.1.1 OperationsBetweenVectorsandMatrices . . . . . . . . . 214 A.1.2 TheScalarProductofTwoVectors . . . . . . . . . . . . . 215 A.1.3 TheDeterminantandtheInverseofaMatrix . . . . . . . . 215 A.1.4 EigenvaluesandEigenvectorsofaMatrix. . . . . . . . . . 216 A.1.5 VectorandMatrixNorms . . . . . . . . . . . . . . . . . . 216 A.2 SystemsofLinearEquations . . . . . . . . . . . . . . . . . . . . 217 A.2.1 GaussianElimination . . . . . . . . . . . . . . . . . . . . 217 A.2.2 TheThomasAlgorithm . . . . . . . . . . . . . . . . . . . 222 A.2.3 TheConjugateGradientMethod . . . . . . . . . . . . . . 222 AppendixB OtherProgrammingConstructsYouMightMeet. . . . . . 225 B.1 CStyleOutput . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 B.2 CStyleDynamicMemoryAllocation . . . . . . . . . . . . . . . . 226 B.3 Ternary?:Operator . . . . . . . . . . . . . . . . . . . . . . . . . 226 B.4 UsingNamespace . . . . . . . . . . . . . . . . . . . . . . . . . . 227 B.5 Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 B.6 MultipleInheritance . . . . . . . . . . . . . . . . . . . . . . . . . 228 B.7 ClassInitialisers . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 AppendixC SolutionstoExercises . . . . . . . . . . . . . . . . . . . . . 231 C.1 MatrixandLinearSystemClasses. . . . . . . . . . . . . . . . . . 231 C.2 ODESolverLibrary . . . . . . . . . . . . . . . . . . . . . . . . . 240 FurtherReading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 MathematicalMethodsandLinearAlgebra . . . . . . . . . . . . . 245 C++Programming . . . . . . . . . . . . . . . . . . . . . . . . . . 245 TheMessage-PassingInterface(MPI) . . . . . . . . . . . . . . . . 245 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.