Computational Physics Lectures: Introduction to programming (C++ and Fortran)
Contents
Extremely useful tools, strongly recommended
A structured programming approach
A structured programming approach
Getting Started
Makefiles and simple scripts
"Hello world":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/cpp/program1.cpp"
Hello World, dissecting the code
Hello World, more dissection
"Hello World with namespace":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/cpp/hellow.cpp"
"Hello World without namespace":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/cpp/hellownonamespace.cpp"
C++ Hello World
Brief summary
Brief summary
Serious problems and representation of numbers
Limits, you must declare variables
From decimal to binary representation
From decimal to binary representation, the actual operation
"From decimal to binary representation":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/cpp/program2.cpp"
"From decimal to binary representation":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/Fortran/program2.f90"
"Representing Integer Numbers":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/cpp/program3.cpp"
Loss of Precision
Loss of Precision
Loss of Precision
Loss of Precision, example
Loss of Precision
Loss of Precision, consequences
Loss of Precision
Loss of Precision
Loss of Precision
Loss of Precision
Loss of Precision
Loss of numerical precision
Loss of numerical precision
Loss of numerical precision
Loss of precision can cause serious problems
Loss of precision, real numbers
Roundoff errors
More on loss of precision
A problematic case
"Program":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/cpp/program4.cpp" to compute \( \exp{(-x)} \)
Program to compute \( \exp{(-x)} \)
Program to compute \( \exp{(-x)} \)
Results \( \exp{(-x)} \)
"Program":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/cpp/program5.cpp" to compute \( \exp{(-x)} \)
Program to compute \( \exp{(-x)} \)
Results \( \exp{(-x)} \)
Most used formula for derivatives
Error Analysis
Error Analysis
Error Analysis
Error Analysis
Error Analysis
Error Analysis
"Program to compute derivative":"https://github.com/CompPhysics/ComputationalPhysics/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/cpp/derivative.cpp"
Technical Matter in C/C++: Pointers
Technical Matter in C/C++: "Pointer example I":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/cpp/program7.cpp"
Dissection: Pointer example I
"Pointer example II":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/IntroProgramming/cpp/program8.cpp"
Dissection: Pointer example II
Output of Pointer example II
File handling; C-way
File handling; C way cont.
File handling, C++-way
File handling, C++-way
File handling, C++-way
File handling, C++-way
File handling, C++-way
Call by value or reference
Call by value or reference
Call by value and reference, F90/95
"Example codes in c++, dynamic memory allocation":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/Classes/cpp/program4.cpp"
"Example codes in c++, writing to file and dynamic allocation for arrays":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/Classes/cpp/program5.cpp"
"Example codes in c++, transfer of data using call by value and call by reference":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/Classes/cpp/program6.cpp"
"Example codes in c++, operating on several arrays and printing time used":"https://github.com/CompPhysics/ComputationalPhysicsMSU/blob/master/doc/Programs/LecturePrograms/programs/Classes/cpp/program7.cpp"
Serious problems and representation of numbers
Overflow
Underflow
Roundoff errors
Loss of precision
«
1
...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
74
»