QTPZ6AL5CZES5XTQHDFXSHWHU5SXXGI7EBLZMXJK7I7TGSISI4YAC
Z6B2FRJWT6EF4MC4GTIDBMULUKEI62ZGPYZMCWRJDJNUM7YUJJMAC
7F3ARXB7ZM4WPC3FOH5RHXFHWB3MGZ6XJYJX5IH6RFQNUKOWHAOQC
RHWQQAAHNHFO3FLCGVB3SIDKNOUFJGZTDNN57IQVBMXXCWX74MKAC
WU76EHIWT7E3CEKGV6LQJUSOC63JYDPPDRV3KKOEGLP2FB5UEUEQC
36DOXPCS6H5JNDEGCINCKM34KVMO3GO3PQ7ZLQTJUG2KVIEGY63QC
JMVLHRX7RFJCQFXESQT75DUKOLBQEO7LMKOZCI4QWQBQKAWLC2PAC
7NDZXAGUWT2JOXEDHCP7OGVNLC7XUNJ2MNEBKDJKSJ2ZFL5HF4YAC
TMJZX3VJEDP3Q3PA5ZIAZC44IBW7V2O43ONUNJEU5P3WVHITH42AC
NBJFXQNG6YLIEL6HK7VZDEQZTXK2QJZ43AKNLXIIBX5K3MOX6WCQC
* Backups :backup:
** TODO Nettoyer public
SCHEDULED: <2023-09-30 Sat>
/Entered on/ [2023-09-30 Sat 16:21]
** TODO Configure sauvegarde avec git-annex
SCHEDULED: <2023-09-30 Sat>
*** TODO public: mega (non encrypté)
SCHEDULED: <2023-09-30 Sat>
*** TODO public: git lfs (non encrypté)
SCHEDULED: <2023-09-30 Sat>
*** TODO public: proton drive (non encrypté)
SCHEDULED: <2023-09-30 Sat>
*** TODO private : mega (encrypté)
SCHEDULED: <2023-09-30 Sat>
*** TODO private : git lfs (encrypté)
SCHEDULED: <2023-09-30 Sat>
*** TODO private : proton drive (encrypté)
SCHEDULED: <2023-09-30 Sat>
\documentclass{article}
\usepackage{listings}
\usepackage{color}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\newenvironment{myitemize}{
\begin{itemize}
\setlength{\itemsep}{1pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}{\end{itemize}}
% For code style
\definecolor{blueviolet}{RGB}{138, 43, 226}
\def\cmd#1{\texttt{\textcolor{blueviolet}{#1}}}
\lstnewenvironment{git}{
\lstset{
language=bash,
breaklines=true,
breakindent=0pt
}\tt \color{blueviolet}}{}
\begin{document}
% For diagram
\tikzstyle{commit}=[rectangle, draw=black, rounded corners, fill=green!40, drop
shadow, text centered, anchor=north]
\tikzstyle{branch}=[rectangle, draw=black, fill=red!30, drop
shadow, text centered, anchor=north, node distance = 7mm]
\tikzstyle{arrow}=[->, thick]
\title{Git}
\maketitle
\section{Note}
\subsection{Outline}
\begin{itemize}
\item Do you want to use Git ? Why ?
\item Git in 5 minutes (demo)
\item Advanceds git
\item Install Git : CERFACS or at home
\end{itemize}
\subsection{Slide structure (Basics)}
Commands \\
Tips section
\subsection{Why Git ?}
Centralized Version System depends on the server (not always reliable).
In Distributed VCS, a complete copy of the server is done locally.
Context : created by Linus Torvald for Linux kernel dev, after BitKeeper access
was revoked.
Qualities : fast, efficient, allows non-linear dev through branching
\subsection{Features}
\begin{myitemize}
\item Git stores snapshots instead of file differences. If
there was no changes, it stores a link to the previous version.
\item Most of the operations are local (no need for network + fast).
\item Data integrity : everything is checksum (SHA-1 hash). The hash is used for
storing (ex: git log)
\item Adds data : difficult to lose something
\item 3 states :
\begin{itemize}
\item modified : changed, but not in database
\item staged : changed, and ready to go in the next commit
\item commited : in database
\end{itemize}
The folder are (resp.) :
\begin{itemize}
\item working directory (checkout of the project)
\item staging area : a file with the info about the next commit
\item git directory
\end{itemize}
\end{myitemize}
\section{Basic Git}
\subsection{Configuration :}
Here we configure the name, email, editor and the diff tool :\\
\cmd{git config --global user.name ``John Doe''}\\
\cmd{git config --global user.email johndoe@example.com}\\
\cmd{git config --global core.editor emacs}\\
\cmd{git config --global merge.tool vimdiff}\\
This can be checked with \cmd{ git config --list}
or in \cmd{ .git/config}.
\subsection{Basics}
\cmd{ git init} : init the git repo\\
\cmd{ git add README} : add the file \\
\cmd{ git commit -m 'initial project version'} : commit with a message\\
\cmd{ git clone git://github.com/schacon/grit.git myfolder} : clone the git repo
into a local folder
\subsection{Recording changes}
\cmd{ git status}\\
\cmd{ git add }: untracked to unmodified/modified\\
\cmd{ git stage }: modified to staged\\
\cmd{ git commit }: staged to unmodified\\
\cmd{.gitignore :\\
\# a comment - this is ignored\\
*.a \\
!lib.a \\
/TODO \\
build/ \\
doc/*.txt }
git diff : view exact changes
%
%Committing : git commit or git commit -m ``message''
%We can skip the staging : git commit -am ``message''
%Removing : just ``rm'' says ``\# Changed but not updated:'' so git rm
%Moving : git mv
%
\subsection{History}
\cmd{ git log} : commit message, author, date\\
\cmd{ git log -p} : show the diff \\
\cmd{ git log --stat} : number of modifications\\
\cmd{ git log --graph} : show branches\\
Graphical : \cmd{ gitk}
\subsection{Undoing}
\cmd{ git commit --amend} : add some file to a commit (staging area). Merge in
single commit\\
\cmd{ git reset HEAD myfile} : unstage\\
\cmd{ git checkout} : undo changes
WARNING : hard to lose something, but it must me commited.
\subsection{Remotes}
\cmd{ git remote -v} : show remote \\
Warning : can only pull from SSH url\\
\cmd{ git remote add [shortname] [url]} : add a remote \\
\cmd{ git fetch [shortname]} : fetch data without merging. Put it in local
branches. (TODO: check that) \\
\cmd{ git pull [shortname]} = git fetch \&\& git merge\\
\cmd{ git push remote branch} : push to the remote. Example : git push origin
master\\
\cmd{ git remote show} : show some informations about the remote
\cmd{ git remote rm }\cmd{ git remote rename }\\
{\it Tip : if you don't have the permissions to update branch, it's easiest to push
your local branch directly to the remote, instead of merging to the master.}
\subsection{Tags}
\cmd{ git tag -a v7.2 -m "This is the version 7.2"}: tag with a number and
message \\
\cmd{ git tag} : show tags\\
\cmd{ git show v7.2} : show info at version\\
\cmd{ git tag -s v7.2 -m "This is the version 7.2"}: tag with a GPG signature\\
\cmd{ git tag v7.2}: create lightweight tag (only checksum)\\
\cmd{ git tag -v v7.2}: verify tag\\
\cmd{ git tag -a v7.2 7epb61}: tag at the commit whose checksum is 7epb61 \\
Warning : you have to push you tags ! \cmd{ git push origin v7.2} or
\cmd{ git push origin --tags} for all
\subsection{Tips}
There is a bash script for completion in the source code of git.
\cmd{ source ~/.git-completion.bash}
Aliases can be created : \cmd{ git config --global alias.co checkout}
\section{Advanced}
\subsection{Branches}
Why is it important ? Lightweight and fast.
\subsubsection{Basics}
Commit object = pointer to the snapshot, author, messages and pointer to the
previous commits (2 if merge).
A snapshot contains a blob (=version) for each file.
A branch is just a pointer to a commit. HEAD is a pointer to the current branch.
\begin{figure}[h]
\begin{tikzpicture}[transform shape,font=\scriptsize,scale=1.9]
\node (C1)[commit] {C1};
\node (C2)[commit,right of=C1] {C2};
\node (C3)[commit,below of=C2] {C3};
\node (master)[branch,above of=C2] {master};
\node (donkey)[branch,below of=C3] {donkey};
\node (head)[branch,above of=master] {HEAD};
\draw[arrow] (C2) to (C1);
\draw[arrow] (C3) to (C1);
\draw[arrow] (master) to (C2);
\draw[arrow] (donkey) to (C3);
\draw[arrow] (head) to (master);
\end{tikzpicture}
\end{figure}
Easy, right ?
\cmd{ git branch monkey} : creates a branch \\
\cmd{ git checkout monkey} : switch to the branch \\
\cmd{ git checkout -b monkey} : both of the above\\
\paragraph{Merging}
\cmd{ git checkout master}\cmd{ git checkout monkey} : merge to master\\
\cmd{ git branch -d monkey} : delete the branch. Don't worry, removes only a
pointer !\\
\paragraph{Conflicts} ~\\
\begin{git}
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
\end{git}
Don't panic !
\begin{git}
<<<<<<< HEAD:index.html
<div id="footer">contact : email.support@github.com</div>
=======
<div id="footer">
please contact us at support@github.com
</div>
>>>>>>> iss53:index.html
\end{git}
Simply remove the lines. Git cannot do that for you.
\cmd{ git mergetool} for a visual merging tool.
Check everything has been merged : \cmd{ git status}, and \cmd{ git commit}
(default message).
{\it Tip : with git merge, it will automatically commit. Use the --no-commit
option if you don't want to}
\paragraph{Management}
\cmd{ git branch} : list branch, with * on the current \\
\cmd{ git branch -v} : list branch with last commit \\
\cmd{ git branch --merged} : list branch with last commit \\
\subsection{Workflow}
Long-term branches : differents branch for stability. Ex (Debian) : \cmd{stable},\cmd{testing},\cmd{unstable}
Short-term branches : for testing ideas. This is only local.
\subsection{Remote branches}
Warning : source of confusion.\\
\paragraph{What happens when I clone ?} Git create an origin remote and pull the master. So
we have origin/master copied locally. However, we will work on the master branch
locally (the other will not be modified until the next push).\\
Explains the difference between fetch and pull : it creates a divergence.\\
What happens if someone commit between my git pull and my git push ?\\
You should always pull (git should say so) before pushing.\\
AND you should always check the log before that.
\paragraph{Tracking branch}
Cloning creates a master branch which will track origin/master so git push will
work without arguments.\\
\cmd{git checkout --track origin/monkey} : will track monkey\\
\cmd{git checkout -b donkey origin/monkey} : idem but with another name.\\
\cmd{git push origin :monkey} : delete remote branch (! difficult to memorise)
\subsection{Rebase}
git merge performs a merge between the 2 latest snapshots.
\cmd{git checkout donkey} and \cmd{git rebase master} will take all the changes
from donkey and apply it to master (starts from common ancestor and apply
successively)\\
\cmd{git rebase master donkey} has the same result
What for ? Cleaner history (looks like we have done everything sequentially).
Result is the same.
QUIZZ : what does the following command does ?\\
\cmd{git rebase --onto master waiting testing} : will apply changes of testing
on master, but only from the ancestor of waiting and testing
NEVER use rebase on commits already pushed ? \\
QUIZZ : why ?\\
\section{Working with others}
\subsection{Commit guidelines}
\begin{enumerate}
\item Check for whitespaces errors : \cmd{git diff --check}
\item Each commit should be about a specific change. Don't forget you can
split your work into several commits ! More readable and easier for
reverting.
\item Format your commit message. Ideally, a short description on the first
line, followed by a body.
\end{enumerate}
\begin{git}
commit a3347b988a338e95b7f3b11eda776ac0d7b84dd0
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri May 25 09:02:03 2012 -0700
fmt-merge-message: add empty line between tag and signature verification
When adding the information from a tag, put an empty line between the message of the tag and the commented -out signature verification information.
At least for the kernel workflow, I often end up re-formatting the message that people send me in the tag data. In that situation, putting the tag message and the tag signature verification back-to-back then means that normal editor "reflow parapgraph" command will get confused and think that the signature is a continuation of the last message paragraph.
So I always end up having to first add an empty line, and then go back and reflow the last paragraph. Let's just do it in git directly.
The extra vertical space also makes the verification visually stand out more from the user-supplied message, so it looks a bit more readable to me too, but that may be just an odd personal preference.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
\end{git}
\subsection{Patches}
A patch is the differences you have added to the project.
\cmd{git format-patch -M origin/master} will create patches ready to be emailed.
One file will be create per commit. -M checks for rename\\
Better than diff as it contains commit messages.\\
Warning : copy/paste can lead to formatting issues. But you can configure Git.
\cmd{git apply mypatch.patch} : apply a patch generated by \cmd{git
diff}(everything or nothing strategy).\\
\cmd{git am mypatch.patch} : apply a patch generated by \cmd{git format-patch}
\subsection{Communicating}
\cmd{git archive master | gzip > myarchive.tar.gz} : create an archive\\
\cmd{git shortlog master} : create a summary of the commits
\section{Expert}
%\section{Must read}
%http://gitready.com/
%Note : git rebase is good for local change, but not if somebody pulled your tree
%:
%http://lwn.net/Articles/328436/
%
%\section{Error messages}
%Perhaps you should specify a branch such as ``master''
\end{document}
# Git
## Outline
* Do you want to use Git ? Why ?
* Git in 5 minutes (demo)
* Advanceds git
* Install Git : CERFACS or at home
### Why Git ?
Centralized Version System depends on the server (not always reliable).
In Distributed VCS, a complete copy of the server is done locally.
Context : created by Linus Torvald for Linux kernel dev, after BitKeeper access
was revoked.
Qualities : fast, efficient, allows non-linear dev through branching
### Features
* Git stores snapshots instead of file differences. If
there was no changes, it stores a link to the previous version.
* Most of the operations are local (no need for network + fast).
* Data integrity : everything is checksum (SHA-1 hash). The hash is used for
storing (ex: git log)
* Adds data : difficult to lose something
* 3 states :
* modified : changed, but not in database
* staged : changed, and ready to go in the next commit
* commited : in database
The folder are (resp.) :
* working directory (checkout of the project)
* staging area : a file with the info about the next commit
* git directory
## Basic Git
### Configuration :
Here we configure the name, email, editor and the diff tool :
git config --global user.name ``John Doe''
git config --global user.email johndoe@example.com
git config --global core.editor emacs
git config --global merge.tool vimdiff
This can be checked with `git config --list`
or in `.git/config`.
### Basics
* `git init`: init the git repo
* `git add README`: add the file
* `git commit -m 'initial project version'`: commit with a message
* `git clone git://github.com/schacon/grit.git myfolder`: clone the git repo into a local folder
### Recording changes
* `git status`
* `git add `: untracked to unmodified/modified
* `git stage `: modified to staged
* `git commit `: staged to unmodified
\# a comment - this is ignored
*.a
!lib.a
/TODO
build/
doc/*.txt }
* git diff : view exact changes
### History
* `git log`: commit message, author, date
* `git log -p`: show the diff
* `git log --stat`: number of modifications
* `git log --graph`: show branches
Graphical : `gitk`
### Undoing
* `git commit --amend`: add some file to a commit (staging area). Merge in
* single commit
* `git reset HEAD myfile`: unstage
* `git checkout`: undo changes
**Warning** : hard to lose something, but it must me commited.
### Remotes
* `git remote -v`: show remote
* Warning : can only pull from SSH url
* `git remote add [shortname] [url]` : add a remote
* `git fetch [shortname]` : fetch data without merging. Put it in local
* branches. (TODO: check that)
* `git pull [shortname]` = git fetch \&\& git merge
* `git push remote branch` : push to the remote. Example : git push origin
* master
* `git remote show`: show some informations about the remote
* `git remote rm }\cmd{ git remote rename `
_Tip_: if you don't have the permissions to update branch, it's easiest to push
your local branch directly to the remote, instead of merging to the master.
### Tags
* `git tag -a v7.2 -m "This is the version 7.2"`: tag with a number and
* message
* `git tag`: show tags
* `git show v7.2`: show info at version
* `git tag -s v7.2 -m "This is the version 7.2"`: tag with a GPG signature
* `git tag v7.2`: create lightweight tag (only checksum)
* `git tag -v v7.2`: verify tag
* `git tag -a v7.2 7epb61`: tag at the commit whose checksum is 7epb61
* Warning : you have to push you tags ! `git push origin v7.2`or
* `git push origin --tags`for all
_Tip_: there is a bash script for completion in the source code of git.
`source ~/.git-completion.bash`
Aliases can be created : `git config --global alias.co checkout`
## Advanced
### Branches
Why is it important ? Lightweight and fast.
#### Basics
Commit object = pointer to the snapshot, author, messages and pointer to the
previous commits (2 if merge).
A snapshot contains a blob (=version) for each file.
A branch is just a pointer to a commit. HEAD is a pointer to the current branch.
\begin{figure}[h]
\begin{tikzpicture}[transform shape,font=\scriptsize,scale=1.9]
\node (C1)[commit] {C1};
\node (C2)[commit,right of=C1] {C2};
\node (C3)[commit,below of=C2] {C3};
\node (master)[branch,above of=C2] {master};
\node (donkey)[branch,below of=C3] {donkey};
\node (head)[branch,above of=master] {HEAD};
\draw[arrow] (C2) to (C1);
\draw[arrow] (C3) to (C1);
\draw[arrow] (master) to (C2);
\draw[arrow] (donkey) to (C3);
\draw[arrow] (head) to (master);
\end{tikzpicture}
\end{figure}
Easy, right ?
* `git branch monkey`: creates a branch
* `git checkout monkey`: switch to the branch
* `git checkout -b monkey`: both of the above
#### Merging
`git checkout master}\cmd{ git checkout monkey`: merge to master
`git branch -d monkey`: delete the branch. Don't worry, removes only a
pointer !
#### Conflicts
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
Don't panic ! Simply remove the lines. Git cannot do that for you.
`git mergetool`for a visual merging tool.
Check everything has been merged : `git status`, and `git commit`
(default message).
_Tip_: with git merge, it will automatically commit. Use the --no-commit
option if you don't want to}
#### Management
* `git branch`: list branch, with * on the current
* `git branch -v`: list branch with last commit
* `git branch --merged`: list branch with last commit
### Workflow
Long-term branches : differents branch for stability. Ex (Debian) : _stable_,
_testing_, _unstable_
Short-term branches : for testing ideas. This is only local.
### Remote branches
Warning : source of confusion.
#### What happens when I clone ?
Git create an origin remote and pull the master. So
we have origin/master copied locally. However, we will work on the master branch
locally (the other will not be modified until the next push).
Explains the difference between fetch and pull : it creates a divergence.
What happens if someone commit between my git pull and my git push ?
You should always pull (git should say so) before pushing.
AND you should always check the log before that.
#### Tracking branch
Cloning creates a master branch which will track origin/master so git push will
work without arguments.
* `git checkout --track origin/monkey`: will track monkey
* `git checkout -b donkey origin/monkey`: idem but with another name.
* `git push origin :monkey`: delete remote branch (! difficult to memorise)
### Rebase
git merge performs a merge between the 2 latest snapshots.
* `git checkout donkey` and `git rebase master` will take all the changes
from donkey and apply it to master (starts from common ancestor and apply
successively)
* `git rebase master donkey`has the same result
What for ? Cleaner history (looks like we have done everything sequentially).
Result is the same.
**Quizz**: what does the following command does ?
`git rebase --onto master waiting testing`: will apply changes of testing
on master, but only from the ancestor of waiting and testing
NEVER use rebase on commits already pushed ?
QUIZZ : why ?
## Working with others
### Commit guidelines
* Check for whitespaces errors : `git diff --check`
* Each commit should be about a specific change. Don't forget you can
split your work into several commits ! More readable and easier for
reverting.
* Format your commit message. Ideally, a short description on the first
line, followed by a body.
commit a3347b988a338e95b7f3b11eda776ac0d7b84dd0
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri May 25 09:02:03 2012 -0700
fmt-merge-message: add empty line between tag and signature verification
When adding the information from a tag, put an empty line between the message of the tag and the commented -out signature verification information.
At least for the kernel workflow, I often end up re-formatting the message that people send me in the tag data. In that situation, putting the tag message and the tag signature verification back-to-back then means that normal editor "reflow parapgraph" command will get confused and think that the signature is a continuation of the last message paragraph.
So I always end up having to first add an empty line, and then go back and reflow the last paragraph. Let's just do it in git directly.
The extra vertical space also makes the verification visually stand out more from the user-supplied message, so it looks a bit more readable to me too, but that may be just an odd personal preference.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
### Patches
A patch is the differences you have added to the project.
`git format-patch -M origin/master`will create patches ready to be emailed.
One file will be create per commit. -M checks for rename
Better than diff as it contains commit messages.
Warning : copy/paste can lead to formatting issues. But you can configure Git.
`git apply mypatch.patch`: apply a patch generated by `git diff`(everything or nothing strategy).
`git am mypatch.patch` : apply a patch generated by `git format-patch`
### Communicating
`git archive master | gzip > myarchive.tar.gz`: create an archive
`git shortlog master`: create a summary of the commits
## Expert
### Older commits
A commit is referenced by its SHA number. Example : `commit
08920095740df4838b2b174624277c6372b40f3c`. We can refer it by an abbreviation
(8-10 numbers should be enough). We can refer to a parent with `HEAD~` (`HEAD~`
gives the other parent in case of a merge). Also we can access to the
grandparent `HEAD~~`. For the first parent, `HEAD~`. Grandparent is
`HEAD~2`.
Everything on donkey that is not in master : `git log master..donkey`.
What I am about to commit : `git log origin/master..HEAD`.
Negation (useful for multiple branches) : `git log \^donkey`: everything
not on donkey. (or `git log --not donkey`).
`git log master...donkey`: everything on each that is not common to the
two.
Tip : you can see the older positions of head with `git reflog`. Warning :
only since the cloning or for the last few months.
### Interactive staging
D\'emo. Useful for
\begin{git}
*** Commands ***
1: status 2: update 3: revert 4: add untracked
5: patch 6: diff 7: quit 8: help
\end{git}
patch allow for a partial staging.
### Stashing
Allows to temporary save your for switching to another tasks (without
committing). Ex :
`git stash`: save
`git checkout -b testing`: change to a new branch
`git checkout master`: return back to master
`git stash apply`: load saved data
We can also create a branch from a stashing : `git stash branch donkey`
_Tip_: if several stash, `git stash list`and \cmd{git stash apply
stash@\{2\}}.
Unapply stash : `git stash show -p stash@{1} | git apply -R`
%%
%% This is file `environ.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% environ.dtx (with options: `package')
%%
%% __________________________________
%% Copyright (C) 2007 Will Robertson
%%
%% License information appended.
%%
\ProvidesPackage{environ}[2008/06/18 v0.2 A new way to define environments]
\def\environbodyname#1{\def\env@BODY{#1}}
\environbodyname\BODY
\def\environfinalcode#1{%
\def\env@finalcode{#1}}
\environfinalcode{\ignorespacesafterend}
\def\longdef@c#1{%
\expandafter\long\expandafter\def\csname#1\endcsname}
\catcode`\Q=3
\long\def\trim@spaces#1{\romannumeral-`\q\trim@trim@\noexpand#1Q Q}
\long\def\trim@trim@#1 Q{\trim@trim@@#1Q}
\long\def\trim@trim@@#1Q#2{#1}
\catcode`\Q=11
\unless\ifdefined\collect@body
\newtoks\@emptytoks
\newtoks\@envbody
\def\collect@body#1{%
\@envbody{\expandafter#1\expandafter{\the\@envbody}}%
\edef\process@envbody{\the\@envbody\noexpand\end{\@currenvir}}%
\@envbody\@emptytoks \def\begin@stack{b}%
\begingroup
\expandafter\let\csname\@currenvir\endcsname\collect@@body
\edef\process@envbody{%
\expandafter\noexpand\csname\@currenvir\endcsname}%
\process@envbody
}
\def\push@begins#1\begin#2{%
\ifx\end#2\else
b\expandafter\push@begins
\fi}
\def\addto@envbody#1{%
\global\@envbody\expandafter{\the\@envbody#1}}
\def\collect@@body#1\end#2{%
\edef\begin@stack{%
\push@begins#1\begin\end \expandafter\@gobble\begin@stack}%
\ifx\@empty\begin@stack
\endgroup
\@checkend{#2}%
\addto@envbody{#1}%
\else
\addto@envbody{#1\end{#2}}%
\fi
\process@envbody}
\fi
\long\def\Collect@Body#1{%
\@envbody{\expandafter#1\expandafter{\the\@envbody}}%
\edef\process@envbody{\the\@envbody\noexpand\end{\@currenvir}}%
\@envbody\@emptytoks \def\begin@stack{b}%
\begingroup
\expandafter\let\csname\@currenvir\endcsname\Collect@@Body
\edef\process@envbody{%
\expandafter\noexpand\csname\@currenvir\endcsname}%
\process@envbody
}
\long\def\Push@Begins#1\begin#2{%
\ifx\end#2\else
b\expandafter\Push@Begins
\fi}
\long\def\Addto@Envbody#1{%
\global\@envbody\expandafter{\the\@envbody#1}}
\long\def\Collect@@Body#1\end#2{%
\edef\begin@stack{%
\Push@Begins#1\begin\end\expandafter\@gobble\begin@stack}%
\ifx\@empty\begin@stack
\endgroup
\@checkend{#2}%
\Addto@Envbody{#1}%
\else
\Addto@Envbody{#1\end{#2}}%
\fi
\process@envbody}
\def\NewEnviron{%
\let\env@newcommand\newcommand
\let\env@newenvironment\newenvironment
\env@NewEnviron}
\def\RenewEnviron{%
\let\env@newcommand\renewcommand
\let\env@newenvironment\renewenvironment
\env@NewEnviron}
\def\env@NewEnviron#1{%
\@ifnextchar[
{\env@new@i{#1}}
{\env@new@iii{#1}{}}}
\def\env@new@i#1[#2]{%
\@ifnextchar[
{\env@new@ii{#1}[#2]}
{\env@new@iii{#1}{[#2]}}}
\def\env@new@ii#1[#2][#3]{%
\env@new@iii{#1}{[#2][#3]}}
\long\def\env@new@iii#1#2#3{%
\@temptokena={\env@new{#1}{#2}{#3}}%
\@ifnextchar[{%
\the\@temptokena
}{%
\expandafter\the\expandafter
\@temptokena\expandafter[\env@finalcode]%
}}
\long\def\env@new#1#2#3[#4]{%
\env@newenvironment{#1}{%
\expandafter\Collect@Body\csname env@#1@parse\endcsname
}{#4}
\longdef@c{env@#1@parse}##1{%
\csname env@#1@save@env\endcsname##1\env@nil
\csname env@#1@process\endcsname##1\env@nil}%
\expandafter\env@newcommand
\csname env@#1@save@env\endcsname#2{\env@save}%
\expandafter\env@newcommand
\csname env@#1@process\endcsname#2{#3\env@ignore}}
\long\def\env@save#1\env@nil{%
\expandafter\edef\env@BODY{%
\unexpanded\expandafter
\expandafter\expandafter{\trim@spaces{#1}}}}
\long\def\env@ignore#1\env@nil{}
\newcommand\NewEnvironment{%
\let\env@newenvironment\newenvironment
\let\env@newcommand\newcommand
\Make@Environment}
\newcommand\RenewEnvironment{%
\let\env@newenvironment\renewenvironment
\let\env@newcommand\renewcommand
\Make@Environment}
\newcommand\Make@Environment[2]{%
\expandafter\let\csname env@args@#1\endcsname\ignorespaces
\env@newenvironment{#1}{%
\expandafter\Collect@Body\csname env@@#1\endcsname}{\ignorespacesafterend}%
\longdef@c{env@@#1}##1{%
\csname env@@@#1\endcsname{%
\csname env@args@#1\endcsname##1\unskip}}%
\longdef@c{env@@@#1}##1{#2}}
\newcommand\EnvironArgs[1]{%
\@ifnextchar[
{\Env@Args{#1}}
{\Env@Args{#1}[0]}}
\long\def\Env@Args#1[#2]{%
\@ifnextchar[
{\Env@@@Args{#1}[#2]}
{\Env@@Args{#1}[#2]}}
\long\def\Env@@Args#1[#2]#3{%
\expandafter\renewcommand\csname env@args@#1\endcsname[#2]{%
#3\ignorespaces}}
\long\def\Env@@@Args#1[#2][#3]#4{%
\expandafter\renewcommand\csname env@args@#1\endcsname[#2][#3]{%
#4\ignorespaces}}
%%
%% Copyright (C) 2007 by Will Robertson <wspr81@gmail.com>
%%
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%%
%% This work is "maintained" (as per LPPL maintenance status)
%% by Will Robertson.
%%
%% This work consists of the file environ.dtx
%% and the derived files environ.pdf,
%% environ.sty, and
%% environ.ins.
%%
%%
%% End of file `environ.sty'.
\usetheme{Boadilla}
\setbeamertemplate{footline}
{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{author in head/foot}\insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
\usebeamerfont{title in head/foot}\insertshorttitle
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
\usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
\insertframenumber{} / \inserttotalframenumber\hspace*{2ex}
\end{beamercolorbox}}%
\vskip0pt%
}
\usepackage{listings}
\usepackage{color}
\usepackage{hyperref}
\hypersetup{
colorlinks,%
linkcolor=black,%
urlcolor=red
}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\usepackage{environ}
% For diagram
\tikzstyle{commit}=[rectangle, draw=black, rounded corners, fill=green!40, drop
shadow, text centered, anchor=north]
\tikzstyle{branch}=[rectangle, draw=black, fill=red!30, drop
shadow, text centered, anchor=north, node distance = 7mm]
\tikzstyle{arrow}=[->, thick]
\tikzstyle{ltext}=[xshift=-0.9cm]
\tikzstyle{rtext}=[xshift=0.6cm]
% New itemize
\newenvironment{myitemize}{
\begin{itemize}
\setlength{\itemsep}{1pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}{\end{itemize}}
% For terminal commands
\definecolor{blueviolet}{RGB}{138, 43, 226}
\lstnewenvironment{terminal} {
\lstset{
% language=bash,
breaklines=true,
breakindent=0pt,
frameround=tttt,
basicstyle=\ttfamily\scriptsize,
frame=single,
morecomment=[l][\color{blueviolet}]{$}
}}{}
% Inline commands
\def\cmd#1{\texttt{\textcolor{blueviolet}{#1}}}
\def\smallcmd#1{{\footnotesize \cmd{#1}}}
% Environment for tips
% We must use the environ package for include tikz in our environment
\tikzstyle{tipsbox} = [draw=blue, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=10pt]
\tikzstyle{tipstitle} =[fill=white]
%\tikzstyle{tipstitle} =[fill=blue, text=white, ellipse]
\NewEnviron{tips}{%
\begin{figure}[h]
\begin{tikzpicture}[transform shape, baseline=-3.5cm]
\node[tipsbox] (box){%
\begin{minipage}{0.95\textwidth}
{\footnotesize
\BODY}
\end{minipage}};
\node[tipstitle] at (box.north) {\textbf{\footnotesize Tips}};
\end{tikzpicture}
\end{figure}
}
\def\tilde{\raise.17ex\hbox{$\scriptstyle\sim$}}
\documentclass{article}
% Nice backslash
\newcommand\bSLASH{\char`\\}
\renewcommand{\labelitemi}{$\bullet$}
\newcommand\BSLASH{\textbackslash}
% Tat
\newcommand{\tab}{\hspace*{2cm}}
% Bourbaki symbol
\usepackage{manfnt}
\makeatletter
\def\hang{\hangindent\parindent}
\def\d@nger{\medbreak\begingroup\clubpenalty=10000
\def\par{\endgraf\endgroup\medbreak} \noindent\hang\hangafter=-2
\hbox to0pt{\hskip-\hangindent\dbend\hfill}}
\outer\def\danger{\d@nger}
\makeatother
% Smaller margins
\usepackage{fullpage}
\begin{document}
\title{Notes on Knuth's \TeX{} book}
\date{}
\maketitle
\danger Sometimes, the difference between the `good' and `bad' typography
can be quite subtle to see. Do not hesitate to zoom in !
\danger Knuth's book is about plain \TeX, but it is not always compatible
with \LaTeX\footnote{Text resizing and tables are managed differently for
example}. I have put here only samples which will work with both.
\section{Symbols}
\paragraph{Special symbols}
Here is a list of special symbols and how to type them. You will only have to
escape most of them with a \bSLASH.
\begin{center}
\begin{tabular}{c|c c c c c c c c c}
Symbole & \BSLASH & \{ & \} & \$ & \& & \# & \_ & \% & \textasciitilde \\
\hline
Code & \BSLASH textbackslash&\BSLASH\{ &\BSLASH\} &
\BSLASH\$ & \BSLASH\& & \BSLASH\# & \BSLASH\_ &
\BSLASH\% & \BSLASH textasciitilde \\
\end{tabular}
\end{center}
A backslash can also be obtained with \BSLASH backslash in math mode or
in Typewriter interface with \BSLASH char~`\BSLASH\BSLASH.
\paragraph{Dashes}
There are several types :
\begin{itemize}
\item the hyphen -, used for compounds like `kick-ass',
\item the en-dash --, used in number ranges like `18-20',
\item the em-dash ---, used in sentences --- for separation.
\end{itemize}
\section{Fonts}
\paragraph{Alternatives} Instead of using {\tt \bSLASH textit\{italics\}} for
typing \textit{italics}, you can use the command {\tt \{\bSLASH it italics\}}.
The difference between the two is quite simple : {\tt \bSLASH textit} will put in
italics only the text between curly brackets, while {\tt \bSLASH it} will typeset
everything after it into italics, thus the need for exterior curly brackets.
Of course, the situtaion is the same with Typewriter fonts. The comparison is then
between {\tt \bSLASH textit} and {\tt \bSLASH tt}.
\paragraph{Italics}
Did you know the space between an italic letter and a roman letter can be
inadequate ? It appears to be too small due to the inclinaison. \\
\centerline{{\it As an example, compare that} space {\it with the correction,
that\/} space.}\\
You can change it with {\tt \bSLASH /}, like\\
\centerline{\tt \{\bSLASH it See that \bSLASH /\} space}
\section{Glue}
In \TeX{}, everything are represented by boxes. Each boxes has a "glue", which can
stretch or shrink according to its definition. For somes cases, the glue
features are different. After a comma, the stretch rate is 1.25 the normal rate.
After a period or a "!, the rate is 3 times the normal one.
This can be problematic if the period is in the middle of a sentence. For
example, abbreviations like `Mr. Brightside' contains a larger space than it should. A
solution is to place a space `\BSLASH ' but it is prerable to use a
\textasciitilde{} like that :\\
\centerline{\tt Mr.\textasciitilde{}Brightside}
If you prefer to adopt the so-called `French spacing', which has only one sort
of space, the command is {\tt \bSLASH frenchspacing} (and {\tt \bSLASH
nonfrenchspacing} for deactivating it).
\section{Lines breaking}
\TeX{} is trained to be good at breaking lines. However in some cases, you do
not want a set of words to be breaked. A tilde put at the right place will avoid
these troubles. Examples :\\
\tab{\tt Theorem\textasciitilde{}1.2} \\
\tab{\tt function\textasciitilde{}\$f(x)\$} \\
\tab{\tt Diderik van\textasciitilde{}der\textasciitilde{}Waals}
\section{Math}
\paragraph{Fractions}
Did you know there is an alternative to \texttt{\bSLASH frac} for typing fractions ?
{\tt \bSLASH over} will put everything before in the numerator and everything
after in the denominator. So {\$\$\tt x+1 \bSLASH over y-1\$\$} will output
:\\
$$ x+1 \over y-1$$
Likewise a binomial coefficient can be written with {\tt \bSLASH choose}.
{\$\$\tt x+1 \bSLASH over y-1\$\$} gives :
$$ n+1 \choose k-1$$
\paragraph{Styles}
According to the context, a certain size, or `style', will be chosen.
As an example, a sum will not be displayed the same if put between \$ \$ or between \$\$ \$\$.
The {\tt \bSLASH scriptstyle} command will reduce the input size like this :
$$ a+\scriptstyle b+\scriptstyle c$$
On the contrary, {\tt \bSLASH displaystyle} will make it larger. It can be useful
for more readeable sums like $\displaystyle \sum_{i=0}^{n}$ instead of
$ \sum_{i=0}^{n}$, or continued fractions :
$$ a_0 + {1 \over \displaystyle a_1+ {1 \over \displaystyle a_2 + {a_3 \over a_4}}}
\mbox{ is nicer than }
a_0 + {1 \over a_1+ {1 \over a_2 + {a_3 \over a_4}}}$$
The previous continued fraction was obtained with :\\
\centerline{\tt \$\$ a\_0+\{1 \bSLASH over \bSLASH displaystyle a\_1+
\{1 \bSLASH over \bSLASH displaystyle a\_2+\{a\_3 \bSLASH over
a\_4\}\} \$\$}\\
Finally, the {\tt \bSLASH atop} command will output vertically-aligned variables.
We can use it for adding several indices in a sum. With the help of {\tt \bSLASH
displaystyle}, we can have
$$ \sum_{\displaystyle i \le n \atop \displaystyle j \le n} a_{ij} $$
by typing \\
\centerline{ \tt
\$\$ \bSLASH sum\_\{\bSLASH displaystyle i \bSLASH le n \bSLASH atop
\bSLASH displaystyle j \bSLASH le n\} a\bSLASH \_\{ij\}\bSLASH \$\$
}
\paragraph{Accents} A wide range of accents is available in math mode :
\begin{table}[h]
\centering
\begin{tabular}{c|c c c c c}
Symbole & $\acute a$ & $\bar a$ & $\breve a$ & $\check a$ & $\dot a$ \\
\hline
Code & \$\BSLASH acute a\$ & \$\BSLASH bar a\$ & \$\BSLASH breve a\$ &
\$\BSLASH check a\$ & \$\BSLASH dot a\$
\end{tabular}
\vspace{10pt}
\begin{tabular}{c|c c c c c}
Symbole & $\ddot a$ & $\grave a$ & $\hat a$ & $\tilde a$ & $\vec a$ \\
\hline
Code &\$\BSLASH ddot a\$ & \$\BSLASH grave a\$ & \$\BSLASH hat a\$
& \$\BSLASH tilde a\$ & \$\BSLASH vec a\$
\end{tabular}
\end{table}
\section{Math revisited}
\paragraph{Roman} In math mode, text is in italics by default. If you need to
type an expression in Roman, and if it is undefined, just use {\tt \bSLASH rm} or
{\tt \bSLASH hbox}. For example :
$$ \sqrt{{\rm Euler}(x)}$$
is obtained by\\
\centerline{\tt \$\$\bSLASH sqrt\{\bSLASH hbox\{Euler\}(x)\}\$\$ {\rm or}
\$\$ \bSLASH sqrt\{\{\bSLASH rm Euler\}(x)\}\$\$}
\paragraph{Spacing} In equations, you may want to add some spaces between
different formulas :
$$ u_{n+1} = 3 n + 2, \qquad \forall n \ge 0 $$
\texttt{\bSLASH qquad} will serve this purpose. \texttt{\bSLASH quad} is
also available for a lesser space. Example :\\
\centerline{\tt \$\$ u\_\{n+1\} = 3 n + 2, \bSLASH qquad \bSLASH forall n
\bSLASH ge 0 \$\$}
The default spacing in formulas is quite good but you can always add more space.
with the following commands
\begin{center}
\begin{tabular}{c c c c}
Thin & Medium & Thick & Negative \\
\BSLASH, & \BSLASH $\ge$ & \BSLASH ;& \BSLASH !
\end{tabular}
\end{center}
\paragraph{Dots} There are two kinds of dots :
$$ f(x_1,\ldots,x_n) \quad \mbox{and} \quad x_1 +\cdots+x_n$$
The {\tt \bSLASH ldots} gives `lower' dots, whereas
{\tt \bSLASH cdots} gives `higher' dots. Examples :\\
\tab \tab \tab{\tt
\$\$ f(x\_1,\bSLASH ldots,x\_n) \$\$}\\
\tab \tab \tab {\tt
\$\$ x\_1 +\bSLASH cdots+x\_n \$\$
}
\end{document}
\documentclass[12pt]{report}
\usepackage[francais]{babel}
\usepackage{amsmath}
\begin{document}
\chapter{M\'ethodes num\'eriques}
\section{Syst\`emes lin\'eaires}
$$Ax = b$$
Pour des syst\`emes pleins, m\'ethodes directes.
\subsection{D\'ecomposition LU}
Si A est inversible, on peut appliquer le pivot de Gauss pour avoir une
d\'ecomposition \\
$A = LU$ , L triangulaire inf\'erieure
U triangulaire sup\'erieure.\\
Cout total en $O(\frac{2}{3}n^3)$.\\
\textit{Attention: } Si le pivot est trop petit, les approximations num\'eriques
peuvent donner de r\'esultats faux. Pivot partiel : on choisit la ligne de
coefficient maximal.
\subsection{M\'ethode de Cholesky}
Si la matrice A est sym\'etrique d\'efinie positive, elle peut se mettre sous la
forme $T T^t$ avec T triangulaire inf\'erieure.\\
Cout total en $O(\frac{1}{3}n^3)$.\\
Si le syst\`eme est creux, m\'ethodes it\'eratives. On d\'ecompose $A=M-N$ :
$$M x_{k+1} = N x_k + b$$
\subsection{M\'ethode de Jacobi}
$M=D$ et $N=A-D$ o\`u D est la diagonale de A.\\
Converge ssi \`a diagonale strictement dominante ($a_{ii} > 0$)\\
Peu utilis\'ee.
\subsection{M\'ethode de Gauss-Seidel}
$M=D+L$ et $N=-U$ o\`u D est la diagonale de A, L triangulaire inf\'erieure, U
triangulaire sup\'erieure.\\
Peu utilis\'ee.
\subsection{M\'ethode SOR}
Gauss-Seidel avec un param\`etre de relaxation $\omega$.\\
$M=\frac{1}{\omega}D+L$ et $N=\frac{1-\omega}{\omega}D-U$\\
Si A est sym\'etrique, d\'efinie positive, convergence ssi $\omega \in [0,2]$
\section{Fonctions non lin\'eaires}
\subsection{M\'ethode de Newton}
Permet de trouver les racines de $f(x)=0$
$$x_{k+1} = x_k-Df^{-1}(x_k) f(x_k)$$
Convergence quadratique mais calcul de la jacobienne couteux.
\subsection{M\'ethode de Broyden}
Quasi newton : on approche la jacobienne par
$$J_n(x_n-x_{n-1}) = F(x_n)-F(x_{n-1}) $$
Peut \^etre sous d\'etermin\'e. D'autres m\'ethodes de calcul de $J_n$ existent.
\section{M\'ethodes d'optimisations}
Les deux premi\`eres m\'ethodes avec le gradient s'appliquent pour des fonctions
$C^1$. Le gradient conjugu\'e s'utilise pour des fonctions $C^2$.
\subsection{Gradient \`a pas constant}
$x_{k+1} = x_k - \rho \nabla f(x_k)$ avec $\rho > 0$ fix\'e.\\
Peu utilis\'ee \`a cause d'instabilit\'es num\'eriques.
\subsection{M\'ethode de plus grande descente}
$$x_{k+1} = x_k - \rho_k \nabla f(x_k)$$
$\rho_k$ est adapt\'e \`a chaque \'etape en minimisant
$$\phi(\rho)=f(x_k - \rho_k \nabla f(x_k))$$
Si f est convexe, on peut utiliser la m\'ethode de Newton pour r\'esoudre
$\phi'(\rho)=0$.
On peut aussi proc\'ed\'er par dichotomie : sur $[a,b]$, f doit \^etre
unimodale\footnote{Il existe $c \in [a,b]$ tel que
$\phi'(x) < 0$ sur $]a,c[$ et
$\phi'(x) > 0$ sur $]c,b[$}
Convergence lin\'eaire.
\subsection{Gradient conjugu\'e}
Pour une fonction quadratique $f(x)=\frac{1}{2} x^t A x - x^t b$.\\
Soit $r k=Ax_k-b$.
It\'eration : $x_{k+1}=x_k-\rho_k \omega_k$ avec
\begin{equation*}
\left\{
\begin{array}{l}
\omega_k =r_k+\theta_k \omega_{k-1} \text{ et }
\theta_k=\frac{||r_k||_2^2}{||r_{k-1}||_2^2}\\
\rho_k =\frac{||r_k||_2^2}{w_k^t A w^k}
\end{array}
\right.
\end{equation*}
\chapter{EDP}
\section{EDP lin\'eaires d'ordre 1}
On veut r\'esoudre
$$\nabla \phi(X)\cdot F(x)+g(X)\phi(X) = h(X)$$
Les caract\'eristiques sont donn\'ees par
$$ \frac{dX}{ds}=F(X)$$
Sur les caract\'eristiques, cela revient \`a r\'esoudre une EDP d'ordre 1
$$ \frac{d \phi(X(s))}{ds}=-g(X(s)) \phi(X(s)) + h(X(s))$$
\section{EDP lin\'eaires d'ordre 2}
$$ a(x,y) \frac{\partial^2 u}{\partial x^2}+
b(x,y) \frac{\partial^2 u}{\partial x \partial y}+
c(x,y) \frac{\partial^2 u}{\partial y^2}+
f(x,y,\frac{\partial u}{\partial x}, \frac{\partial u}{\partial y})=0$$
On fait une discussion sur le type d'EDP sur un domaine D.
\subsection{Cas hyperbolique}
Si $b^2-4ac > 0$, on fait un changement de coordonn\'ees pour avoir 2 \'equations de
transports :
\begin{equation*}
\left\{
\begin{array}{l}
2a \xi_x+(b-\sqrt{b^2-4ac}) \xi_x = 0\\
2a \eta_x+(b-\sqrt{b^2-4ac}) \eta_x = 0\\
\end{array}
\right.
\end{equation*}
Forme canonique :
$$ \frac{\partial^2 v}{\partial \xi \partial \eta}=G(\xi,\eta,v,
\frac{\partial v}{\partial \xi},\frac{\partial v}{\partial \eta})$$
\subsection{Cas parabolique}
Si $b^2-4ac = 0$, on fait un changement de coordonn\'ees pour avoir 2 \'equations de
transports :
\begin{equation*}
\left\{
\begin{array}{l}
2a \xi_x+ b \xi_x=0\\
\eta \text{ est choisi tel que } \phi \text{ est un } C^2 \text{-diff\'eomorphisme}
\end{array}
\right.
\end{equation*}
Forme canonique :
$$ \frac{\partial^2 v}{\partial \eta^2}=G(\xi,\eta,v,
\frac{\partial v}{\partial \xi},\frac{\partial v}{\partial \eta})$$
\subsection{Cas elliptique}
Forme canonique :
$$ \frac{\partial^2 v}{\partial \xi^2}
+\frac{\partial^2 v}{\partial \eta^2}+G(\xi,\eta,v,
\frac{\partial v}{\partial \xi},\frac{\partial v}{\partial \eta})=0$$
A COMPLETER
\section{Sch\'emas num\'eriques}
\subsection{Consistance, convergence, stabilit\'e}
Discr\'etisation : $u_{n+1}=C(\Delta t,\Delta x) u_n$\\
Consistance d'un sch\'ema : caract\'erise l'erreur de troncature.
$$\lim_{(\Delta t,\Delta x)\rightarrow 0}
\sup_{t_n} ||\frac{u(t_n+\Delta t)-C(\Delta t,\Delta x)u(t_n)}{\Delta t}||=0 $$
Sch\'ema d'ordre r en espace et q en temps
$$\sup_{t_n} ||u(t_n+\Delta t)-C(\Delta t,\Delta x)u(t_n)||=
O(|\Delta t|^{q+1}+
|\Delta t| |\Delta x |^r) $$
Stabilit\'e d'un sch\'ema :
Il existe une constante $K_T$ telle que
$\forall \Delta x, \Delta t, n \Delta t \le T$
$$|| C(\Delta t,\Delta x)^n|| \le K_T$$
Convergence d'un sch\'ema :
L'\'ecart entre la solution approch\'ee et la solution exacte tend vers 0 quand le
pas de discr\'etisation tend vers 0.\\
Th\'eor\^eme de Lax : soit un sch\'ema consistant. Alors il est convergent ssi il est
stable.\\
Analyse de von Neumann : prendre la transform\'ee de Fourier
$$\hat{U}^{n+1}(\lambda)=G(\Delta x, \Delta t, 2\pi \lambda) \hat{U}^n $$
Stabilit\'e :
Il existe une constante $K_T$ telle que
$\forall \Delta x, k, \Delta t, n \Delta t \le T$
$$|| G(\Delta t,\Delta x,k)^n|| \le K_T$$
Soit $\lambda_i$ les valeurs propres de G.\\
Th\'eoreme de von Neumann : \\
CN de stabilit\'e
$$\sup_k \max_i |\lambda_i| \le 1+O(|\Delta t|) $$
Si G est normale, c'est une CNS.
\subsection{Types de schémas}
Exemple de l'équation de transport.
\subsubsection{Sch\'ema euler explicite décentré}
Aval :
$$\frac{u_j^{n+1}- u_j^n}{\Delta t} +c \frac{u_j^n- u_{j-1}^n}{\Delta x}=0$$
Ordre 1 en espace et 1 en temps pour l'équation de transport.\\
Toujours instable\\
Amont :
Stable si $c \frac{\Delta x}{\Delta t} \le 1$
\subsubsection{Sch\'ema euler explicite centré}
$$\frac{u_j^{n+1}- u_j^n}{\Delta t} +
c \frac{u_{j+1}^n- u_{j-1}^n}{2 \Delta x}=0$$
Ordre 2 en espace et 1 en temps pour l'équation de transport.\\
Instable si $\frac{\Delta x}{\Delta t}$ reste constant.
\subsubsection{Sch\'ema de Lax Wendrof}
$$\frac{u_j^{n+1}- u_j^n}{\Delta t} +
c \frac{u_{j+1}^n- u_{j-1}^n}{2 \Delta x}-
\frac{c^2}{2}\frac{\Delta t}{\Delta x^2}
\frac{u_{j+1}^n+2 u_j- u_{j-1}^n}{2 \Delta x}=0$$
Ordre 2 en temps et en espace.\\
Stable si $|c| \frac{\Delta x}{\Delta t} \le 1$
\chapter{El\'ements finis}
\section{}
\chapter{Volume finis}
\section{}
\end{document}
:PROPERTIES:
:ID: 32598fde-e934-43dc-bb69-21c9b8013948
:END:
#+title: Backup
#+filetags: personal
* Nouvelle version
On ne fait plus de sauvegarde mais des archives.
hubic n'existe plus.
- public (13Go) = On utilise git-annex non encrypter pour archiver sur:
- github (LFS, accès direct)
- mega
- disque dur
- private (5.6Gb) = git-annex avec encryption
- mega
- disque dur
Contenu
- public
* Ancienne version
- google -> to google drive (clear)
- hubic -> to Hubic and Mega(clear)
- local config files -> google and hubic (encrypted)
- raspberry config files -> google and hubic (encrypted)
- local rtorrent -> google and hubic (encrypted)
- raspberry rtorrent -> google and hubic (encrypted)
#+begin_src fish
#!/usr/local/bin/fish
# 3 steps procedure :
# 1. Backup from the pi using rsync
# 2. Encrypt cofig files (rasperry + local) using duplicity
# 2. Backup to the cloud using rsync
#
# Backup data either in clear or encrypted
# - google -> to google drive (clear)
# - hubic -> to Hubic and Mega(clear)
# - local config files -> google and hubic (encrypted)
# - raspberry config files -> google and hubic (encrypted)
# - local rtorrent -> google and hubic (encrypted)
# - raspberry rtorrent -> google and hubic (encrypted)
set root "/home/alex/backups"
# Duplicity needs a passphrase. Use pass "backup/duplicity"
set -x PASSPHRASE (cat /home/alex/.pass.txt)
# #------- Raspberry: backup -----
# Save books
# rclone sync pi:/media/books/ /media/books/
cd /home/alex/annex ; git annex sync
# Save torrents and config files(encrypted)
# Warning : --include implyies everything is excluded so we need /** at the end
# Don't forget the / in the folder too..
set tmp ~/backups/raspberry-tmp/
rclone sync --include "/home/alex/Downloads/torrents/**" \
--include "/home/alex/Downloads/session/**" \
--include "/usr/local/etc/**" \
--include "/etc/**" \
--include "/boot/loader.conf" pi:/ $tmp
# Encrypt it
duplicity --allow-source-mismatch $tmp file:///home/alex/backups/raspberry
#------- Local backup (encrypted) ----------------
# 1. Create encrypted local version
#
# This requires setenv PASSPHRASE in doas.conf !!
# Due to permission, we need separate folder for doas command
doas duplicity --allow-source-mismatch --include /usr/local/etc/ --include /etc/ \
--include /boot/loader.conf --exclude '**' \
/ file:///home/alex/backups/desktop/root
duplicity --allow-source-mismatch --include /home/alex/Downloads/torrents \
--include /home/alex/Downloads/session \
--exclude '**' \
/home/alex/Downloads file:///home/alex/backups/desktop/rtorrent
#------------ Backup all encnrypted and non encrypted
# Backup is then made with rsync because there is a symlink
# desktop -> google/desktop
# desktop -> hubic /desktop
#--- All
# Google drive and mega can be managed with rclone
rclone -L sync --exclude 'Coopétition/' --drive-import-formats .xlsx $root/google/ google:
rclone -L sync $root/google backblaze:unixStorage
rclone -L sync $root/hubic hubic:
rclone -L sync $root/hubic mega:
#--- Passphrase
/usr/local/bin/pass git push
#+end_src