├── my_document.txt ├── basics ├── git_tutorial │ ├── document_adam.txt │ ├── document_lisa.txt │ ├── hello.txt │ ├── my_document.txt │ ├── document_claire │ ├── document_MABILEAU.txt │ ├── document_BELARBI.txt │ ├── document_borde.txt │ ├── document_ribeiro.txt │ ├── document_samahtachaqourrt.txt │ ├── document.txt │ ├── document_chueva.txt │ └── document_leroux.txt ├── slides │ ├── src │ │ ├── johan.jpg │ │ ├── sylvain.png │ │ ├── twitter-white.svg │ │ ├── git_decentralized.svg │ │ ├── github-white.svg │ │ ├── quantstack-white.svg │ │ ├── git_basic.svg │ │ ├── compiler.svg │ │ ├── linker.svg │ │ └── git_rebase2.svg │ └── package.json ├── cpp │ ├── placeholder │ │ ├── main.cpp │ │ └── CMakeLists.txt │ └── first_program │ │ ├── main.cpp │ │ └── CMakeLists.txt ├── README.md └── basics.ipynb ├── types ├── cpp │ ├── uvector.cpp │ ├── uvector.hpp │ ├── main.cpp │ ├── matrix.cpp │ ├── matrix.hpp │ └── CMakeLists.txt ├── slides │ ├── src │ │ ├── johan.jpg │ │ ├── sylvain.png │ │ ├── twitter-white.svg │ │ ├── array_memory.svg │ │ └── quantstack-white.svg │ └── package.json ├── README.md └── move_semantic │ ├── CMakeLists.txt │ ├── resource.hpp │ ├── main.cpp │ └── resource.cpp ├── Name.txt ├── stl ├── slides │ ├── src │ │ ├── johan.jpg │ │ ├── sylvain.png │ │ ├── twitter-white.svg │ │ └── quantstack-white.svg │ └── package.json ├── cpp │ ├── vector_utils.cpp │ ├── additional_exercises.hpp │ ├── vector_utils.hpp │ ├── main.cpp │ ├── CMakeLists.txt │ └── additional_exercises.cpp └── README.md ├── exercises ├── polynomial │ ├── polynomial.cpp │ ├── CMakeLists.txt │ ├── polynomial.hpp │ └── main.cpp ├── interpolation │ ├── main.cpp │ ├── interpolation.hpp │ ├── CMakeLists.txt │ ├── interpolation.cpp │ ├── interpolation_impl.hpp │ └── interpolation_impl.cpp └── chess │ ├── CMakeLists.txt │ ├── chess_array.hpp │ └── main.cpp ├── functional ├── cpp │ ├── multi_files │ │ ├── discount_factor.cpp │ │ ├── discount_factor.hpp │ │ ├── main.cpp │ │ ├── bond_pricer.hpp │ │ └── CMakeLists.txt │ └── single_file │ │ ├── main.cpp │ │ └── CMakeLists.txt ├── slides │ ├── src │ │ ├── johan.jpg │ │ ├── sylvain.png │ │ ├── twitter-white.svg │ │ ├── link.svg │ │ ├── git_decentralized.svg │ │ ├── github-white.svg │ │ ├── quantstack-white.svg │ │ ├── git_basic.svg │ │ └── git_rebase2.svg │ └── package.json └── README.md ├── pointers ├── slides │ ├── src │ │ ├── johan.jpg │ │ ├── sylvain.png │ │ ├── twitter-white.svg │ │ ├── array_memory.svg │ │ └── quantstack-white.svg │ └── package.json ├── cpp │ ├── resource.hpp │ ├── resource.cpp │ ├── option.cpp │ ├── option.hpp │ ├── pricer.hpp │ ├── pricer.cpp │ ├── main.cpp │ └── CMakeLists.txt └── README.md ├── projects ├── pde1d │ ├── pde1d_solver.pdf │ └── superbox.sty ├── currency-ranking │ ├── biblio.bib │ ├── currency-ranking.pdf │ ├── superbox.sty │ └── currency-ranking.tex ├── super-replication │ ├── biblio.bib │ ├── bundle.pdf │ ├── superbox.sty │ └── bundle.tex └── breakeven-volatility │ ├── biblio.bib │ ├── breakeven-volatility.pdf │ ├── superbox.sty │ └── breakeven-volatility.tex ├── polymorphism ├── slides │ ├── src │ │ ├── johan.jpg │ │ ├── sylvain.png │ │ ├── twitter-white.svg │ │ ├── github-white.svg │ │ └── quantstack-white.svg │ └── package.json ├── cpp │ ├── volatility.cpp │ ├── volatility.hpp │ ├── main.cpp │ └── CMakeLists.txt └── README.md ├── environment.yml ├── .gitignore ├── README.md └── LICENSE /my_document.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /basics/git_tutorial/document_adam.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /basics/git_tutorial/document_lisa.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /basics/git_tutorial/hello.txt: -------------------------------------------------------------------------------- 1 | hello -------------------------------------------------------------------------------- /basics/git_tutorial/my_document.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /basics/git_tutorial/document_claire: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /basics/git_tutorial/document_MABILEAU.txt: -------------------------------------------------------------------------------- 1 | Louis Mabileau 2 | Louismab -------------------------------------------------------------------------------- /basics/git_tutorial/document_BELARBI.txt: -------------------------------------------------------------------------------- 1 | Sofia BELARBI 2 | belaso8 3 | -------------------------------------------------------------------------------- /basics/git_tutorial/document_borde.txt: -------------------------------------------------------------------------------- 1 | valentin 2 | borde 3 | vbuseruni -------------------------------------------------------------------------------- /basics/git_tutorial/document_ribeiro.txt: -------------------------------------------------------------------------------- 1 | Alicia 2 | Ribeiro 3 | alicia-ribeiro97 -------------------------------------------------------------------------------- /basics/git_tutorial/document_samahtachaqourrt.txt: -------------------------------------------------------------------------------- 1 | samah tachaqourrt 2 | samahtachaqourrt -------------------------------------------------------------------------------- /types/cpp/uvector.cpp: -------------------------------------------------------------------------------- 1 | #include "uvector.hpp" 2 | 3 | namespace dauphine 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /Name.txt: -------------------------------------------------------------------------------- 1 | First Name : Aymeric 2 | Last Name : Berthoumieu 3 | User Name : AymericBerthoumieu -------------------------------------------------------------------------------- /stl/slides/src/johan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/stl/slides/src/johan.jpg -------------------------------------------------------------------------------- /exercises/polynomial/polynomial.cpp: -------------------------------------------------------------------------------- 1 | #include "polynomial.hpp" 2 | 3 | namespace dauphine 4 | { 5 | } 6 | 7 | -------------------------------------------------------------------------------- /stl/slides/src/sylvain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/stl/slides/src/sylvain.png -------------------------------------------------------------------------------- /types/slides/src/johan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/types/slides/src/johan.jpg -------------------------------------------------------------------------------- /basics/slides/src/johan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/basics/slides/src/johan.jpg -------------------------------------------------------------------------------- /basics/slides/src/sylvain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/basics/slides/src/sylvain.png -------------------------------------------------------------------------------- /functional/cpp/multi_files/discount_factor.cpp: -------------------------------------------------------------------------------- 1 | // Put here the functions discount_factor and print_discount_factor 2 | -------------------------------------------------------------------------------- /pointers/slides/src/johan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/pointers/slides/src/johan.jpg -------------------------------------------------------------------------------- /types/slides/src/sylvain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/types/slides/src/sylvain.png -------------------------------------------------------------------------------- /functional/slides/src/johan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/functional/slides/src/johan.jpg -------------------------------------------------------------------------------- /pointers/slides/src/sylvain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/pointers/slides/src/sylvain.png -------------------------------------------------------------------------------- /projects/pde1d/pde1d_solver.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/projects/pde1d/pde1d_solver.pdf -------------------------------------------------------------------------------- /functional/cpp/multi_files/discount_factor.hpp: -------------------------------------------------------------------------------- 1 | // Put here the declarations of discount_factor and print_discount_factor 2 | -------------------------------------------------------------------------------- /functional/slides/src/sylvain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/functional/slides/src/sylvain.png -------------------------------------------------------------------------------- /polymorphism/slides/src/johan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/polymorphism/slides/src/johan.jpg -------------------------------------------------------------------------------- /types/cpp/uvector.hpp: -------------------------------------------------------------------------------- 1 | #ifndef UVECTOR_HPP 2 | #define UVECTOR_HPP 3 | 4 | namespace dauphine 5 | { 6 | } 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /polymorphism/slides/src/sylvain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/polymorphism/slides/src/sylvain.png -------------------------------------------------------------------------------- /projects/currency-ranking/biblio.bib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/projects/currency-ranking/biblio.bib -------------------------------------------------------------------------------- /projects/super-replication/biblio.bib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/projects/super-replication/biblio.bib -------------------------------------------------------------------------------- /projects/super-replication/bundle.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/projects/super-replication/bundle.pdf -------------------------------------------------------------------------------- /projects/breakeven-volatility/biblio.bib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/projects/breakeven-volatility/biblio.bib -------------------------------------------------------------------------------- /basics/cpp/placeholder/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char* argv[]) 5 | { 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /projects/currency-ranking/currency-ranking.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/projects/currency-ranking/currency-ranking.pdf -------------------------------------------------------------------------------- /stl/cpp/vector_utils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "vector_utils.hpp" 4 | 5 | namespace dauphine 6 | { 7 | } 8 | 9 | -------------------------------------------------------------------------------- /stl/cpp/additional_exercises.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ADDITIONAL_EXERCISES_HPP 2 | #define ADDITIONAL_EXERCISES_HPP 3 | 4 | namespace dauphine 5 | { 6 | } 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | name: cpp_dauphine 2 | channels: 3 | - conda-forge 4 | dependencies: 5 | - xtensor=0.23.10 6 | - xtensor-blas=0.19.1 7 | - xeus-cling=0.13.0 8 | -------------------------------------------------------------------------------- /projects/breakeven-volatility/breakeven-volatility.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dauphine203/cpp_dauphine/HEAD/projects/breakeven-volatility/breakeven-volatility.pdf -------------------------------------------------------------------------------- /stl/cpp/vector_utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VECTOR_UTILS_HPP 2 | #define VECTOR_UTILS_HPP 3 | 4 | #include 5 | 6 | namespace dauphine 7 | { 8 | } 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /functional/cpp/multi_files/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | int main(int argc, char* argv[]) 3 | { 4 | // Uncomment the following line 5 | // double df = discount factor(0.04, 1.5); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /stl/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "vector_utils.hpp" 3 | #include "additional_exercises.hpp" 4 | 5 | int main(int argc, char* argv[]) 6 | { 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /types/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "matrix.hpp" 3 | 4 | int main(int argc, char* argv[]) 5 | { 6 | dauphine::matrix m(2, 4); 7 | std::cout << m.m_nb_rows << std::endl; 8 | return 0; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /functional/cpp/multi_files/bond_pricer.hpp: -------------------------------------------------------------------------------- 1 | // #include "discount_factor.hpp" 2 | // 3 | // double price_bond(doube maturity, double rate, double yield, double nominal) 4 | // { 5 | // return discount_factor(rate, maturity); 6 | // } 7 | -------------------------------------------------------------------------------- /basics/git_tutorial/document.txt: -------------------------------------------------------------------------------- 1 | This is a simple document for git training. 2 | Please enter your first name and last name: 3 | 4 | First Name: aaaa 5 | Last Name: bbbb 6 | 7 | Also enter the date of today: 8 | 9 | Date: 10 | 11 | THat's it! 12 | -------------------------------------------------------------------------------- /polymorphism/cpp/volatility.cpp: -------------------------------------------------------------------------------- 1 | #include "volatility.hpp" 2 | #include 3 | 4 | namespace dauphine 5 | { 6 | const std::string& volatility::underlying_name() const 7 | { 8 | return "BNP Paribas"; 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /functional/cpp/single_file/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char* argv[]) 7 | { 8 | std::cout << "I'm an empty program" << std::endl; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /basics/git_tutorial/document_chueva.txt: -------------------------------------------------------------------------------- 1 | This is a simple document for git training. 2 | Please enter your first name and last name: 3 | 4 | First Name: Dayana 5 | Last Name: Chueva 6 | 7 | Also enter the date of today: 8 | 9 | Date: 12/10/2021 10 | 11 | THat's it! 12 | -------------------------------------------------------------------------------- /basics/git_tutorial/document_leroux.txt: -------------------------------------------------------------------------------- 1 | This is a simple document for git training. 2 | Please enter your first name and last name: 3 | 4 | First Name: Alex 5 | Last Name: Leroux 6 | 7 | Also enter the date of today: 8 | 9 | Date: 08/10/2021 10 | 11 | THat's it! 12 | -------------------------------------------------------------------------------- /types/cpp/matrix.cpp: -------------------------------------------------------------------------------- 1 | #include "matrix.hpp" 2 | 3 | namespace dauphine 4 | { 5 | matrix::matrix(std::size_t nb_rows, std::size_t nb_cols) 6 | : m_nb_rows(nb_rows), 7 | m_nb_cols(nb_cols), 8 | m_data(nb_rows * nb_cols) 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /pointers/cpp/resource.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RESOURCE_HPP 2 | #define RESOURCE_HPP 3 | 4 | namespace dauphine 5 | { 6 | class resource 7 | { 8 | public: 9 | 10 | void acquire(); 11 | void release(); 12 | void print_message(); 13 | }; 14 | } 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /basics/cpp/first_program/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char* argv[]) 5 | { 6 | double x1 = 1., y1 = 0.; 7 | double x2 = 0., y2 = 1.; 8 | 9 | double distance = std::sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); 10 | std::cout << "distance = " << distance << std::endl; 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /polymorphism/cpp/volatility.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VOLATILITY_HPP 2 | #define VOLATILITY_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace dauphine 8 | { 9 | class volatility 10 | { 11 | public: 12 | 13 | const std::string& underlying_name() const; 14 | }; 15 | 16 | class implied_volatility : public volatility 17 | { 18 | }; 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /stl/README.md: -------------------------------------------------------------------------------- 1 | The slides are available [online](http://dauphine203.github.io/cpp_dauphine/stl/index.html) 2 | 3 | ## cmake cheatsheet 4 | 5 | First time you compile: 6 | 7 | ```bash 8 | mkdir build 9 | cd build 10 | ``` 11 | 12 | ### Windows users 13 | 14 | ```bash 15 | cmake -G "NMake Makefiles" .. 16 | nmake 17 | ``` 18 | 19 | ### Linus / OSX users 20 | 21 | ```bash 22 | cmake .. 23 | make 24 | ``` 25 | -------------------------------------------------------------------------------- /types/README.md: -------------------------------------------------------------------------------- 1 | The slides are available [online](http://dauphine203.github.io/cpp_dauphine/types/index.html) 2 | 3 | ## cmake cheatsheet 4 | 5 | First time you compile: 6 | 7 | ```bash 8 | mkdir build 9 | cd build 10 | ``` 11 | 12 | ### Windows users 13 | 14 | ```bash 15 | cmake -G "NMake Makefiles" .. 16 | nmake 17 | ``` 18 | 19 | ### Linus / OSX users 20 | 21 | ```bash 22 | cmake .. 23 | make 24 | ``` 25 | -------------------------------------------------------------------------------- /functional/README.md: -------------------------------------------------------------------------------- 1 | The slides are available [online](http://dauphine203.github.io/cpp_dauphine/functional/index.html) 2 | 3 | ## cmake cheatsheet 4 | 5 | First time you compile: 6 | 7 | ```bash 8 | mkdir build 9 | cd build 10 | ``` 11 | 12 | ### Windows users 13 | 14 | ```bash 15 | cmake -G "NMake Makefiles" .. 16 | nmake 17 | ``` 18 | 19 | ### Linus / OSX users 20 | 21 | ```bash 22 | cmake .. 23 | make 24 | ``` 25 | -------------------------------------------------------------------------------- /pointers/README.md: -------------------------------------------------------------------------------- 1 | The slides are available [online](http://dauphine203.github.io/cpp_dauphine/pointers/index.html) 2 | 3 | ## cmake cheatsheet 4 | 5 | First time you compile: 6 | 7 | ```bash 8 | mkdir build 9 | cd build 10 | ``` 11 | 12 | ### Windows users 13 | 14 | ```bash 15 | cmake -G "NMake Makefiles" .. 16 | nmake 17 | ``` 18 | 19 | ### Linus / OSX users 20 | 21 | ```bash 22 | cmake .. 23 | make 24 | ``` 25 | -------------------------------------------------------------------------------- /polymorphism/README.md: -------------------------------------------------------------------------------- 1 | The slides are available [online](http://dauphine203.github.io/cpp_dauphine/polymorphism/index.html) 2 | 3 | ## cmake cheatsheet 4 | 5 | First time you compile: 6 | 7 | ```bash 8 | mkdir build 9 | cd build 10 | ``` 11 | 12 | ### Windows users 13 | 14 | ```bash 15 | cmake -G "NMake Makefiles" .. 16 | nmake 17 | ``` 18 | 19 | ### Linus / OSX users 20 | 21 | ```bash 22 | cmake .. 23 | make 24 | ``` 25 | -------------------------------------------------------------------------------- /types/cpp/matrix.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MATRIX_HPP 2 | #define MATRIX_HPP 3 | 4 | #include 5 | #include 6 | #include "uvector.hpp" 7 | 8 | namespace dauphine 9 | { 10 | class matrix 11 | { 12 | public: 13 | 14 | matrix(std::size_t nb_rows, std::size_t nb_cols); 15 | 16 | private: 17 | 18 | std::size_t m_nb_rows; 19 | std::size_t m_nb_cols; 20 | std::vector m_data; 21 | }; 22 | } 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /polymorphism/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "volatility.hpp" 3 | 4 | // To compile 5 | // 6 | // Windows users: 7 | // mkdir build 8 | // cd build 9 | // cmake -G "NMake Makefiles" .. 10 | // nmake 11 | // 12 | // OSX / Linux users: 13 | // mkdir build 14 | // cd build 15 | // cmake .. 16 | // make 17 | namespace dauphine 18 | { 19 | void test_access() 20 | { 21 | implied_volatility v; 22 | std::cout << v.underlying_name() << std::endl; 23 | } 24 | } 25 | 26 | int main(int argc, char* argv[]) 27 | { 28 | dauphine::test_access(); 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | build/ 35 | *.swp 36 | 37 | # Npm 38 | dist/ 39 | node_modules/ 40 | package-lock.json 41 | 42 | # Notebook 43 | .ipynb_checkpoints/ 44 | 45 | # tex 46 | *.log 47 | *.aux 48 | *.synctex.gz 49 | -------------------------------------------------------------------------------- /basics/slides/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dauphine_cpp_basics", 3 | "version": "1.0.0", 4 | "description": "cpp basics", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "postinstall": "cpx \"node_modules/reveal.js/**/*\" dist && cpx \"src/**/*\" dist && cpx \"node_modules/genericons/genericons/*.css\" dist && cpx \"node_modules/genericons/genericons/*\" dist/fonts" 9 | }, 10 | "author": "", 11 | "license": "BSD", 12 | "dependencies": { 13 | "genericons": "^1.0.1", 14 | "reveal.js": "^3.4.1" 15 | }, 16 | "devDependencies": { 17 | "cpx": "^1.5.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /stl/slides/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dauphine_cpp_stl", 3 | "version": "1.0.0", 4 | "description": "cpp programming with stl", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "postinstall": "cpx \"node_modules/reveal.js/**/*\" dist && cpx \"src/**/*\" dist && cpx \"node_modules/genericons/genericons/*.css\" dist && cpx \"node_modules/genericons/genericons/*\" dist/fonts" 9 | }, 10 | "author": "", 11 | "license": "BSD", 12 | "dependencies": { 13 | "genericons": "^1.0.1", 14 | "reveal.js": "^3.4.1" 15 | }, 16 | "devDependencies": { 17 | "cpx": "^1.5.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /types/slides/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dauphine_cpp_stl", 3 | "version": "1.0.0", 4 | "description": "defining your own types", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "postinstall": "cpx \"node_modules/reveal.js/**/*\" dist && cpx \"src/**/*\" dist && cpx \"node_modules/genericons/genericons/*.css\" dist && cpx \"node_modules/genericons/genericons/*\" dist/fonts" 9 | }, 10 | "author": "", 11 | "license": "BSD", 12 | "dependencies": { 13 | "genericons": "^1.0.1", 14 | "reveal.js": "^3.4.1" 15 | }, 16 | "devDependencies": { 17 | "cpx": "^1.5.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /polymorphism/slides/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dauphine_cpp_polymorphism", 3 | "version": "1.0.0", 4 | "description": "polymorphism", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "postinstall": "cpx \"node_modules/reveal.js/**/*\" dist && cpx \"src/**/*\" dist && cpx \"node_modules/genericons/genericons/*.css\" dist && cpx \"node_modules/genericons/genericons/*\" dist/fonts" 9 | }, 10 | "author": "", 11 | "license": "BSD", 12 | "dependencies": { 13 | "genericons": "^1.0.1", 14 | "reveal.js": "^3.4.1" 15 | }, 16 | "devDependencies": { 17 | "cpx": "^1.5.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /functional/slides/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dauphine_cpp_functional", 3 | "version": "1.0.0", 4 | "description": "cpp functional programming", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "postinstall": "cpx \"node_modules/reveal.js/**/*\" dist && cpx \"src/**/*\" dist && cpx \"node_modules/genericons/genericons/*.css\" dist && cpx \"node_modules/genericons/genericons/*\" dist/fonts" 9 | }, 10 | "author": "", 11 | "license": "BSD", 12 | "dependencies": { 13 | "genericons": "^1.0.1", 14 | "reveal.js": "^3.4.1" 15 | }, 16 | "devDependencies": { 17 | "cpx": "^1.5.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /pointers/slides/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dauphine_cpp_pointers", 3 | "version": "1.0.0", 4 | "description": "pointers and memeory management", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "postinstall": "cpx \"node_modules/reveal.js/**/*\" dist && cpx \"src/**/*\" dist && cpx \"node_modules/genericons/genericons/*.css\" dist && cpx \"node_modules/genericons/genericons/*\" dist/fonts" 9 | }, 10 | "author": "", 11 | "license": "BSD", 12 | "dependencies": { 13 | "genericons": "^1.0.1", 14 | "reveal.js": "^3.4.1" 15 | }, 16 | "devDependencies": { 17 | "cpx": "^1.5.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /basics/README.md: -------------------------------------------------------------------------------- 1 | The slides are available [online](http://dauphine203.github.io/cpp_dauphine/basics/index.html) 2 | 3 | ## Command line cheatsheet 4 | 5 | - ls : list files and subdirectories in the current directory 6 | - cd path : changes directory to subdirectory path 7 | - cd .. : changes directory to the upper one containing the current directory 8 | - mkdir name : creates a new subdirectory called name 9 | - rm file : removes the file named file 10 | - rm -r dir : removes the subdirectory dir and all it contains 11 | 12 | The TAB key can be used to autocomplete. For instance, if you want to `cd` in `my_super_long_directory`, 13 | just type `cd my_s` and hit the TAB key. 14 | -------------------------------------------------------------------------------- /pointers/cpp/resource.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "resource.hpp" 3 | 4 | namespace dauphine 5 | { 6 | void resource::acquire() 7 | { 8 | std::cout << "resource::acquire" << std::endl; 9 | } 10 | 11 | void resource::release() 12 | { 13 | std::cout << "resource::release" << std::endl; 14 | } 15 | 16 | void resource::print_message() 17 | { 18 | std::cout << "resource::print_message START" << std::endl; 19 | throw std::runtime_error("resource could not print message"); 20 | std::cout << "resource::print_message STATUS" << std::endl; 21 | std::cout << "resource::print_message END" << std::endl; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Dauphine203/cpp_dauphine/basic_nb?labpath=basics%2Fbasics.ipynb) 2 | 3 | # cpp_dauphine 4 | 5 | C++ courses for Paris Dauphine 6 | You can join the [gitter chat](https://gitter.im/Dauphine_master203/cpp) 7 | 8 | ## Slides 9 | 10 | The slides of the different sessions are available [online](https://dauphine203.github.io/cpp_dauphine/#/). 11 | 12 | ## Requirements 13 | 14 | The following must be installed: 15 | 16 | - cmake 17 | - git 18 | - VS 2015 (or 2017) for Windows users 19 | 20 | Once you've installed git (or git-for-windows), open a console (or a git-bash) and type 21 | 22 | ```bash 23 | git config --global user.name "your_github_name" 24 | git config --global user.email "your_email" 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /pointers/cpp/option.cpp: -------------------------------------------------------------------------------- 1 | #include "option.hpp" 2 | 3 | namespace dauphine 4 | { 5 | volatility::volatility() 6 | { 7 | std::cout << "volatility constructor" << std::endl; 8 | } 9 | 10 | volatility::~volatility() 11 | { 12 | std::cout << "volatility destructor" << std::endl; 13 | } 14 | 15 | double volatility::get_volatility(double maturity, double strike) const 16 | { 17 | return 0.14; 18 | } 19 | 20 | volatility* make_volatility() 21 | { 22 | return new volatility; 23 | } 24 | 25 | underlying::underlying(volatility* vol) 26 | { 27 | } 28 | 29 | underlying::~underlying() 30 | { 31 | } 32 | 33 | option::option(underlying* underlying, volatility* vol) 34 | { 35 | } 36 | 37 | option::~option() 38 | { 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /exercises/interpolation/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "interpolation_impl.hpp" 3 | 4 | namespace dauphine 5 | { 6 | void test_spline_interpolation() 7 | { 8 | interpolation_impl* inter 9 | = make_interpolation({1., 2., 3., 4.}, 10 | {1., 4., 9., 16.}, 11 | interpolation_type::spline); 12 | double res = inter->interpolate(2.5); 13 | std::cout << res << std::endl; 14 | delete inter; 15 | 16 | interpolation_impl* inter2 = make_interpolation(...); 17 | *inter1 = *inter2; 18 | 19 | 20 | interpolation inter(x, y, interpolation_type::spline); 21 | inter.interpolate(...); 22 | interpolation inter2 = inter; 23 | 24 | interpolation x; 25 | 26 | func(x, x); 27 | } 28 | } 29 | 30 | int main(int argc, char* argv[]) 31 | { 32 | dauphine::test_spline_interpolation(); 33 | return 0; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /pointers/cpp/option.hpp: -------------------------------------------------------------------------------- 1 | #ifndef OPTION_HPP 2 | #define OPATION_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace dauphine 8 | { 9 | class volatility 10 | { 11 | public: 12 | 13 | volatility(); 14 | ~volatility(); 15 | 16 | double get_volatility(double maturity, double strike) const; 17 | }; 18 | 19 | volatility* make_volatility(); 20 | 21 | class underlying 22 | { 23 | public: 24 | 25 | underlying(volatility* vol); 26 | ~underlying(); 27 | 28 | private: 29 | 30 | volatility* p_volatility; 31 | }; 32 | 33 | class option 34 | { 35 | public: 36 | 37 | option(underlying* underlying, volatility* vol); 38 | ~option(); 39 | 40 | private: 41 | 42 | underlying* p_underlying; 43 | volatility* p_volatility; 44 | }; 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /exercises/interpolation/interpolation.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INTERPOLATION_HPP 2 | #define INTERPOLATION_HPP 3 | 4 | #include 5 | 6 | namespace dauphine 7 | { 8 | enum class interpolation_type 9 | { 10 | linear, 11 | spline 12 | }; 13 | 14 | class interpolation_impl; 15 | 16 | class interpolation 17 | { 18 | public: 19 | 20 | interpolation(const std::vector& x, 21 | const std::vector& y, 22 | interpolation_type type); 23 | ~interpolation(); 24 | 25 | interpolation(const interpolation& rhs); 26 | interpolation& operator=(const interpolation& rhs); 27 | 28 | interpolation(interpolation&& rhs); 29 | interpolation& operator=(interpolation&& rhs); 30 | 31 | double interpolate(double x) const; 32 | 33 | private: 34 | 35 | interpolation_impl* p_impl; 36 | }; 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | } 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /pointers/cpp/pricer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PRICER_HPP 2 | #define PRICER_HPP 3 | 4 | #include 5 | 6 | namespace dauphine 7 | { 8 | class data_model; 9 | class product; 10 | 11 | using data_model_ptr = std::shared_ptr; 12 | using product_ptr = std::shared_ptr; 13 | 14 | class data_model 15 | { 16 | public: 17 | 18 | data_model(product_ptr prod); 19 | ~data_model(); 20 | 21 | private: 22 | 23 | product_ptr p_product; 24 | }; 25 | 26 | class product 27 | { 28 | public: 29 | 30 | product(); 31 | ~product(); 32 | }; 33 | 34 | class pricer 35 | { 36 | public: 37 | 38 | pricer(product_ptr prod, data_model_ptr data); 39 | ~pricer(); 40 | 41 | private: 42 | 43 | product_ptr p_product; 44 | data_model_ptr p_data; 45 | }; 46 | 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /pointers/cpp/pricer.cpp: -------------------------------------------------------------------------------- 1 | #include "pricer.hpp" 2 | #include 3 | 4 | namespace dauphine 5 | { 6 | data_model::data_model(product_ptr prod) 7 | : p_product(prod) 8 | { 9 | std::cout << "data_model constructor" << std::endl; 10 | } 11 | 12 | data_model::~data_model() 13 | { 14 | std::cout << "data_model destructor" << std::endl; 15 | } 16 | 17 | product::product() 18 | { 19 | std::cout << "product constructor" << std::endl; 20 | } 21 | 22 | product::~product() 23 | { 24 | std::cout << "product destructor" << std::endl; 25 | } 26 | 27 | pricer::pricer(product_ptr prod, data_model_ptr data) 28 | : p_product(prod), p_data(data) 29 | { 30 | std::cout << "pricer constructor" << std::endl; 31 | } 32 | 33 | pricer::~pricer() 34 | { 35 | std::cout << "pricer destructor" << std::endl; 36 | } 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /exercises/interpolation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(interpolation) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | 10 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 11 | endif() 12 | 13 | if(MSVC) 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 15 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 16 | endif() 17 | 18 | set(TYPES_SRCS 19 | main.cpp 20 | interpolation.hpp 21 | interpolation.cpp 22 | interpolation_impl.hpp 23 | interpolation_impl.cpp) 24 | 25 | set(TYPES_TARGET test_interpolation) 26 | add_executable(${TYPES_TARGET} ${TYPES_SRCS}) 27 | 28 | -------------------------------------------------------------------------------- /pointers/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include "resource.hpp" 2 | #include "option.hpp" 3 | #include "pricer.hpp" 4 | 5 | // TO COMPILE: 6 | // 7 | // WINDOWS USERS 8 | // mkdir build 9 | // cd build 10 | // cmake -G "NMake Makefiles" .. 11 | // nmake 12 | // 13 | // OSX USERS 14 | // mkdir build 15 | // cd build 16 | // cmake .. 17 | // make 18 | 19 | namespace dauphine 20 | { 21 | void test_resource() 22 | { 23 | resource r; 24 | r.acquire(); 25 | r.print_message(); 26 | r.release(); 27 | } 28 | 29 | void test_volatility() 30 | { 31 | volatility* vol = make_volatility(); 32 | underlying u(vol); 33 | option opt(&u, vol); 34 | } 35 | 36 | void test_pricer() 37 | { 38 | product_ptr prod = product_ptr(new product); 39 | data_model_ptr data = std::make_shared(prod); 40 | pricer p(prod, data); 41 | } 42 | } 43 | 44 | int main(int artc, char* argv[]) 45 | { 46 | dauphine::test_resource(); 47 | return 0; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /exercises/chess/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(placehoder) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(CHESS_SRCS 24 | main.cpp) 25 | 26 | set(CHESS_TARGET chess) 27 | add_executable(${CHESS_TARGET} ${CHESS_SRCS}) 28 | 29 | -------------------------------------------------------------------------------- /basics/cpp/first_program/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(first_program) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(FIRST_SRCS main.cpp) 24 | 25 | set(FIRST_TARGET first_program) 26 | add_executable(${FIRST_TARGET} ${FIRST_SRCS}) 27 | 28 | -------------------------------------------------------------------------------- /polymorphism/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(placehoder) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(TYPES_SRCS 24 | main.cpp 25 | volatility.cpp) 26 | 27 | set(TYPES_TARGET polymorphism) 28 | add_executable(${TYPES_TARGET} ${TYPES_SRCS}) 29 | 30 | -------------------------------------------------------------------------------- /basics/cpp/placeholder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(placehoder) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(PLACEHOLDER_SRCS main.cpp) 24 | 25 | set(PLACEHOLDER_TARGET placeholder_program) 26 | add_executable(${PLACEHOLDER_TARGET} ${PLACEHOLDER_SRCS}) 27 | 28 | -------------------------------------------------------------------------------- /functional/cpp/single_file/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(placehoder) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(FUNCTIONAL_SRCS 24 | main.cpp) 25 | 26 | set(FUNCTIONAL_TARGET functional) 27 | add_executable(${FUNCTIONAL_TARGET} ${FUNCTIONAL_SRCS}) 28 | 29 | -------------------------------------------------------------------------------- /types/move_semantic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(placehoder) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(MVSEM_SRCS 24 | main.cpp 25 | resource.cpp) 26 | 27 | set(MVSEM_TARGET move_semantic) 28 | add_executable(${MVSEM_TARGET} ${MVSEM_SRCS}) 29 | 30 | -------------------------------------------------------------------------------- /exercises/polynomial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(placehoder) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(TYPES_SRCS 24 | main.cpp 25 | polynomial.cpp) 26 | 27 | set(TYPES_TARGET test_polynomial) 28 | add_executable(${TYPES_TARGET} ${TYPES_SRCS}) 29 | 30 | -------------------------------------------------------------------------------- /types/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(placehoder) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(TYPES_SRCS 24 | main.cpp 25 | matrix.cpp 26 | uvector.cpp) 27 | 28 | set(TYPES_TARGET types_practice) 29 | add_executable(${TYPES_TARGET} ${TYPES_SRCS}) 30 | 31 | -------------------------------------------------------------------------------- /stl/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(placehoder) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(STL_SRCS 24 | main.cpp 25 | vector_utils.cpp 26 | additional_exercises.cpp) 27 | 28 | set(STL_TARGET stl_practice) 29 | add_executable(${STL_TARGET} ${STL_SRCS}) 30 | 31 | -------------------------------------------------------------------------------- /pointers/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(placehoder) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(TYPES_SRCS 24 | main.cpp 25 | resource.cpp 26 | option.cpp 27 | pricer.cpp) 28 | 29 | set(TYPES_TARGET pointers_practice) 30 | add_executable(${TYPES_TARGET} ${TYPES_SRCS}) 31 | 32 | -------------------------------------------------------------------------------- /functional/cpp/multi_files/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(placehoder) 3 | 4 | include(CheckCXXCompilerFlag) 5 | 6 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion") 8 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion") 9 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 10 | 11 | if (HAS_CPP14_FLAG) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 13 | else() 14 | message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") 15 | endif() 16 | endif() 17 | 18 | if(MSVC) 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") 20 | set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO) 21 | endif() 22 | 23 | set(FUNCTIONAL_SRCS 24 | main.cpp 25 | discount_factor.cpp 26 | discount_factor.hpp 27 | bond_pricer.hpp) 28 | 29 | set(FUNCTIONAL_TARGET functional) 30 | add_executable(${FUNCTIONAL_TARGET} ${FUNCTIONAL_SRCS}) 31 | 32 | -------------------------------------------------------------------------------- /types/move_semantic/resource.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RESOURCE_HPP 2 | #define RESOURCE_HPP 3 | 4 | namespace dauphine 5 | { 6 | // Simple class to track calls to construtors / destructor / assignments 7 | // In a real application, resource could hold a dynamic allocated array, 8 | // a connection to a database, an handler on a file or anything that 9 | // requires user-defined value semantic. 10 | // Each resource has a unique id (this is guaranteed by construction), 11 | // and a value that may be copied / moved from another resource. 12 | // A value of 0 means an uninitialized resource (or a resource that has been 13 | // reset after a move example) 14 | class resource 15 | { 16 | public: 17 | 18 | resource(int value = 0); 19 | ~resource(); 20 | 21 | resource(const resource& rhs); 22 | resource& operator=(const resource& rhs); 23 | 24 | resource(resource&& rhs); 25 | resource& operator=(resource&& rhs); 26 | 27 | int get_id() const; 28 | int get_value() const; 29 | 30 | private: 31 | 32 | int m_id; 33 | int m_value; 34 | }; 35 | 36 | std::ostream& operator<<(std::ostream& out, const resource& r); 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /exercises/interpolation/interpolation.cpp: -------------------------------------------------------------------------------- 1 | #include "interpolation.hpp" 2 | #include "interpolation_impl.hpp" 3 | 4 | 5 | namespace dauphine 6 | { 7 | interpolation_impl* 8 | make_interpolation(const std::vector& x, 9 | const std::vector& y, 10 | interpolation_type t) 11 | { 12 | switch(t) 13 | { 14 | case interpolation_type::linear: 15 | return new linear_interpolation(x, y); 16 | case interpolation_type::spline: 17 | return new spline_interpolation(x, y); 18 | } 19 | } 20 | 21 | interpolation::interpolation(const std::vector& x, 22 | const std::vector& y, 23 | interpolation_type type) 24 | : p_impl(make_interpolation(x, y, type)) 25 | { 26 | } 27 | 28 | interpolation::~interpolation() 29 | { 30 | delete p_impl; 31 | p_impl = nullptr; 32 | } 33 | 34 | interpolation::interpolation(const interpolation& rhs) 35 | : p_impl(rhs.p_impl->clone()) 36 | { 37 | } 38 | 39 | interpolation& interpolation::operator=(const interpolation& rhs) 40 | { 41 | interpolation tmp(rhs); 42 | std::swap(tmp.p_impl, this->p_impl); 43 | return *this; 44 | } 45 | 46 | interpolation::interpolation(interpolation&& rhs) 47 | : p_impl(rhs.p_impl) 48 | { 49 | rhs.p_impl = nullptr; 50 | } 51 | 52 | interpolation& operator=(interpolation&& rhs) 53 | { 54 | std::swap(p_impl, rhs.p_impl); 55 | return *this; 56 | } 57 | 58 | double interpolation::interpolate(double x) const 59 | { 60 | return p_impl->interpolate(x); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /stl/cpp/additional_exercises.cpp: -------------------------------------------------------------------------------- 1 | #include "additional_exercises.hpp" 2 | 3 | namespace dauphine 4 | { 5 | 6 | /* 7 | * Exercise 1 8 | * 9 | * Write a linear interpolation function that takes 3 input vectors: 10 | * 11 | * - x: the abscissa 12 | * - y: the ordinates 13 | * - x_interp: the abscissa of the wanted values 14 | * 15 | * and an output vector res, holding the ordinates of the interpolated points. 16 | * 17 | * That is, for each abscissa a in x_interp such that x1 < a < x2, res holds a value 18 | * v_res such that (a, v_res) is the linear interpolation of (x1, y1) and (x2, y2). 19 | */ 20 | 21 | /* 22 | * Exercise 2 23 | * 24 | * Given a std::vector holding values between 0 and 9, 25 | * count the numbers of pairs with sum equal to 9. 26 | * 27 | * For instance, if the input vector is { 0, 0, 1, 2, 3, 3, 4, 5, 6, 6, 8, 8, 9 }, 28 | * the result is 5: (0, 9), (1, 8), (3, 6), (3, 6), (4, 5). 29 | * 30 | * A number can be consumed only once to form such a pair. 31 | * 32 | * We assume the input vector is sorted. 33 | */ 34 | 35 | /* 36 | * Exercise 3 37 | * 38 | * Given a std::vector holding values between 0 and 9, and an integer n, 39 | * count the numbers of pairs with sum equal to 9 that hold n as their first value 40 | * 41 | * For instance, if the input vector is { 0, 0, 1, 2, 3, 3, 4, 5, 6, 6, 8, 8, 9 } and n = 3, 42 | * the result is 2: 43 | * 44 | * A number can be consumed only once to form such a pair. 45 | * 46 | * We assume the input vector is sorted. 47 | * 48 | * 49 | */ 50 | } 51 | 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /types/move_semantic/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "resource.hpp" 3 | 4 | namespace dauphine 5 | { 6 | resource get_resource(int i) 7 | { 8 | return resource(i); 9 | } 10 | 11 | void compute(const resource& param) 12 | { 13 | std::cout << "compute(const resource& param) - id = " << param.get_id() << std::endl; 14 | } 15 | 16 | void compute(resource&& param) 17 | { 18 | std::cout << "compute(resource&& param) - id = " << param.get_id() << std::endl; 19 | } 20 | 21 | void test_copy() 22 | { 23 | std::cout << "TEST COPY" << std::endl; 24 | resource r1(1); 25 | resource r2 = r1; 26 | resource r3(4); 27 | r2 = r3; 28 | } 29 | 30 | void test_move() 31 | { 32 | std::cout << "TEST MOVE" << std::endl; 33 | resource r1(10); 34 | // r1 should not be used after beeing moved 35 | resource r2 = std::move(r1); 36 | resource r3(20); 37 | r2 = std::move(r3); 38 | } 39 | 40 | void test_lvalue_ref() 41 | { 42 | std::cout << "TEST LVALUE REF" << std::endl; 43 | resource r(15); 44 | compute(r); 45 | } 46 | 47 | void test_rvalue_ref() 48 | { 49 | std::cout << "TEST RVALUE REF" << std::endl; 50 | compute(get_resource(20)); 51 | } 52 | 53 | void test_rvalue_ref_as_lvalue() 54 | { 55 | std::cout << "TEST RVALUE REF AS LVALUE" << std::endl; 56 | resource&& r = get_resource(48); 57 | compute(r); 58 | compute(std::move(r)); 59 | } 60 | 61 | void full_test() 62 | { 63 | test_copy(); 64 | test_move(); 65 | test_lvalue_ref(); 66 | test_rvalue_ref(); 67 | test_rvalue_ref_as_lvalue(); 68 | } 69 | } 70 | 71 | 72 | int main(int argc, char* argv[]) 73 | { 74 | dauphine::full_test(); 75 | return 0; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /types/move_semantic/resource.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "resource.hpp" 3 | 4 | namespace dauphine 5 | { 6 | int next_id() 7 | { 8 | static int id = 0; 9 | return id++; 10 | } 11 | 12 | resource::resource(int value) 13 | : m_id(next_id()), m_value(value) 14 | { 15 | std::cout << "Resource constructor: " << *this << std::endl; 16 | } 17 | 18 | resource::~resource() 19 | { 20 | std::cout << "Resource destructor: " << *this << std::endl; 21 | } 22 | 23 | resource::resource(const resource& rhs) 24 | : m_id(next_id()), m_value(rhs.m_value) // We don't copy the id since we want it to be unique 25 | { 26 | std::cout << "Resource copy constructor: " << *this << " from resource: " << rhs << std::endl; 27 | } 28 | 29 | resource& resource::operator=(const resource& rhs) 30 | { 31 | std::cout << "Resource copy assign operator: " << *this << " from resource: " << rhs << std::endl; 32 | m_value = rhs.m_value; 33 | return *this; 34 | } 35 | 36 | resource::resource(resource&& rhs) 37 | : m_id(next_id()), m_value(std::move(rhs.m_value)) 38 | { 39 | std::cout << "Resource move constructor: " << *this << " from resource: " << rhs << std::endl; 40 | rhs.m_value = 0; 41 | } 42 | 43 | resource& resource::operator=(resource&& rhs) 44 | { 45 | std::cout << "Resource move assign operator: " << *this << "from resource: " << rhs << std::endl; 46 | std::swap(m_value, rhs.m_value); 47 | return *this; 48 | } 49 | 50 | int resource::get_id() const 51 | { 52 | return m_id; 53 | } 54 | 55 | int resource::get_value() const 56 | { 57 | return m_value; 58 | } 59 | 60 | std::ostream& operator<<(std::ostream& out, const resource& r) 61 | { 62 | out << "id = " << r.get_id() << " - " << "value = " << r.get_value(); 63 | return out; 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /exercises/interpolation/interpolation_impl.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INTERPOLATION_IMPL_HPP 2 | #define INTERPOLATION_IMPL_HPP 3 | 4 | #include 5 | 6 | namespace dauphine 7 | { 8 | class interpolation_impl 9 | { 10 | public: 11 | 12 | virtual ~interplation_impl() = default; 13 | 14 | interpolation_impl& 15 | operator=(const interpolation_impl&) = delete; 16 | 17 | interpolation_impl(interpolation_impl&&) = delete; 18 | interpolation_impl& 19 | operator=(interpolation_impl&) = delete; 20 | 21 | double interpolate(double x) const; 22 | 23 | virtual interpolation_impl* clone() const = 0; 24 | 25 | protected: 26 | 27 | interpolation_impl(const std::vector& x, 28 | const std::vector& y); 29 | interpolation_impl(const interpolation_impl&) = default; 30 | 31 | const std::vector& get_x() const; 32 | const std::vector& get_y() const; 33 | 34 | private: 35 | 36 | size_t find_upper_bound(double x) const; 37 | virtual double interpolate_impl(double x, 38 | size_t upper_bound) const = 0; 39 | 40 | std::vector m_x; 41 | std::vector m_y; 42 | }; 43 | 44 | class spline_interpolation : public interpolation_impl 45 | { 46 | public: 47 | 48 | spline_interpolation(const std::vector& x, 49 | const std::vector& y); 50 | 51 | interpolation_impl* clone() const override; 52 | private: 53 | 54 | spline_interpolation(const spline_interpolation&) = default; 55 | double interpolate_impl(double x, 56 | size_t upper_bound) const override; 57 | 58 | std::vector m_y2; 59 | }; 60 | 61 | class linear_interpolation : public interpolation_impl 62 | { 63 | public: 64 | 65 | linear_interpolation(const std::vector& x, 66 | const std::vector& y); 67 | 68 | interpolation_impl* clone() const override; 69 | 70 | private: 71 | 72 | linear_interpolation(const linear_interpolation&) = default; 73 | double interpolate_impl(double x, 74 | size_t upper_bound) const override; 75 | }; 76 | 77 | } 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | #endif 87 | 88 | -------------------------------------------------------------------------------- /basics/slides/src/twitter-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /stl/slides/src/twitter-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /types/slides/src/twitter-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /functional/slides/src/twitter-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /pointers/slides/src/twitter-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /polymorphism/slides/src/twitter-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /projects/pde1d/superbox.sty: -------------------------------------------------------------------------------- 1 | %%%% debut macro %%%% 2 | % eclbkbox.sty by Hideki Isozaki, 1992 3 | % Date: May 28, 1993 4 | 5 | \newbox\bk@bxb 6 | \newbox\bk@bxa 7 | \newif\if@bkcont 8 | \newif\ifbkcount 9 | \newcount\bk@lcnt 10 | 11 | \def\breakboxskip{2pt} 12 | \def\breakboxparindent{1.8em} 13 | 14 | \def\breakbox{\vskip\breakboxskip\relax 15 | \setbox\bk@bxb\vbox\bgroup 16 | \advance\linewidth -2\fboxrule 17 | \advance\linewidth -2\fboxsep 18 | \hsize\linewidth\@parboxrestore 19 | \parindent\breakboxparindent\relax} 20 | 21 | % \@tempdimb: amount of vertical skip 22 | % between the first line (\bk@bxa) and the rest (\bk@bxb) 23 | \def\bk@split{% 24 | \@tempdimb\ht\bk@bxb % height of original box 25 | \advance\@tempdimb\dp\bk@bxb 26 | \setbox\bk@bxa\vsplit\bk@bxb to\z@ % split it 27 | \setbox\bk@bxa\vbox{\unvbox\bk@bxa}% recover height & depth of \bk@bxa 28 | \setbox\@tempboxa\vbox{\copy\bk@bxa\copy\bk@bxb}% naive concatenation 29 | \advance\@tempdimb-\ht\@tempboxa 30 | \advance\@tempdimb-\dp\@tempboxa}% gap between two boxes 31 | 32 | 33 | % \@tempdima: height of the first line (\bk@bxa) + fboxsep 34 | \def\bk@addfsepht{% 35 | \setbox\bk@bxa\vbox{\vskip\fboxsep\box\bk@bxa}} 36 | 37 | \def\bk@addskipht{% 38 | \setbox\bk@bxa\vbox{\vskip\@tempdimb\box\bk@bxa}} 39 | 40 | % \@tempdima: depth of the first line (\bk@bxa) + fboxsep 41 | \def\bk@addfsepdp{% 42 | \@tempdima\dp\bk@bxa 43 | \advance\@tempdima\fboxsep 44 | \dp\bk@bxa\@tempdima} 45 | 46 | % \@tempdima: depth of the first line (\bk@bxa) + vertical skip 47 | \def\bk@addskipdp{% 48 | \@tempdima\dp\bk@bxa 49 | \advance\@tempdima\@tempdimb 50 | \dp\bk@bxa\@tempdima} 51 | 52 | \def\bk@line{% 53 | \hbox to \linewidth{\ifbkcount\smash{\llap{\the\bk@lcnt\ }}\fi 54 | \vrule \@width\fboxrule\hskip\fboxsep 55 | \box\bk@bxa\hfil 56 | \hskip\fboxsep\vrule \@width\fboxrule}} 57 | 58 | \def\endbreakbox{\egroup 59 | \ifhmode\par\fi{\noindent\bk@lcnt\@ne 60 | \@bkconttrue\baselineskip\z@\lineskiplimit\z@ 61 | \lineskip\z@\vfuzz\maxdimen 62 | \bk@split\bk@addfsepht\bk@addskipdp 63 | \ifvoid\bk@bxb % Only one line 64 | \def\bk@fstln{\bk@addfsepdp 65 | \vbox{\hrule\@height\fboxrule\bk@line\hrule\@height\fboxrule}}% 66 | \else % More than one line 67 | \def\bk@fstln{\vbox{\hrule\@height\fboxrule\bk@line}\hfil 68 | \advance\bk@lcnt\@ne 69 | \loop 70 | \bk@split\bk@addskipdp\leavevmode 71 | \ifvoid\bk@bxb % The last line 72 | \@bkcontfalse\bk@addfsepdp 73 | \vtop{\bk@line\hrule\@height\fboxrule}% 74 | \else % 2,...,(n-1) 75 | \bk@line 76 | \fi 77 | \hfil\advance\bk@lcnt\@ne 78 | \if@bkcont\repeat}% 79 | \fi 80 | \leavevmode\bk@fstln\par}\vskip\breakboxskip\relax} 81 | 82 | \bkcountfalse 83 | %%%% fin macro %%%% -------------------------------------------------------------------------------- /projects/breakeven-volatility/superbox.sty: -------------------------------------------------------------------------------- 1 | %%%% debut macro %%%% 2 | % eclbkbox.sty by Hideki Isozaki, 1992 3 | % Date: May 28, 1993 4 | 5 | \newbox\bk@bxb 6 | \newbox\bk@bxa 7 | \newif\if@bkcont 8 | \newif\ifbkcount 9 | \newcount\bk@lcnt 10 | 11 | \def\breakboxskip{2pt} 12 | \def\breakboxparindent{1.8em} 13 | 14 | \def\breakbox{\vskip\breakboxskip\relax 15 | \setbox\bk@bxb\vbox\bgroup 16 | \advance\linewidth -2\fboxrule 17 | \advance\linewidth -2\fboxsep 18 | \hsize\linewidth\@parboxrestore 19 | \parindent\breakboxparindent\relax} 20 | 21 | % \@tempdimb: amount of vertical skip 22 | % between the first line (\bk@bxa) and the rest (\bk@bxb) 23 | \def\bk@split{% 24 | \@tempdimb\ht\bk@bxb % height of original box 25 | \advance\@tempdimb\dp\bk@bxb 26 | \setbox\bk@bxa\vsplit\bk@bxb to\z@ % split it 27 | \setbox\bk@bxa\vbox{\unvbox\bk@bxa}% recover height & depth of \bk@bxa 28 | \setbox\@tempboxa\vbox{\copy\bk@bxa\copy\bk@bxb}% naive concatenation 29 | \advance\@tempdimb-\ht\@tempboxa 30 | \advance\@tempdimb-\dp\@tempboxa}% gap between two boxes 31 | 32 | 33 | % \@tempdima: height of the first line (\bk@bxa) + fboxsep 34 | \def\bk@addfsepht{% 35 | \setbox\bk@bxa\vbox{\vskip\fboxsep\box\bk@bxa}} 36 | 37 | \def\bk@addskipht{% 38 | \setbox\bk@bxa\vbox{\vskip\@tempdimb\box\bk@bxa}} 39 | 40 | % \@tempdima: depth of the first line (\bk@bxa) + fboxsep 41 | \def\bk@addfsepdp{% 42 | \@tempdima\dp\bk@bxa 43 | \advance\@tempdima\fboxsep 44 | \dp\bk@bxa\@tempdima} 45 | 46 | % \@tempdima: depth of the first line (\bk@bxa) + vertical skip 47 | \def\bk@addskipdp{% 48 | \@tempdima\dp\bk@bxa 49 | \advance\@tempdima\@tempdimb 50 | \dp\bk@bxa\@tempdima} 51 | 52 | \def\bk@line{% 53 | \hbox to \linewidth{\ifbkcount\smash{\llap{\the\bk@lcnt\ }}\fi 54 | \vrule \@width\fboxrule\hskip\fboxsep 55 | \box\bk@bxa\hfil 56 | \hskip\fboxsep\vrule \@width\fboxrule}} 57 | 58 | \def\endbreakbox{\egroup 59 | \ifhmode\par\fi{\noindent\bk@lcnt\@ne 60 | \@bkconttrue\baselineskip\z@\lineskiplimit\z@ 61 | \lineskip\z@\vfuzz\maxdimen 62 | \bk@split\bk@addfsepht\bk@addskipdp 63 | \ifvoid\bk@bxb % Only one line 64 | \def\bk@fstln{\bk@addfsepdp 65 | \vbox{\hrule\@height\fboxrule\bk@line\hrule\@height\fboxrule}}% 66 | \else % More than one line 67 | \def\bk@fstln{\vbox{\hrule\@height\fboxrule\bk@line}\hfil 68 | \advance\bk@lcnt\@ne 69 | \loop 70 | \bk@split\bk@addskipdp\leavevmode 71 | \ifvoid\bk@bxb % The last line 72 | \@bkcontfalse\bk@addfsepdp 73 | \vtop{\bk@line\hrule\@height\fboxrule}% 74 | \else % 2,...,(n-1) 75 | \bk@line 76 | \fi 77 | \hfil\advance\bk@lcnt\@ne 78 | \if@bkcont\repeat}% 79 | \fi 80 | \leavevmode\bk@fstln\par}\vskip\breakboxskip\relax} 81 | 82 | \bkcountfalse 83 | %%%% fin macro %%%% 84 | -------------------------------------------------------------------------------- /projects/currency-ranking/superbox.sty: -------------------------------------------------------------------------------- 1 | %%%% debut macro %%%% 2 | % eclbkbox.sty by Hideki Isozaki, 1992 3 | % Date: May 28, 1993 4 | 5 | \newbox\bk@bxb 6 | \newbox\bk@bxa 7 | \newif\if@bkcont 8 | \newif\ifbkcount 9 | \newcount\bk@lcnt 10 | 11 | \def\breakboxskip{2pt} 12 | \def\breakboxparindent{1.8em} 13 | 14 | \def\breakbox{\vskip\breakboxskip\relax 15 | \setbox\bk@bxb\vbox\bgroup 16 | \advance\linewidth -2\fboxrule 17 | \advance\linewidth -2\fboxsep 18 | \hsize\linewidth\@parboxrestore 19 | \parindent\breakboxparindent\relax} 20 | 21 | % \@tempdimb: amount of vertical skip 22 | % between the first line (\bk@bxa) and the rest (\bk@bxb) 23 | \def\bk@split{% 24 | \@tempdimb\ht\bk@bxb % height of original box 25 | \advance\@tempdimb\dp\bk@bxb 26 | \setbox\bk@bxa\vsplit\bk@bxb to\z@ % split it 27 | \setbox\bk@bxa\vbox{\unvbox\bk@bxa}% recover height & depth of \bk@bxa 28 | \setbox\@tempboxa\vbox{\copy\bk@bxa\copy\bk@bxb}% naive concatenation 29 | \advance\@tempdimb-\ht\@tempboxa 30 | \advance\@tempdimb-\dp\@tempboxa}% gap between two boxes 31 | 32 | 33 | % \@tempdima: height of the first line (\bk@bxa) + fboxsep 34 | \def\bk@addfsepht{% 35 | \setbox\bk@bxa\vbox{\vskip\fboxsep\box\bk@bxa}} 36 | 37 | \def\bk@addskipht{% 38 | \setbox\bk@bxa\vbox{\vskip\@tempdimb\box\bk@bxa}} 39 | 40 | % \@tempdima: depth of the first line (\bk@bxa) + fboxsep 41 | \def\bk@addfsepdp{% 42 | \@tempdima\dp\bk@bxa 43 | \advance\@tempdima\fboxsep 44 | \dp\bk@bxa\@tempdima} 45 | 46 | % \@tempdima: depth of the first line (\bk@bxa) + vertical skip 47 | \def\bk@addskipdp{% 48 | \@tempdima\dp\bk@bxa 49 | \advance\@tempdima\@tempdimb 50 | \dp\bk@bxa\@tempdima} 51 | 52 | \def\bk@line{% 53 | \hbox to \linewidth{\ifbkcount\smash{\llap{\the\bk@lcnt\ }}\fi 54 | \vrule \@width\fboxrule\hskip\fboxsep 55 | \box\bk@bxa\hfil 56 | \hskip\fboxsep\vrule \@width\fboxrule}} 57 | 58 | \def\endbreakbox{\egroup 59 | \ifhmode\par\fi{\noindent\bk@lcnt\@ne 60 | \@bkconttrue\baselineskip\z@\lineskiplimit\z@ 61 | \lineskip\z@\vfuzz\maxdimen 62 | \bk@split\bk@addfsepht\bk@addskipdp 63 | \ifvoid\bk@bxb % Only one line 64 | \def\bk@fstln{\bk@addfsepdp 65 | \vbox{\hrule\@height\fboxrule\bk@line\hrule\@height\fboxrule}}% 66 | \else % More than one line 67 | \def\bk@fstln{\vbox{\hrule\@height\fboxrule\bk@line}\hfil 68 | \advance\bk@lcnt\@ne 69 | \loop 70 | \bk@split\bk@addskipdp\leavevmode 71 | \ifvoid\bk@bxb % The last line 72 | \@bkcontfalse\bk@addfsepdp 73 | \vtop{\bk@line\hrule\@height\fboxrule}% 74 | \else % 2,...,(n-1) 75 | \bk@line 76 | \fi 77 | \hfil\advance\bk@lcnt\@ne 78 | \if@bkcont\repeat}% 79 | \fi 80 | \leavevmode\bk@fstln\par}\vskip\breakboxskip\relax} 81 | 82 | \bkcountfalse 83 | %%%% fin macro %%%% 84 | -------------------------------------------------------------------------------- /projects/super-replication/superbox.sty: -------------------------------------------------------------------------------- 1 | %%%% debut macro %%%% 2 | % eclbkbox.sty by Hideki Isozaki, 1992 3 | % Date: May 28, 1993 4 | 5 | \newbox\bk@bxb 6 | \newbox\bk@bxa 7 | \newif\if@bkcont 8 | \newif\ifbkcount 9 | \newcount\bk@lcnt 10 | 11 | \def\breakboxskip{2pt} 12 | \def\breakboxparindent{1.8em} 13 | 14 | \def\breakbox{\vskip\breakboxskip\relax 15 | \setbox\bk@bxb\vbox\bgroup 16 | \advance\linewidth -2\fboxrule 17 | \advance\linewidth -2\fboxsep 18 | \hsize\linewidth\@parboxrestore 19 | \parindent\breakboxparindent\relax} 20 | 21 | % \@tempdimb: amount of vertical skip 22 | % between the first line (\bk@bxa) and the rest (\bk@bxb) 23 | \def\bk@split{% 24 | \@tempdimb\ht\bk@bxb % height of original box 25 | \advance\@tempdimb\dp\bk@bxb 26 | \setbox\bk@bxa\vsplit\bk@bxb to\z@ % split it 27 | \setbox\bk@bxa\vbox{\unvbox\bk@bxa}% recover height & depth of \bk@bxa 28 | \setbox\@tempboxa\vbox{\copy\bk@bxa\copy\bk@bxb}% naive concatenation 29 | \advance\@tempdimb-\ht\@tempboxa 30 | \advance\@tempdimb-\dp\@tempboxa}% gap between two boxes 31 | 32 | 33 | % \@tempdima: height of the first line (\bk@bxa) + fboxsep 34 | \def\bk@addfsepht{% 35 | \setbox\bk@bxa\vbox{\vskip\fboxsep\box\bk@bxa}} 36 | 37 | \def\bk@addskipht{% 38 | \setbox\bk@bxa\vbox{\vskip\@tempdimb\box\bk@bxa}} 39 | 40 | % \@tempdima: depth of the first line (\bk@bxa) + fboxsep 41 | \def\bk@addfsepdp{% 42 | \@tempdima\dp\bk@bxa 43 | \advance\@tempdima\fboxsep 44 | \dp\bk@bxa\@tempdima} 45 | 46 | % \@tempdima: depth of the first line (\bk@bxa) + vertical skip 47 | \def\bk@addskipdp{% 48 | \@tempdima\dp\bk@bxa 49 | \advance\@tempdima\@tempdimb 50 | \dp\bk@bxa\@tempdima} 51 | 52 | \def\bk@line{% 53 | \hbox to \linewidth{\ifbkcount\smash{\llap{\the\bk@lcnt\ }}\fi 54 | \vrule \@width\fboxrule\hskip\fboxsep 55 | \box\bk@bxa\hfil 56 | \hskip\fboxsep\vrule \@width\fboxrule}} 57 | 58 | \def\endbreakbox{\egroup 59 | \ifhmode\par\fi{\noindent\bk@lcnt\@ne 60 | \@bkconttrue\baselineskip\z@\lineskiplimit\z@ 61 | \lineskip\z@\vfuzz\maxdimen 62 | \bk@split\bk@addfsepht\bk@addskipdp 63 | \ifvoid\bk@bxb % Only one line 64 | \def\bk@fstln{\bk@addfsepdp 65 | \vbox{\hrule\@height\fboxrule\bk@line\hrule\@height\fboxrule}}% 66 | \else % More than one line 67 | \def\bk@fstln{\vbox{\hrule\@height\fboxrule\bk@line}\hfil 68 | \advance\bk@lcnt\@ne 69 | \loop 70 | \bk@split\bk@addskipdp\leavevmode 71 | \ifvoid\bk@bxb % The last line 72 | \@bkcontfalse\bk@addfsepdp 73 | \vtop{\bk@line\hrule\@height\fboxrule}% 74 | \else % 2,...,(n-1) 75 | \bk@line 76 | \fi 77 | \hfil\advance\bk@lcnt\@ne 78 | \if@bkcont\repeat}% 79 | \fi 80 | \leavevmode\bk@fstln\par}\vskip\breakboxskip\relax} 81 | 82 | \bkcountfalse 83 | %%%% fin macro %%%% 84 | -------------------------------------------------------------------------------- /types/slides/src/array_memory.svg: -------------------------------------------------------------------------------- 1 | 2 |
p1
[Not supported by viewer]
p2
[Not supported by viewer]
-------------------------------------------------------------------------------- /pointers/slides/src/array_memory.svg: -------------------------------------------------------------------------------- 1 | 2 |
p1
[Not supported by viewer]
p2
[Not supported by viewer]
-------------------------------------------------------------------------------- /exercises/polynomial/polynomial.hpp: -------------------------------------------------------------------------------- 1 | #ifndef POLYNOMIAL_HPP 2 | #define POLYNOMIAL_HPP 3 | 4 | namespace dauphine 5 | { 6 | // The goal of ths exercise is to implement 7 | // a class modeling a N-degree polynomial with 8 | // traditional arithmetic operations. Process 9 | // step by step so you can incrementally test 10 | // your implementation. 11 | // 12 | // Pay attention to the const-correctness 13 | 14 | // Phase 1 15 | // Declare and define a class polynomial with the 16 | // following methods: 17 | // 18 | // - a constructor taking the degree of the polynomial 19 | // as its parameter 20 | // - a constructor taking an std::initializer_list 21 | // so one can initialize the polynomial in a single line. 22 | // The initializer list should start with the highest degree 23 | // coefficient and end with the lowest (reverse order) 24 | // - operator[] for reading and writing coefficients 25 | // of given degree. Coefficient are stored in ascending 26 | // degree; if p is a 4-degree polynomial, p[0] is the 27 | // coefficient of degree 0, p[1] the one of degree1 and 28 | // so on. 29 | // - degree(), a method that returns the degree of 30 | // the coefficient. 31 | // - eval(double x), a method that returns the evaluation 32 | // of the polynomial at the given point 33 | // 34 | // Also define an operator<< for printing the polynomial. Only 35 | // non null coefficients should be printed: 36 | // polynomial p(5); 37 | // p[0] = 1.; p[2] = 2.; p[3] = 3.; 38 | // std::cout << p << std::endl should print: 39 | // 3. X^4 + 2. X^2 + 1. 40 | 41 | // Phase 2 42 | // - Implement the unary minus operation 43 | // - Implement the addition and substraction operations for polynomials. 44 | // Don't forget the overloads involving a polynomial and a scalar. 45 | // - Implement comparison operator (operator== and operator!=) out of 46 | // the polynomial class. 47 | // TIP: you can either declare them as friend in the polynomial class 48 | // or make them rely on a public method of the polynomial called "equal" 49 | // that would perform the comparison. In that later case, operator== 50 | // and operator!= should be one-liners. 51 | 52 | // Phase 3 53 | // - Implement the multiplication of a polynomial by a scalar 54 | // - Implement the multiplication of 2 polynomials 55 | // Process in 3 steps 56 | // a] Start with a naive implementation (loops without any optimization) 57 | // b] Avoid useless operations (when a coefficient is 0) 58 | // c] Try to refine your implementation with the STL algorithms 59 | // Note: you can skip step c] in a first time and come back to it when 60 | // you've implemented all the features of the polynomial class. 61 | 62 | // Phase 4 63 | // - Implement the division of a polynomial by a scalar 64 | // - Implement the euclidian division of polynomials 65 | // operator/ returns the quotient 66 | // operator% returns the remainder 67 | } 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /exercises/chess/chess_array.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHESS_ARRAY_HPP 2 | #define CHESS_ARRAY_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace chess 8 | { 9 | template 10 | class chess_array : private std::array 11 | { 12 | public: 13 | 14 | using base_type = std::array; 15 | using value_type = typename base_type::value_type; 16 | using reference = typename base_type::reference; 17 | using const_reference = typename base_type::const_reference; 18 | using pointer = typename base_type::pointer; 19 | using const_pointer = typename base_type::const_pointer; 20 | using size_type = typename base_type::size_type; 21 | using difference_type = typename base_type::difference_type; 22 | using iterator = typename base_type::iterator; 23 | using const_iterator = typename base_type::const_iterator; 24 | using reverse_iterator = typename base_type::reverse_iterator; 25 | using const_reverse_iterator = typename base_type::const_reverse_iterator; 26 | 27 | chess_array(std::initializer_list init); 28 | 29 | reference operator[](char c); 30 | const_reference operator[](char c) const; 31 | 32 | reference at(char c); 33 | const_reference at(char c) const; 34 | 35 | using base_type::front; 36 | using base_type::back; 37 | 38 | using base_type::empty; 39 | using base_type::size; 40 | 41 | using base_type::begin; 42 | using base_type::end; 43 | using base_type::cbegin; 44 | using base_type::cend; 45 | 46 | using base_type::rbegin; 47 | using base_type::rend; 48 | 49 | using base_type::fill; 50 | using base_type::swap; 51 | 52 | private: 53 | 54 | size_type index(char c) const; 55 | }; 56 | 57 | template 58 | void swap(chess_array& ca1, chess_array& ca2); 59 | 60 | /****************************** 61 | * chess_array implementation * 62 | ******************************/ 63 | 64 | template 65 | inline chess_array::chess_array(std::initializer_list init) 66 | { 67 | std::copy(init.begin(), init.end(), base_type::begin()); 68 | } 69 | 70 | template 71 | inline auto chess_array::operator[](char c) -> reference 72 | { 73 | return base_type::operator[](index(c)); 74 | } 75 | 76 | template 77 | inline auto chess_array::operator[](char c) const -> const_reference 78 | { 79 | return base_type::operator[](index(c)); 80 | } 81 | 82 | template 83 | inline auto chess_array::at(char c) -> reference 84 | { 85 | return base_type::at(index(c)); 86 | } 87 | 88 | template 89 | inline auto chess_array::at(char c) const -> const_reference 90 | { 91 | return base_type::at(index(c)); 92 | } 93 | 94 | template 95 | inline auto chess_array::index(char c) const -> size_type 96 | { 97 | return static_cast(c - 'a'); 98 | } 99 | 100 | template 101 | void swap(chess_array& ca1, chess_array& ca2) 102 | { 103 | ca1.swap(ca2); 104 | } 105 | } 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /exercises/chess/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | // WINDOWS 10 | // mkdir build 11 | // cd build 12 | // cmake -G "NMake Makefiles" .. 13 | // nmake 14 | 15 | // LINUX // MACOS 16 | // mkdir build 17 | // cd build 18 | // cmake .. 19 | // make 20 | 21 | namespace chess 22 | { 23 | void print_chess() 24 | { 25 | std::cout << "+----+----+----+----+----+----+----+----+----+ " << std::endl; 26 | std::cout << "| 8 | Rb | Nb | Bb | Qb | Kb | Bb | Nb | Rb |" << std::endl; 27 | std::cout << "+----+----+----+----+----+----+----+----+----+ " << std::endl; 28 | std::cout << "| 7 | Pb | Pb | Pb | Pb | Pb | Pb | Pb | Pb | " << std::endl; 29 | std::cout << "+----+----+----+----+----+----+----+----+----+ " << std::endl; 30 | std::cout << "| 6 | | | | | | | | | " << std::endl; 31 | std::cout << "+----+----+----+----+----+----+----+----+----+ " << std::endl; 32 | std::cout << "| 5 | | | | | | | | | " << std::endl; 33 | std::cout << "+----+----+----+----+----+----+----+----+----+ " << std::endl; 34 | std::cout << "| 4 | | | | | | | | | " << std::endl; 35 | std::cout << "+----+----+----+----+----+----+----+----+----+ " << std::endl; 36 | std::cout << "| 3 | | | | | | | | | " << std::endl; 37 | std::cout << "+----+----+----+----+----+----+----+----+----+ " << std::endl; 38 | std::cout << "| 2 | Pw | Pw | Pw | Pw | Pw | Pw | Pw | Pw | " << std::endl; 39 | std::cout << "+----+----+----+----+----+----+----+----+----+ " << std::endl; 40 | std::cout << "| 1 | Rw | Nw | Bw | Qw | Kw | Bw | Nw | Rw | " << std::endl; 41 | std::cout << "+----+----+----+----+----+----+----+----+----+ " << std::endl; 42 | std::cout << "| | a | b | c | d | e | f | g | h | " << std::endl; 43 | std::cout << "+----+----+----+----+----+----+----+----+----+ " << std::endl; 44 | } 45 | 46 | using position_type = std::pair; 47 | using move_type = std::pair; 48 | 49 | void get_move(std::string input, move_type& pos) 50 | { 51 | std::array tmp; 52 | 53 | input.erase(std::remove(input.begin(), input.end(), ' '), input.end()); 54 | input[input.find('-')] = ','; 55 | std::size_t i = 0; 56 | std::string token; 57 | std::istringstream iss(input); 58 | while(std::getline(iss, token, ',')) 59 | { 60 | tmp[i++] = token; 61 | } 62 | if(i<4) 63 | { 64 | throw std::runtime_error("too few position arguments"); 65 | } 66 | 67 | pos.first.first = tmp[0][0]; 68 | pos.first.second = stoi(tmp[1]); 69 | pos.second.first = tmp[2][0]; 70 | pos.second.second = stoi(tmp[3]); 71 | } 72 | } 73 | 74 | int main(int /*argc*/, char** /*argv*/) 75 | { 76 | std::string input; 77 | std::cout << "Enter your move: ro,co - rd,cd" << std::endl; 78 | std::getline(std::cin, input); 79 | chess::move_type pos; 80 | try 81 | { 82 | chess::get_move(input, pos); 83 | } 84 | catch(std::exception& e) 85 | { 86 | std::cout << e.what() << std::endl; 87 | } 88 | return 0; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /basics/slides/src/git_decentralized.svg: -------------------------------------------------------------------------------- 1 | 2 |
Remote repo1
- master
- branch a
[Not supported by viewer]
Remote repo2
- master
Remote repo2<div>- master</div>
Local repo
- master
- branch a
[Not supported by viewer]
-------------------------------------------------------------------------------- /functional/slides/src/link.svg: -------------------------------------------------------------------------------- 1 | 2 |

discount_factor.o
[Not supported by viewer]

main.o
[Not supported by viewer]

discount_factor.exe
[Not supported by viewer]
-------------------------------------------------------------------------------- /functional/slides/src/git_decentralized.svg: -------------------------------------------------------------------------------- 1 | 2 |
Remote repo1
- master
- branch a
[Not supported by viewer]
Remote repo2
- master
Remote repo2<div>- master</div>
Local repo
- master
- branch a
[Not supported by viewer]
-------------------------------------------------------------------------------- /basics/basics.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# The Basics\n", 8 | "\n", 9 | "This notebook illustrates the basics of the language, and how to use the Jupyter notebook with C++" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "
\n", 21 | " \n", 26 | " \n", 27 | "
\n", 28 | " To run the selected code cell, hit
Shift + Enter
\n", 29 | "
\n", 30 | "
" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "metadata": {}, 36 | "source": [ 37 | "The `#include` directive brings definitions of functions and classes not defined by the language but in different libraries. Cells containing `#include` directives should not contain any definition or declaration." 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 1, 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "#include \n", 47 | "#include " 48 | ] 49 | }, 50 | { 51 | "cell_type": "markdown", 52 | "metadata": {}, 53 | "source": [ 54 | "`std::cout` is used to print text or the value of a variable. It is required to include `` before using it, so the previous cell must have been executed.\n" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": 2, 60 | "metadata": {}, 61 | "outputs": [ 62 | { 63 | "name": "stdout", 64 | "output_type": "stream", 65 | "text": [ 66 | "This is a text\n" 67 | ] 68 | } 69 | ], 70 | "source": [ 71 | "std::cout << \"This is a text\" << std::endl;" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 3, 77 | "metadata": {}, 78 | "outputs": [ 79 | { 80 | "name": "stdout", 81 | "output_type": "stream", 82 | "text": [ 83 | "2\n" 84 | ] 85 | } 86 | ], 87 | "source": [ 88 | "int a = 2;\n", 89 | "std::cout << a << std::endl;" 90 | ] 91 | }, 92 | { 93 | "cell_type": "markdown", 94 | "metadata": {}, 95 | "source": [ 96 | "Omitting the `;` in the last statement of a cell results in an output being printed. Notice that this is specific to the notebook, this is NOT valid C++." 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": 4, 102 | "metadata": {}, 103 | "outputs": [ 104 | { 105 | "data": { 106 | "text/plain": [ 107 | "2" 108 | ] 109 | }, 110 | "execution_count": 4, 111 | "metadata": {}, 112 | "output_type": "execute_result" 113 | } 114 | ], 115 | "source": [ 116 | "a" 117 | ] 118 | }, 119 | { 120 | "cell_type": "markdown", 121 | "metadata": {}, 122 | "source": [ 123 | "- To insert a cell above (resp. below) the current cell, quit the editing mode (by hiting the ESC key) and hit `a` (resp `b`).\n", 124 | "- To delete the current cell, quit the editing mode and hit `d` twice.\n", 125 | "- Executing the last cell of the notebook always creates a new cell after." 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": null, 131 | "metadata": {}, 132 | "outputs": [], 133 | "source": [] 134 | } 135 | ], 136 | "metadata": { 137 | "kernelspec": { 138 | "display_name": "C++14", 139 | "language": "C++14", 140 | "name": "xcpp14" 141 | }, 142 | "language_info": { 143 | "codemirror_mode": "text/x-c++src", 144 | "file_extension": ".cpp", 145 | "mimetype": "text/x-c++src", 146 | "name": "c++", 147 | "version": "14" 148 | } 149 | }, 150 | "nbformat": 4, 151 | "nbformat_minor": 4 152 | } 153 | -------------------------------------------------------------------------------- /exercises/interpolation/interpolation_impl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "interpolation_impl.hpp" 4 | 5 | namespace dauphine 6 | { 7 | void spline_derivative(const std::vector& x, 8 | const std::vector& y, 9 | std::vector& y2) 10 | { 11 | size_t size = x.size(); 12 | std::vector u(size); 13 | y2.resize(size); 14 | u.front() = 0.; 15 | y2.front() = 0.; 16 | for (size_t i = 1; i < size-2; ++i) 17 | { 18 | double sig = (x[i] - x[i+1]) / (x[i+1] - x[i-1]); 19 | double p = sig*y2[i-1] + 2.; 20 | y2[i] = (sig - 1.) / p; 21 | u[i] = (y[i+1] - y[i])/(x[i+1] - x[i]) - (y[i] - y[i-1])/(x[i] - x[i-1]); 22 | u[i] = (6.*u[i]/x[i+1] - x[i-1]) - sig*u[i-1]/p; 23 | } 24 | u.back() = 0.; 25 | y2.back() = 0.; 26 | for (size_t i = size - 2; i < size-2; --i) 27 | { 28 | y2[i] = y2[i]*y2[i+1] + u[i]; 29 | } 30 | } 31 | 32 | void spline_derivative(const std::vector& x, 33 | const std::vector& y, 34 | std::vector& y2); 35 | double spline_interpolate(double xlow, double xhigh, 36 | double ylow, double yhigh, 37 | double y2low, double y2high, 38 | double x) 39 | { 40 | double h = xhigh - xlow; 41 | double a = (xhigh - x)/h; 42 | double b = (x - xlow)/h; 43 | double res = a*ylow + b*yhigh + ((a*a*a - a)*y2low + (b*b*b - b)*y2high)*(h*h)/6.; 44 | return res; 45 | } 46 | 47 | interpolation_impl::interpolation_impl 48 | (const std::vector& x, 49 | const std::vector& y) 50 | : m_x(x) 51 | , m_y(y) 52 | { 53 | } 54 | 55 | double interpolation_impl::interpolate(double x) const 56 | { 57 | size_t upper_bound = find_upper_bound(x); 58 | if (upper_bound == m_x.size()) 59 | { 60 | return m_y.back(); 61 | } 62 | else 63 | { 64 | return interpolate_impl(x, upper_bound); 65 | } 66 | } 67 | 68 | const std::vector& 69 | interpolation_impl::get_x() const 70 | { 71 | return m_x; 72 | } 73 | 74 | const std::vector& 75 | interpolation_impl::get_y() const 76 | { 77 | return m_y; 78 | } 79 | 80 | size_t interpolation_impl::find_upper_bound(double x) const 81 | { 82 | if (x < m_x.front() || x > m_x.back()) 83 | { 84 | throw std::runtime_error("x out of bounds"); 85 | } 86 | auto iter = std::upper_bound(m_x.cbegin(), 87 | m_x.cend(), 88 | x); 89 | size_t index = static_cast( 90 | iter - m_x.cbegin()); 91 | return index; 92 | } 93 | 94 | linear_interpolation::linear_interpolation 95 | (const std::vector& x, 96 | const std::vector& y) 97 | : interpolation_impl(x, y) 98 | { 99 | } 100 | 101 | double linear_interpolation::interpolate_impl(double x, 102 | size_t upper_bound) const 103 | { 104 | return 0; 105 | } 106 | 107 | spline_interpolation::spline_interpolation 108 | (const std::vector& x, 109 | const std::vector& y) 110 | : interpolation_impl(x, y) 111 | , m_y2(x.size()) 112 | { 113 | spline_derivative(get_x(), get_y(), m_y2); 114 | } 115 | 116 | double spline_interpolate(double xlow, double xhigh, 117 | double ylow, double yhigh, 118 | double y2low, double y2high, 119 | double x); 120 | 121 | double spline_interpolation::interpolate_impl(double x, 122 | size_t upper_bound) const 123 | { 124 | double res = spline_interpolate(get_x()[upper_bound-1], 125 | get_x()[upper_bound], 126 | get_y()[upper_bound-1], 127 | get_y()[upper_bound], 128 | m_y2[upper_bound-1], 129 | m_y2[upper_bound], 130 | x); 131 | return res; 132 | } 133 | 134 | interpolation_impl* 135 | spline_interpolation::clone() const 136 | { 137 | return new spine_interpolation(*this); 138 | } 139 | 140 | interpolation_impl* 141 | linear_interpolation::clone() const 142 | { 143 | return new linear_interpolation(*this); 144 | } 145 | 146 | } 147 | 148 | -------------------------------------------------------------------------------- /basics/slides/src/github-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /functional/slides/src/github-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /polymorphism/slides/src/github-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /stl/slides/src/quantstack-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /basics/slides/src/quantstack-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /pointers/slides/src/quantstack-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /types/slides/src/quantstack-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /functional/slides/src/quantstack-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /polymorphism/slides/src/quantstack-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /exercises/polynomial/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "polynomial.hpp" 4 | 5 | /* 6 | * Compilation for windows users 7 | * mkdir build 8 | * cd build 9 | * cmake -G "NMake Makefiles" .. 10 | * nmake 11 | */ 12 | 13 | /* 14 | * Compilation for OSX / Linux users 15 | * mkdir build 16 | * cd build 17 | * cmake .. 18 | * make 19 | */ 20 | 21 | /* 22 | * See the instructions in polynomial.hpp 23 | * Uncomment the following test functions 24 | * once your implementation is done, to 25 | * check that it is valid 26 | */ 27 | 28 | namespace dauphine 29 | { 30 | std::string get_checked_value(bool c) 31 | { 32 | return c ? "Ok" : "Failed"; 33 | } 34 | 35 | /* 36 | void test_constructor() 37 | { 38 | std::cout << "POLYNOMIAL INTERFACE" << std::endl; 39 | polynomial p(3); 40 | p[0] = 2.; 41 | p[2] = 1.5; 42 | p[3] = 1.; 43 | std::cout << p << std::endl; 44 | // Should print "X^3 + 1.5 X^2 + 2. 45 | bool deg_cond = p.degree() == 3; 46 | std::cout << "polynomial::degree check : " << get_checked_value(deg_cond) << std::endl; 47 | double res = p.eval(2.); 48 | bool res_cond = (res == 16.); 49 | std::cout << "polynomial::eval check : " << get_checked_value(res_cond) << std::endl; 50 | polynomial p2 = { 1., 1.5, 0., 2. }; 51 | bool init_check = (p2[0] == p[0] && 52 | p2[1] == p[1] && 53 | p2[2] == p[2] && 54 | p2[3] == p[3]); 55 | std::cout << "Polynom initialization check: " << get_checked_value(init_check) << std::endl; 56 | std::cout << std::endl; 57 | } 58 | 59 | void test_comparison() 60 | { 61 | std::cout << "POLYNOMIAL COMPARISON" << std::endl; 62 | polynomial p1 = { 1., 2., 0., 4. }; 63 | polynomial p2 = { 1., 3., 0., 4. }; 64 | 65 | bool c1 = (p1 == p1); 66 | bool c2 = (p1 != p2); 67 | 68 | std::cout << "Polynomial operator==: " << get_checked_value(c1) << std::endl; 69 | std::cout << "Polynomial operator!=: " << get_checked_value(c2) << std::endl; 70 | std::cout << std::endl; 71 | } 72 | 73 | void test_addition() 74 | { 75 | std::cout << "POLYNOMIAL ADDITION" << std::endl; 76 | polynomial p1 = { 1., 2., 0., 4. }; 77 | polynomial p2 = { 2., 2., 1., 3. }; 78 | polynomial p3 = { 3., 4., 1., 7. }; 79 | polynomial p4 = { 4., 5., 3., 7. }; 80 | polynomial p5 = { 2., 1., 3., -1. }; 81 | 82 | bool tapp = (p3 == p1 + p2); 83 | bool taps = (p4 == p1 + 3.); 84 | bool tasp = (p4 == 3. + p1); 85 | 86 | bool tspp = (p1 == p3 - p2); 87 | bool tsps = (p1 == p4 - 3); 88 | bool tssp = (p5 == 3 - p1); 89 | 90 | std::cout << "Polynomial + Polynomial: " << get_checked_value(tapp) << std::endl; 91 | std::cout << "Polynomial + Scalar : " << get_checked_value(taps) << std::endl; 92 | std::cout << "Scalar + Polynomial : " << get_checked_value(tasp) << std::endl; 93 | std::cout << "Polynomial - Polynomial: " << get_checked_value(tspp) << std::endl; 94 | std::cout << "Polynomial - Scalar : " << get_checked_value(tsps) << std::endl; 95 | std::cout << "Scalar - Polynomial : " << get_checked_value(tssp) << std::endl; 96 | std::cout << std::endl; 97 | } 98 | 99 | void test_multiplication() 100 | { 101 | std::cout << "POLYNOMIAL MULTIPLICATION" << std::endl; 102 | polynomial p1 = { 2., 1. }; 103 | polynomial p2 = { 3., 4. }; 104 | polynomial mres = { 6. 11. 4. }; 105 | polynomial mresps = { 4., 2. }; 106 | bool mpp = (mres == p1 * p2); 107 | bool mps = (mresps == p1 * 2); 108 | bool msp = (mresps == 2 * p1); 109 | 110 | std::cout << "Polynomial * Polynomial: " << get_checked_value(mpp) << std::endl; 111 | std::cout << "Polynomial * Scalar : " << get_checked_value(mps) << std::endl; 112 | std::cout << "Scalar * Polynomial : " << get_checked_value(msp) << std::endl; 113 | std::cout << std::endl; 114 | } 115 | 116 | void test_division() 117 | { 118 | std::cout << "POLYNOMIAL DIVISION" << std::endl; 119 | polynomial p1 = { 1, -1, -1, 3., -2., 0. }; 120 | polynomial p2 = { 1., -1., 1. }; 121 | polynomial qres = { 1., 0., -2., 1. }; 122 | polynomial rres = { 1., -1. }; 123 | 124 | bool qcond = (qres == p1 / p2); 125 | bool rcond = (rres == p1 % p2); 126 | 127 | std::cout << "Polynomial / Polynomial: " << get_checked_value(qcond) << std::endl; 128 | std::cout << "Polynomial % Polynomial: " << get_checked_value(rcond) << std::endl; 129 | std::cout << std::endl; 130 | } 131 | */ 132 | } 133 | 134 | int main(int argc, char* argv[]) 135 | { 136 | //dauphine::test_constructor(); 137 | //dauphine::test_comparison(); 138 | //dauphine::test_addition(); 139 | //dauphine::test_multiplication(); 140 | //dauphine::test_division(); 141 | return 0; 142 | } 143 | 144 | -------------------------------------------------------------------------------- /projects/currency-ranking/currency-ranking.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper]{article} 2 | 3 | \usepackage[T1]{fontenc} 4 | \usepackage[latin1]{inputenc} 5 | \usepackage{amsmath,amsthm,amsfonts,amssymb,euscript,stmaryrd,graphicx,appendix,enumitem,yhmath,mathrsfs,superbox} 6 | \usepackage{fullpage} 7 | \usepackage{color,psfrag} 8 | 9 | \definecolor{ACORRIGER}{rgb}{0.9,0,0} 10 | 11 | \def\myqed {{% set up 12 | \parfillskip=0pt % so \par doesnt push \square to left 13 | \widowpenalty=10000 % so we dont break the page before \square 14 | \displaywidowpenalty=10000 % ditto 15 | %\finalhyphendem*erits=0 % TeXbook exercise 14.32 16 | % 17 | % horizontal 18 | \leavevmode % \nobreak means lines not pages 19 | \unskip % remove previous space or glue 20 | \nobreak % don't break lines 21 | \hfil % ragged right if we spill over 22 | \penalty50 % discouragement to do so 23 | \hskip.2em % ensure some space 24 | \null % anchor following \hfill 25 | \hfill % push \square to right 26 | $\square$% % the end-of-proof mark 27 | % 28 | % vertical 29 | \par}} % build paragraph 30 | 31 | \newcommand{\footnoteremember}[2]{ 32 | \footnote{#2} 33 | \newcounter{#1} 34 | \setcounter{#1}{\value{footnote}} 35 | } 36 | \newcommand{\footnoterecall}[1]{ 37 | \footnotemark[\value{#1}] 38 | } 39 | \def\andcr{% 40 | \end{tabular}% 41 | \\ 42 | \begin{tabular}[t]{c}} 43 | 44 | \author 45 | { 46 | } 47 | 48 | \title{Global Ranking of World Currencies} 49 | \date{} 50 | 51 | 52 | \newtheorem{theo}{Theorem}[section] 53 | \newtheorem{theodef}{Theorem-Definition}[section] 54 | \newtheorem{prop}[theo]{Proposition} 55 | \newtheorem{coro}[theo]{Corollary} 56 | \newtheorem{remark}{Remark} 57 | \newtheorem{lemm}[theo]{Lemma} 58 | \newtheorem{defi}{Definition} 59 | \newtheorem*{propx}{Proposition} 60 | 61 | 62 | \newcommand{\1}{\textbf{1}} 63 | \newcommand{\N}{\mathbb{N}} 64 | \newcommand{\Z}{\mathbb{Z}} 65 | \newcommand{\Q}{\mathbb{Q}} 66 | \newcommand{\R}{\mathbb{R}} 67 | \newcommand{\K}{\mathbb{K}} 68 | 69 | \newcommand{\C}{\mathbb{C}} 70 | \newcommand{\E}{\mathbb{E}} 71 | \newcommand{\vega}{\upsilon} 72 | \newcommand{\Vega}{\mathcal{V}} 73 | 74 | \newcommand{\PP}{\mathbb{P}} 75 | \newcommand{\cF}{\mathcal{F}} 76 | \newcommand{\diag}{\operatorname{diag}} 77 | \newcommand{\supp}{\operatorname{supp}} 78 | \newcommand{\card}{\operatorname{card}} 79 | \newcommand{\vect}{\operatorname{vect}} 80 | \newcommand{\sspan}{\operatorname{span}} 81 | \newcommand{\cov}{\operatorname{cov}} 82 | \newcommand{\var}{\operatorname{Var}} 83 | \newcommand{\Proj}{\operatorname{Proj}} 84 | \newcommand{\cell}{\operatorname{cell}} 85 | \newcommand{\LL}{\operatorname{L}} 86 | \newcommand{\Prime}{\operatorname{Prime}} 87 | \newcommand{\Call}{\operatorname{Call}} 88 | \newcommand{\Put}{\operatorname{Put}} 89 | \newcommand{\slab}{\operatorname{slab}} 90 | \newcommand{\tanapprox}{\operatorname{tanapprox}} 91 | \newcommand{\ui}{{\underline{i}}} 92 | \newcommand{\uj}{{\underline{j}}} 93 | 94 | \def\independent{{\perp\!\!\!\!\perp}} 95 | \def\simdist{\stackrel{\mathcal{L}}{\sim}} 96 | \def\h1{\hspace{0.1cm}} 97 | 98 | % keywords 99 | \def\keywordname{{\bf Keywords:}} 100 | 101 | \newcommand{\keywords}[1]{\par\addvspace\baselineskip\noindent\keywordname\enspace\ignorespaces#1} 102 | 103 | \bibliographystyle{plain} 104 | 105 | \graphicspath{{./}{figures/}} 106 | 107 | \begin{document} 108 | \maketitle 109 | \vspace{-1cm} 110 | 111 | \begin{center}{\Large \emph{A simple method for ranking currencies based on their relative stability} }\end{center} 112 | 113 | \section{Introduction} 114 | 115 | \par Using the nominal value of a currency with respect to some reference numeraire is not an appropriate means of ranking them with respect to how "strong" one should consider that currency. For example, the value of the Japanese Yen is lesser than the Brazialian real, while Yen is considered a much stronger currency. 116 | 117 | \par A better way to compare a currency to another is to analyse the volatility skew of the pair. For example, a negative skew generally indicates a fatter tail for negative returns than positive returns. Hence, if A-B currency pair has a negative skew, we may consider A to be "lesser" than B. 118 | 119 | \section{Creating a currency strength score} 120 | 121 | \par Considering the anti-symmetric matrix $M$ of the at-the-money skews of all currency pairs, we seek to approximate it with the outer-difference of a \emph{score} vector $S$, $O_{i, j} = S_i - S_j$. When using the least-square criterion, $\min_{S} \|M - O\|_2^2$, the problem can be formulated as a linear regression. 122 | 123 | \par The convention for quoting option prices on currency pairs is specific to foreign exchange market. We recommend you to read up about the FX option quoting convention (Butterfly and Risk Reversal). The 25 Delta risk-reversal can be considered a good proxy for the skew of the considered currency pair. 124 | 125 | \section{C++ Computing Project} 126 | 127 | \par First, using the C++ programming language (and testing with generated data), produce a routine performing the approximation of an anti-symmetrical matrix with the outer-difference of a score vector. 128 | 129 | \par Then, using a real-world snapshot of the 25-Delta risk-reversal values, compute a "score" for a list of at least 15 currencies of the world following the criterion described in the previous section, including precious metals. 130 | 131 | \par Provide a careful interpretation of the resulting scores. 132 | 133 | \bibliography{biblio} 134 | \end{document} 135 | -------------------------------------------------------------------------------- /basics/slides/src/git_basic.svg: -------------------------------------------------------------------------------- 1 | 2 |
fa2f8
fa2f8
ea8r5
ea8r5
bc16d
bc16d
a789f
a789f
ae45f
ae45f
-------------------------------------------------------------------------------- /functional/slides/src/git_basic.svg: -------------------------------------------------------------------------------- 1 | 2 |
fa2f8
fa2f8
ea8r5
ea8r5
bc16d
bc16d
a789f
a789f
ae45f
ae45f
-------------------------------------------------------------------------------- /basics/slides/src/compiler.svg: -------------------------------------------------------------------------------- 1 | 2 |

<div><br></div>
header1.hpp
[Not supported by viewer]
source.cpp
[Not supported by viewer]
object.obj
object.obj
COMPILER
COMPILER
-------------------------------------------------------------------------------- /projects/super-replication/bundle.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper]{article} 2 | 3 | \usepackage[T1]{fontenc} 4 | \usepackage[latin1]{inputenc} 5 | \usepackage{amsmath,amsthm,amsfonts,amssymb,euscript,stmaryrd,graphicx,appendix,enumitem,yhmath,mathrsfs,superbox} 6 | \usepackage{fullpage} 7 | \usepackage{color,psfrag} 8 | 9 | \definecolor{ACORRIGER}{rgb}{0.9,0,0} 10 | 11 | \def\myqed {{% set up 12 | \parfillskip=0pt % so \par doesnt push \square to left 13 | \widowpenalty=10000 % so we dont break the page before \square 14 | \displaywidowpenalty=10000 % ditto 15 | %\finalhyphendem*erits=0 % TeXbook exercise 14.32 16 | % 17 | % horizontal 18 | \leavevmode % \nobreak means lines not pages 19 | \unskip % remove previous space or glue 20 | \nobreak % don't break lines 21 | \hfil % ragged right if we spill over 22 | \penalty50 % discouragement to do so 23 | \hskip.2em % ensure some space 24 | \null % anchor following \hfill 25 | \hfill % push \square to right 26 | $\square$% % the end-of-proof mark 27 | % 28 | % vertical 29 | \par}} % build paragraph 30 | 31 | \newcommand{\footnoteremember}[2]{ 32 | \footnote{#2} 33 | \newcounter{#1} 34 | \setcounter{#1}{\value{footnote}} 35 | } 36 | \newcommand{\footnoterecall}[1]{ 37 | \footnotemark[\value{#1}] 38 | } 39 | \def\andcr{% 40 | \end{tabular}% 41 | \\ 42 | \begin{tabular}[t]{c}} 43 | 44 | \author 45 | { 46 | } 47 | 48 | \title{Cheapest Super-Replication of Vanilla Options} 49 | \date{} 50 | 51 | 52 | \newtheorem{theo}{Theorem}[section] 53 | \newtheorem{theodef}{Theorem-Definition}[section] 54 | \newtheorem{prop}[theo]{Proposition} 55 | \newtheorem{coro}[theo]{Corollary} 56 | \newtheorem{remark}{Remark} 57 | \newtheorem{lemm}[theo]{Lemma} 58 | \newtheorem{defi}{Definition} 59 | \newtheorem*{propx}{Proposition} 60 | 61 | 62 | \newcommand{\1}{\textbf{1}} 63 | \newcommand{\N}{\mathbb{N}} 64 | \newcommand{\Z}{\mathbb{Z}} 65 | \newcommand{\Q}{\mathbb{Q}} 66 | \newcommand{\R}{\mathbb{R}} 67 | \newcommand{\K}{\mathbb{K}} 68 | 69 | \newcommand{\C}{\mathbb{C}} 70 | \newcommand{\E}{\mathbb{E}} 71 | \newcommand{\vega}{\upsilon} 72 | \newcommand{\Vega}{\mathcal{V}} 73 | 74 | \newcommand{\PP}{\mathbb{P}} 75 | \newcommand{\cF}{\mathcal{F}} 76 | \newcommand{\diag}{\operatorname{diag}} 77 | \newcommand{\supp}{\operatorname{supp}} 78 | \newcommand{\card}{\operatorname{card}} 79 | \newcommand{\vect}{\operatorname{vect}} 80 | \newcommand{\sspan}{\operatorname{span}} 81 | \newcommand{\cov}{\operatorname{cov}} 82 | \newcommand{\var}{\operatorname{Var}} 83 | \newcommand{\Proj}{\operatorname{Proj}} 84 | \newcommand{\cell}{\operatorname{cell}} 85 | \newcommand{\LL}{\operatorname{L}} 86 | \newcommand{\Prime}{\operatorname{Prime}} 87 | \newcommand{\Call}{\operatorname{Call}} 88 | \newcommand{\Put}{\operatorname{Put}} 89 | \newcommand{\slab}{\operatorname{slab}} 90 | \newcommand{\tanapprox}{\operatorname{tanapprox}} 91 | \newcommand{\ui}{{\underline{i}}} 92 | \newcommand{\uj}{{\underline{j}}} 93 | 94 | \def\independent{{\perp\!\!\!\!\perp}} 95 | \def\simdist{\stackrel{\mathcal{L}}{\sim}} 96 | \def\h1{\hspace{0.1cm}} 97 | 98 | % keywords 99 | \def\keywordname{{\bf Keywords:}} 100 | 101 | \newcommand{\keywords}[1]{\par\addvspace\baselineskip\noindent\keywordname\enspace\ignorespaces#1} 102 | 103 | \bibliographystyle{plain} 104 | 105 | \graphicspath{{./}{figures/}} 106 | 107 | \begin{document} 108 | \maketitle 109 | \vspace{-1cm} 110 | 111 | \begin{center}{\Large \emph{A Linear-Proramming Approach to Super Replication and Arbitrage Detection} }\end{center} 112 | 113 | \par \emph{This project is slightly more ambitious than the two other proposals, and aimed at students already familiar with the C++ programming language. The added difficulty is that it requires students to make use of a third-party library.} 114 | 115 | \section{Introduction} 116 | 117 | \par Just like their underlyings, listed options are traded on exchanges with an order book mechanism, so that, in order to guarantee a transation, buyers must cross the bid-ask spreads of the considered instruments. 118 | 119 | \par In this project, we consider the case of a trader interested in buying a European option with a given maturity $T$ with a piecewise linear payiff. 120 | 121 | \par A piecewise-linear payoff may be written as a linear combination of Call and Put payoffs. A buyer willing to purchase the corresponding linear combination must trade Calls and Puts at the Ask price when the corresponding weight it positive, and the Bid price when the corresponding weight is negative. This can be prohibitive, especially when certain strikes are illiquid which results in large bid-ask spreads. 122 | 123 | \par The goal of this project is to produce a routine that outputs the weights for a linear combination of calls and puts that super-replicates the target payoff while minimizing the cost. 124 | 125 | \section{C++ Computing Project} 126 | 127 | \par Produce a C++ routine outputing weights for the super replication of a piecewise linear function of compact suport with Call options. 128 | 129 | \par \emph{This stepp should require no optimization whatsoever}. 130 | 131 | \par Formulate the problem of the \emph{minimal super replication} of a piecewiese linear profile with combination of calls and puts as a linear programming problem. 132 | 133 | \par Using a third-party linear programming solver, or with your own implementation of the simplex method, provide a routine computing the cheapest super-replication price for any given piecewise linear profile. 134 | 135 | \par What would it mean if the cheapest replication of the null payoff had a negative price? 136 | 137 | \bibliography{biblio} 138 | \end{document} 139 | -------------------------------------------------------------------------------- /basics/slides/src/linker.svg: -------------------------------------------------------------------------------- 1 | 2 |

<div><br></div>
object2.obj
[Not supported by viewer]
object1.obj
[Not supported by viewer]
prog.exe
prog.exe
LINKER

[Not supported by viewer]
-------------------------------------------------------------------------------- /basics/slides/src/git_rebase2.svg: -------------------------------------------------------------------------------- 1 | 2 |
1afdc
1afdc
f2ae5
f2ae5
45ad6
45ad6
d45fb
d45fb
24a62
24a62
master
master
-------------------------------------------------------------------------------- /functional/slides/src/git_rebase2.svg: -------------------------------------------------------------------------------- 1 | 2 |
1afdc
1afdc
f2ae5
f2ae5
45ad6
45ad6
d45fb
d45fb
24a62
24a62
master
master
-------------------------------------------------------------------------------- /projects/breakeven-volatility/breakeven-volatility.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper]{article} 2 | 3 | \usepackage[T1]{fontenc} 4 | \usepackage[latin1]{inputenc} 5 | \usepackage{amsmath,amsthm,amsfonts,amssymb,euscript,stmaryrd,graphicx,appendix,enumitem,yhmath,mathrsfs,superbox} 6 | \usepackage{fullpage} 7 | \usepackage{color,psfrag} 8 | 9 | \definecolor{ACORRIGER}{rgb}{0.9,0,0} 10 | 11 | \def\myqed {{% set up 12 | \parfillskip=0pt % so \par doesnt push \square to left 13 | \widowpenalty=10000 % so we dont break the page before \square 14 | \displaywidowpenalty=10000 % ditto 15 | %\finalhyphendem*erits=0 % TeXbook exercise 14.32 16 | % 17 | % horizontal 18 | \leavevmode % \nobreak means lines not pages 19 | \unskip % remove previous space or glue 20 | \nobreak % don't break lines 21 | \hfil % ragged right if we spill over 22 | \penalty50 % discouragement to do so 23 | \hskip.2em % ensure some space 24 | \null % anchor following \hfill 25 | \hfill % push \square to right 26 | $\square$% % the end-of-proof mark 27 | % 28 | % vertical 29 | \par}} % build paragraph 30 | 31 | \newcommand{\footnoteremember}[2]{ 32 | \footnote{#2} 33 | \newcounter{#1} 34 | \setcounter{#1}{\value{footnote}} 35 | } 36 | \newcommand{\footnoterecall}[1]{ 37 | \footnotemark[\value{#1}] 38 | } 39 | \def\andcr{% 40 | \end{tabular}% 41 | \\ 42 | \begin{tabular}[t]{c}} 43 | 44 | \author 45 | { 46 | } 47 | 48 | \title{Break-Even Volatility} 49 | \date{} 50 | 51 | 52 | \newtheorem{theo}{Theorem}[section] 53 | \newtheorem{theodef}{Theorem-Definition}[section] 54 | \newtheorem{prop}[theo]{Proposition} 55 | \newtheorem{coro}[theo]{Corollary} 56 | \newtheorem{remark}{Remark} 57 | \newtheorem{lemm}[theo]{Lemma} 58 | \newtheorem{defi}{Definition} 59 | \newtheorem*{propx}{Proposition} 60 | 61 | 62 | \newcommand{\1}{\textbf{1}} 63 | \newcommand{\N}{\mathbb{N}} 64 | \newcommand{\Z}{\mathbb{Z}} 65 | \newcommand{\Q}{\mathbb{Q}} 66 | \newcommand{\R}{\mathbb{R}} 67 | \newcommand{\K}{\mathbb{K}} 68 | 69 | \newcommand{\C}{\mathbb{C}} 70 | \newcommand{\E}{\mathbb{E}} 71 | \newcommand{\vega}{\upsilon} 72 | \newcommand{\Vega}{\mathcal{V}} 73 | 74 | \newcommand{\PP}{\mathbb{P}} 75 | \newcommand{\cF}{\mathcal{F}} 76 | \newcommand{\diag}{\operatorname{diag}} 77 | \newcommand{\supp}{\operatorname{supp}} 78 | \newcommand{\card}{\operatorname{card}} 79 | \newcommand{\vect}{\operatorname{vect}} 80 | \newcommand{\sspan}{\operatorname{span}} 81 | \newcommand{\cov}{\operatorname{cov}} 82 | \newcommand{\var}{\operatorname{Var}} 83 | \newcommand{\Proj}{\operatorname{Proj}} 84 | \newcommand{\cell}{\operatorname{cell}} 85 | \newcommand{\LL}{\operatorname{L}} 86 | \newcommand{\Prime}{\operatorname{Prime}} 87 | \newcommand{\Call}{\operatorname{Call}} 88 | \newcommand{\Put}{\operatorname{Put}} 89 | \newcommand{\slab}{\operatorname{slab}} 90 | \newcommand{\tanapprox}{\operatorname{tanapprox}} 91 | \newcommand{\ui}{{\underline{i}}} 92 | \newcommand{\uj}{{\underline{j}}} 93 | 94 | \def\independent{{\perp\!\!\!\!\perp}} 95 | \def\simdist{\stackrel{\mathcal{L}}{\sim}} 96 | \def\h1{\hspace{0.1cm}} 97 | 98 | % keywords 99 | \def\keywordname{{\bf Keywords:}} 100 | 101 | \newcommand{\keywords}[1]{\par\addvspace\baselineskip\noindent\keywordname\enspace\ignorespaces#1} 102 | 103 | \bibliographystyle{plain} 104 | 105 | \graphicspath{{./}{figures/}} 106 | 107 | \begin{document} 108 | \maketitle 109 | \vspace{-1cm} 110 | 111 | \begin{center}{\Large \emph{Estimating a fair volatility skew from historical prices} }\end{center} 112 | 113 | \section{Introduction} 114 | 115 | \par Commonly available historical prices are OHLC (Open, High, Low, Close) prices. There are many volatility estimates using the OHLC data meant to improve the efficiency of the standard close-to-close estimator of the volatility $\sum (C_i - C_{i-1})^2$. 116 | 117 | \par Different volatility estimates may be used for different purposes. One issue with the classical estimators is that they are generally not linked to how good the resulting hedge may be. 118 | 119 | \par Estimating volatility from price history can be necessary in the context of option pricing and hedging. For example: 120 | 121 | \begin{itemize} 122 | \item pricing or hedging options on an underlying with illiquid or no option market. 123 | 124 | \item finding whether the market skew is \emph{fair}, or perform a skew arbitrage on the marker. 125 | \end{itemize} 126 | 127 | \section{Fair estimator for the historical volatility} 128 | 129 | Let us consider the following scenario. 130 | 131 | \begin{itemize} 132 | \item We sell a vanilla option of strike $K$ and maturity $T$ for a price corresponding to some (arbitrary) value of the Black-Scholes volatility $\sigma$. 133 | \item We perform a daily delta-hedge assuming the Black-Scholes model with the same volatility $\sigma$. 134 | \item This delta-hedge results in a final P\& L that depend on the input value for $\sigma$, $P \text{\&} L_{T, K}(\sigma)$. 135 | \end{itemize} 136 | 137 | \par Using a zero-finding method to find the value $\sigma_{T, K}$ that cancels $P\text{\&}L_{T, K}(\sigma)$ results in an estimation for a "fair" or "break-even" volatility, that is, the value for the Black-Schole volatility that would have resulted in a perfect hedge. 138 | 139 | \par Repeating the processe for a range of values for $T$ and $K$ can be used to produce a complete volatility surface. 140 | 141 | \begin{breakbox} 142 | This method can produce a complete volatility surfaces for an underlying simply using its price history. 143 | \end{breakbox} 144 | 145 | \section{C++ Computing Project} 146 | 147 | \par Using the C++ programming language, compute a "break-even" volatility smile for one-year maturity options on the SPX500 index using the past year closing prices for the index. 148 | 149 | \par Compare the resulting values with the current one-year volatility skew of SPX500. If our estimation is correct, how can we take advantage of it to arbitrage the implied SPX500 volatility smile? 150 | 151 | \par Bonus question: using the so-called "Black-Scholes Robustness formula", the P\& L from the continuous hedge of an option can be written as the time average of the instantaneous volatility weighted with the square gamma of the considered option. Use this formula to produce another estimator for the break-even volatility. 152 | 153 | \bibliography{biblio} 154 | \end{document} --------------------------------------------------------------------------------