diff --git a/Makefile b/Makefile index a06b476..78e4a2f 100644 --- a/Makefile +++ b/Makefile @@ -3,29 +3,44 @@ BASENAME=scientificcomputing-script SUBDIRS=programming plotting programmingstyle statistics bootstrap regression likelihood pointprocesses designpattern SUBTEXS=$(foreach subd, $(SUBDIRS), $(subd)/lecture/$(subd).tex) -pdf : chapters $(BASENAME).pdf +all : script chapters chapters : - for sd in $(SUBDIRS); do $(MAKE) -C $$sd/lecture pdf; done + for sd in $(SUBDIRS); do $(MAKE) -C $$sd/lecture chapter; done + +script : plots $(BASENAME).pdf + + +plots : + for sd in $(SUBDIRS); do $(MAKE) -C $$sd/lecture plots; done + + +pdf : $(BASENAME).pdf $(BASENAME).pdf : $(BASENAME).tex header.tex $(SUBTEXS) pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true splitindex $(BASENAME).idx -again : - pdflatex $(BASENAME).tex - index : pdflatex -interaction=scrollmode $(BASENAME).tex splitindex $(BASENAME).idx pdflatex -interaction=scrollmode $(BASENAME).tex | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex $(BASENAME).tex || true +again : + pdflatex $(BASENAME).tex + +watchpdf : + while true; do ! make -s -q pdf && make pdf; sleep 0.5; done + + +watchscript : + while true; do ! make -s -q script && make script; sleep 0.5; done + + clean : rm -f *~ $(BASENAME).aux $(BASENAME).log $(BASENAME).out $(BASENAME).toc $(BASENAME).lo? $(BASENAME).idx $(BASENAME)-term.i* $(BASENAME)-enterm.i* $(BASENAME)-code.i* for sd in $(SUBDIRS); do $(MAKE) -C $$sd/lecture clean; done cleanall : clean - rm -f $(PDFFILE) - -watchpdf : - while true; do ! make -q pdf && make pdf; sleep 0.5; done + rm -f $(BASENAME).pdf + for sd in $(SUBDIRS); do $(MAKE) -C $$sd/lecture cleanall; done diff --git a/bootstrap/lecture/Makefile b/bootstrap/lecture/Makefile index 7abf35f..3f9c4f6 100644 --- a/bootstrap/lecture/Makefile +++ b/bootstrap/lecture/Makefile @@ -1,32 +1,13 @@ BASENAME=bootstrap -PYFILES=$(wildcard *.py) -PYPDFFILES=$(PYFILES:.py=.pdf) - all : pdf -# script: -pdf : $(BASENAME)-chapter.pdf - -$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(PYPDFFILES) - CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ - PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ - sed -i -e "s/setcounter{page}{.*}/setcounter{page}{$$PAGE}/; s/setcounter{chapter}{.*}/setcounter{chapter}{$$CHAPTER}/" $(BASENAME)-chapter.tex - pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true +include ../../chapter.mk -$(PYPDFFILES) : %.pdf : %.py - python $< - -clean : - rm -f *~ - rm -f $(BASENAME).aux $(BASENAME).log - rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out - rm -f $(PYPDFFILES) $(GPTTEXFILES) - -cleanall : clean - rm -f $(BASENAME)-chapter.pdf +# script: +pdf : chapter -watchpdf : - while true; do ! make -q pdf && make pdf; sleep 0.5; done +clean : cleanchapter +cleanall : clean cleanchapter diff --git a/bootstrap/lecture/bootstrap-chapter.tex b/bootstrap/lecture/bootstrap-chapter.tex index 29816da..2b3dbe8 100644 --- a/bootstrap/lecture/bootstrap-chapter.tex +++ b/bootstrap/lecture/bootstrap-chapter.tex @@ -5,8 +5,10 @@ \lstset{inputpath=../code} \graphicspath{{figures/}} -\setcounter{page}{69} -\setcounter{chapter}{4} +\typein[\pagenumber]{Number of first page} +\typein[\chapternumber]{Chapter number} +\setcounter{page}{\pagenumber} +\setcounter{chapter}{\chapternumber} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/chapter.mk b/chapter.mk new file mode 100644 index 0000000..8a56ed1 --- /dev/null +++ b/chapter.mk @@ -0,0 +1,52 @@ +# plots: +plots : pythonplots gnuplots + +# python plots: +PYFILES=$(wildcard *.py) +PYPDFFILES=$(PYFILES:.py=.pdf) + +pythonplots : $(PYPDFFILES) + +$(PYPDFFILES) : %.pdf: %.py + python $< + +cleanpythonplots : + rm -f $(PYPDFFILES) + + +# gnuplot plots: +GPTFILES=$(wildcard *.gpt) +GPTTEXFILES=$(GPTFILES:.gpt=.tex) + +gnuplots : $(GPTTEXFILES) + +$(GPTTEXFILES) : %.tex: %.gpt whitestyles.gp + gnuplot whitestyles.gp $< + epstopdf $*.eps + +cleangnuplots : + rm -f $(GPTTEXFILES) + + +# script: +chapter : $(BASENAME)-chapter.pdf + +$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(wildcard $(BASENAME).aux) $(PYPDFFILES) $(GPTTEXFILES) + if test -f $(BASENAME).aux; then \ + CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ + PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ + fi; \ + { echo $${PAGE:=1}; echo $${CHAPTER:=0}; } | pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && { echo $${PAGE:=1}; echo $${CHAPTER:=0}; } | pdflatex -interaction=scrollmode $< || true + +watchchapter : + while true; do ! make -q chapter && make chapter; sleep 0.5; done + + +cleanchapter : cleanpythonplots cleangnuplots + rm -f *~ + rm -f $(BASENAME).aux $(BASENAME).log + rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out $(BASENAME)-chapter.idx + + +cleanallchapter : cleanchapter + rm -f $(BASENAME)-chapter.pdf diff --git a/designpattern/lecture/Makefile b/designpattern/lecture/Makefile index 145c35c..e7312a5 100644 --- a/designpattern/lecture/Makefile +++ b/designpattern/lecture/Makefile @@ -1,32 +1,13 @@ BASENAME=designpattern -PYFILES=$(wildcard *.py) -PYPDFFILES=$(PYFILES:.py=.pdf) - all : pdf -# script: -pdf : $(BASENAME)-chapter.pdf - -$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(PYPDFFILES) - CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ - PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ - sed -i -e "s/setcounter{page}{.*}/setcounter{page}{$$PAGE}/; s/setcounter{chapter}{.*}/setcounter{chapter}{$$CHAPTER}/" $(BASENAME)-chapter.tex - pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true +include ../../chapter.mk -$(PYPDFFILES) : %.pdf : %.py - python $< - -clean : - rm -f *~ - rm -f $(BASENAME).aux $(BASENAME).log - rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out - rm -f $(PYPDFFILES) $(GPTTEXFILES) - -cleanall : clean - rm -f $(BASENAME)-chapter.pdf +# script: +pdf : chapter -watchpdf : - while true; do ! make -q pdf && make pdf; sleep 0.5; done +clean : cleanchapter +cleanall : clean cleanchapter diff --git a/designpattern/lecture/designpattern-chapter.tex b/designpattern/lecture/designpattern-chapter.tex index 31c6e00..4bb7291 100644 --- a/designpattern/lecture/designpattern-chapter.tex +++ b/designpattern/lecture/designpattern-chapter.tex @@ -5,8 +5,10 @@ \lstset{inputpath=../code} \graphicspath{{figures/}} -\setcounter{page}{121} -\setcounter{chapter}{8} +\typein[\pagenumber]{Number of first page} +\typein[\chapternumber]{Chapter number} +\setcounter{page}{\pagenumber} +\setcounter{chapter}{\chapternumber} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/likelihood/lecture/Makefile b/likelihood/lecture/Makefile index 51e7876..17f92ae 100644 --- a/likelihood/lecture/Makefile +++ b/likelihood/lecture/Makefile @@ -1,32 +1,12 @@ BASENAME=likelihood -PYFILES=$(wildcard *.py) -PYPDFFILES=$(PYFILES:.py=.pdf) - all : pdf -# script: -pdf : $(BASENAME)-chapter.pdf - -$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(PYPDFFILES) - CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ - PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ - sed -i -e "s/setcounter{page}{.*}/setcounter{page}{$$PAGE}/; s/setcounter{chapter}{.*}/setcounter{chapter}{$$CHAPTER}/" $(BASENAME)-chapter.tex - pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true - -$(PYPDFFILES) : %.pdf : %.py - python $< +include ../../chapter.mk -clean : - rm -f *~ - rm -f $(BASENAME).aux $(BASENAME).log - rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out - rm -f $(PYPDFFILES) $(GPTTEXFILES) - -cleanall : clean - rm -f $(BASENAME)-chapter.pdf - -watchpdf : - while true; do ! make -q pdf && make pdf; sleep 0.5; done +# script: +pdf : chapter +clean : cleanchapter +cleanall : clean cleanchapter diff --git a/likelihood/lecture/likelihood-chapter.tex b/likelihood/lecture/likelihood-chapter.tex index 714919a..bb4182a 100644 --- a/likelihood/lecture/likelihood-chapter.tex +++ b/likelihood/lecture/likelihood-chapter.tex @@ -5,8 +5,10 @@ \lstset{inputpath=../code} \graphicspath{{figures/}} -\setcounter{page}{89} -\setcounter{chapter}{6} +\typein[\pagenumber]{Number of first page} +\typein[\chapternumber]{Chapter number} +\setcounter{page}{\pagenumber} +\setcounter{chapter}{\chapternumber} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/plotting/lecture/Makefile b/plotting/lecture/Makefile index 3fa9e21..5e11607 100644 --- a/plotting/lecture/Makefile +++ b/plotting/lecture/Makefile @@ -1,21 +1,12 @@ BASENAME=plotting -PYFILES=$(wildcard *.py) -PYPDFFILES=$(PYFILES:.py=.pdf) - -GPTFILES=$(wildcard *.gpt) -GPTTEXFILES=$(GPTFILES:.gpt=.tex) - all: pdf slides thumbs +include ../../chapter.mk + # script: -pdf : $(BASENAME)-chapter.pdf -$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(GPTTEXFILES) $(PYPDFFILES) ../../header.tex - CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ - PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ - sed -i -e "s/setcounter{page}{.*}/setcounter{page}{$$PAGE}/; s/setcounter{chapter}{.*}/setcounter{chapter}{$$CHAPTER}/" $(BASENAME)-chapter.tex - pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true +pdf : chapter # slides: @@ -31,31 +22,15 @@ $(BASENAME)-handout.pdf: $(BASENAME)-slides.tex $(GPTTEXFILES) pdfnup --nup 2x4 --no-landscape --paper a4paper --trim "-1cm -1cm -1cm -1cm" --outfile $@ thumbsfoils.pdf # 1-19 rm thumbsfoils.* -watchpdf : - while true; do ! make -q pdf && make pdf; sleep 0.5; done - watchslides : while true; do ! make -q slides && make slides; sleep 0.5; done -# python plots: -$(PYPDFFILES) : %.pdf: %.py - python $< - -# gnuplot plots: -$(GPTTEXFILES) : %.tex: %.gpt whitestyles.gp - gnuplot whitestyles.gp $< - epstopdf $*.eps - -clean : - rm -f *~ - rm -f $(BASENAME).aux $(BASENAME).log - rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out +clean : cleanchapter rm -f $(BASENAME)-slides.aux $(BASENAME)-slides.log $(BASENAME)-slides.out $(BASENAME)-slides.toc $(BASENAME)-slides.nav $(BASENAME)-slides.snm $(BASENAME)-slides.vrb - rm -f $(PYPDFFILES) $(GPTTEXFILES) -cleanall : clean - rm -f $(BASENAME)-chapter.pdf $(BASENAME)-slides.pdf $(BASENAME)-handout.pdf +cleanall : clean cleanallchapter + rm -f $(BASENAME)-slides.pdf $(BASENAME)-handout.pdf help : diff --git a/plotting/lecture/plotting-chapter.tex b/plotting/lecture/plotting-chapter.tex index 9dab40d..7498863 100644 --- a/plotting/lecture/plotting-chapter.tex +++ b/plotting/lecture/plotting-chapter.tex @@ -5,8 +5,10 @@ \lstset{inputpath=../code} \graphicspath{{images/}} -\setcounter{page}{33} -\setcounter{chapter}{1} +\typein[\pagenumber]{Number of first page} +\typein[\chapternumber]{Chapter number} +\setcounter{page}{\pagenumber} +\setcounter{chapter}{\chapternumber} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/plotting/lecture/plotting.tex b/plotting/lecture/plotting.tex index f843f6f..df502de 100644 --- a/plotting/lecture/plotting.tex +++ b/plotting/lecture/plotting.tex @@ -1,4 +1,4 @@ -\chapter{\tr{Data plotting}{Graphische Darstellung von Daten}} +\chapter{Graphische Darstellung von Daten} Die F\"ahigkeit zur ad\"aquaten Darstellung wissenschaftlicher Daten darf durchaus zu den notwendigen Kernkompetenzen gez\"ahlt werden. Wir diff --git a/pointprocesses/lecture/Makefile b/pointprocesses/lecture/Makefile index 44c7d3b..e53a65d 100644 --- a/pointprocesses/lecture/Makefile +++ b/pointprocesses/lecture/Makefile @@ -1,21 +1,12 @@ BASENAME=pointprocesses -PYFILES=$(wildcard *.py) -PYPDFFILES=$(PYFILES:.py=.pdf) - -GPTFILES=$(wildcard *.gpt) -GPTTEXFILES=$(GPTFILES:.gpt=.tex) - all: pdf slides thumbs +include ../../chapter.mk + # script: -pdf : $(BASENAME)-chapter.pdf -$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex ../../header.tex $(GPTTEXFILES) $(PYPDFFILES) - CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ - PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ - sed -i -e "s/setcounter{page}{.*}/setcounter{page}{$$PAGE}/; s/setcounter{chapter}{.*}/setcounter{chapter}{$$CHAPTER}/" $(BASENAME)-chapter.tex - pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true +pdf : chapter # slides: @@ -31,31 +22,15 @@ $(BASENAME)-handout.pdf: $(BASENAME)-slides.tex $(GPTTEXFILES) pdfnup --nup 2x4 --no-landscape --paper a4paper --trim "-1cm -1cm -1cm -1cm" --outfile $@ thumbsfoils.pdf # 1-19 rm thumbsfoils.* -watchpdf : - while true; do ! make -q pdf && make pdf; sleep 0.5; done - watchslides : while true; do ! make -q slides && make slides; sleep 0.5; done -# python plots: -$(PYPDFFILES) : %.pdf: %.py - python $< - -# gnuplot plots: -$(GPTTEXFILES) : %.tex: %.gpt whitestyles.gp - gnuplot whitestyles.gp $< - epstopdf $*.eps - -clean : - rm -f *~ - rm -f $(BASENAME).aux $(BASENAME).log - rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out +clean : cleanchapter rm -f $(BASENAME)-slides.aux $(BASENAME)-slides.log $(BASENAME)-slides.out $(BASENAME)-slides.toc $(BASENAME)-slides.nav $(BASENAME)-slides.snm $(BASENAME)-slides.vrb - rm -f $(PYPDFFILES) $(GPTTEXFILES) -cleanall : clean - rm -f $(BASENAME)-chapter.pdf $(BASENAME)-slides.pdf $(BASENAME)-handout.pdf +cleanall : clean cleanchapter + $(BASENAME)-slides.pdf $(BASENAME)-handout.pdf help : diff --git a/pointprocesses/lecture/pointprocesses-chapter.tex b/pointprocesses/lecture/pointprocesses-chapter.tex index 3dfc545..f9f25a7 100644 --- a/pointprocesses/lecture/pointprocesses-chapter.tex +++ b/pointprocesses/lecture/pointprocesses-chapter.tex @@ -5,8 +5,10 @@ \lstset{inputpath=../code} \graphicspath{{figures/}} -\setcounter{page}{99} -\setcounter{chapter}{7} +\typein[\pagenumber]{Number of first page} +\typein[\chapternumber]{Chapter number} +\setcounter{page}{\pagenumber} +\setcounter{chapter}{\chapternumber} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/pointprocesses/lecture/pointprocessscetchA.eps b/pointprocesses/lecture/pointprocessscetchA.eps index de57b17..3b37567 100644 --- a/pointprocesses/lecture/pointprocessscetchA.eps +++ b/pointprocesses/lecture/pointprocessscetchA.eps @@ -1,7 +1,7 @@ %!PS-Adobe-2.0 EPSF-2.0 %%Title: pointprocessscetchA.tex %%Creator: gnuplot 4.6 patchlevel 4 -%%CreationDate: Mon Nov 23 13:45:26 2015 +%%CreationDate: Sat Nov 28 12:01:31 2015 %%DocumentFonts: %%BoundingBox: 50 50 373 135 %%EndComments @@ -430,10 +430,10 @@ SDict begin [ /Title (pointprocessscetchA.tex) /Subject (gnuplot plot) /Creator (gnuplot 4.6 patchlevel 4) - /Author (grewe) + /Author (jan) % /Producer (gnuplot) % /Keywords () - /CreationDate (Mon Nov 23 13:45:26 2015) + /CreationDate (Sat Nov 28 12:01:31 2015) /DOCINFO pdfmark end } ifelse diff --git a/pointprocesses/lecture/pointprocessscetchA.pdf b/pointprocesses/lecture/pointprocessscetchA.pdf index 57b8447..e77278a 100644 Binary files a/pointprocesses/lecture/pointprocessscetchA.pdf and b/pointprocesses/lecture/pointprocessscetchA.pdf differ diff --git a/pointprocesses/lecture/pointprocessscetchB.eps b/pointprocesses/lecture/pointprocessscetchB.eps index ab1db53..e3199ee 100644 --- a/pointprocesses/lecture/pointprocessscetchB.eps +++ b/pointprocesses/lecture/pointprocessscetchB.eps @@ -1,7 +1,7 @@ %!PS-Adobe-2.0 EPSF-2.0 %%Title: pointprocessscetchB.tex %%Creator: gnuplot 4.6 patchlevel 4 -%%CreationDate: Mon Nov 23 13:46:59 2015 +%%CreationDate: Sat Nov 28 12:01:32 2015 %%DocumentFonts: %%BoundingBox: 50 50 373 237 %%EndComments @@ -430,10 +430,10 @@ SDict begin [ /Title (pointprocessscetchB.tex) /Subject (gnuplot plot) /Creator (gnuplot 4.6 patchlevel 4) - /Author (grewe) + /Author (jan) % /Producer (gnuplot) % /Keywords () - /CreationDate (Mon Nov 23 13:46:59 2015) + /CreationDate (Sat Nov 28 12:01:32 2015) /DOCINFO pdfmark end } ifelse diff --git a/pointprocesses/lecture/pointprocessscetchB.pdf b/pointprocesses/lecture/pointprocessscetchB.pdf index ddce0a7..12d3621 100644 Binary files a/pointprocesses/lecture/pointprocessscetchB.pdf and b/pointprocesses/lecture/pointprocessscetchB.pdf differ diff --git a/programming/lecture/Makefile b/programming/lecture/Makefile index 379ae0e..41ff3c5 100644 --- a/programming/lecture/Makefile +++ b/programming/lecture/Makefile @@ -2,33 +2,13 @@ BASENAME=programming #TEXFILES=boolean_logical_indexing.tex control_structures.tex data_structures.tex plotting.tex programming_basics.tex scripts_functions.tex sta_stc.tex variables_datatypes.tex vectors_matrices.tex -PYFILES=$(wildcard *.py) -PYPDFFILES=$(PYFILES:.py=.pdf) - all : pdf -# script: -pdf : $(BASENAME)-chapter.pdf - -$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(PYPDFFILES) ../../header.tex - CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ - PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ - sed -i -e "s/setcounter{page}{.*}/setcounter{page}{$$PAGE}/; s/setcounter{chapter}{.*}/setcounter{chapter}{$$CHAPTER}/" $(BASENAME)-chapter.tex - pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true - -$(PYPDFFILES) : %.pdf : %.py - python $< +include ../../chapter.mk -clean : - rm -f *~ - rm -f $(BASENAME).aux $(BASENAME).log - rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out - rm -f $(PYPDFFILES) $(GPTTEXFILES) - -cleanall : clean - rm -f $(BASENAME)-chapter.pdf - -watchpdf : - while true; do ! make -q pdf && make pdf; sleep 0.5; done +# script: +pdf : chapter +clean : cleanchapter +cleanall : clean cleanchapter diff --git a/programming/lecture/programming-chapter.tex b/programming/lecture/programming-chapter.tex index 8eb19a1..62fce49 100644 --- a/programming/lecture/programming-chapter.tex +++ b/programming/lecture/programming-chapter.tex @@ -5,7 +5,9 @@ \lstset{inputpath=../code} \graphicspath{{images/}} -\setcounter{page}{15} +\typein[\pagenumber]{Number of first page} +\typein[\chapternumber]{Chapter number} +\setcounter{page}{3} \setcounter{chapter}{0} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/programmingstyle/code/calculateSines.m b/programmingstyle/code/calculateSines.m new file mode 100644 index 0000000..15008f8 --- /dev/null +++ b/programmingstyle/code/calculateSines.m @@ -0,0 +1,32 @@ +function sines = calculateSines(times, amplitudes, frequencies) +% Function calculates sinewaves with all combinations of +% given amplitudes and frequencies. +% +% sines = calculateSines(times, amplitudes, frequencies) +% +% Arguments: +% times : vector of times as which the sines should be computed. +% amplitudes : vector with amplitudes. +% frequencies: vector with frequencies. +% +% Returns: +% a 3-D Matrix of sinewaves, 2nd dimension represents +% the amplitudes, 3rd the frequencies. + sines = zeros(length(times), length(amplitudes), length(frequencies)); + for i = 1:length(amplitudes) + sines(:,i,:) = sinesWithFrequencies(times, amplitudes(i), frequencies); + end +end + + +function sines = sinesWithFrequencies(times, amplitude, frequencies) + sines = zeros(length(times), length(frequencies)); + for i = 1:length(frequencies) + sines(:,i) = sineWave(times, amplitude, frequencies(i)); + end +end + + +function sine = sineWave(times, amplitude, frequency) + sine = sin(2.0*pi.*times*frequency) .* amplitude; +end diff --git a/programmingstyle/code/calculate_sines.m b/programmingstyle/code/calculate_sines.m deleted file mode 100644 index 05ad1ca..0000000 --- a/programmingstyle/code/calculate_sines.m +++ /dev/null @@ -1,30 +0,0 @@ -function sines = calculate_sines(x, amplitudes, frequencies) - % Function calculates sinewaves with all combinations of - % given amplitudes and frequencies. - % Arguments: x, a vector of radiants for which the sine should be - % computed. - % amplitudes, a vector of amplitudes. - % frequencies, a vector of frequencies. - % - % Returns: a 3-D Matrix of sinewaves, 2nd dimension represents - % the amplitudes, 3rd the frequencies. - - sines = zeros(length(x), length(amplitudes), length(frequencies)); - - for i = 1:length(amplitudes) - sines(:,i,:) = sines_with_frequencies(x, amplitudes(i), frequencies); - end -end - - -function sines = sines_with_frequencies(x, amplitude, frequencies) - sines = zeros(length(x), length(frequencies)); - for i = 1:length(frequencies) - sines(:,i) = sinewave(x, amplitude, frequencies(i)); - end -end - - -function sine = sinewave(x, amplitude, frequency) - sine = sin(2 .* pi .* x *frequency) .* amplitude; -end diff --git a/programmingstyle/lecture/Makefile b/programmingstyle/lecture/Makefile index 463f202..4c7aa7c 100644 --- a/programmingstyle/lecture/Makefile +++ b/programmingstyle/lecture/Makefile @@ -1,32 +1,12 @@ BASENAME=programmingstyle -PYFILES=$(wildcard *.py) -PYPDFFILES=$(PYFILES:.py=.pdf) - all : pdf -# script: -pdf : $(BASENAME)-chapter.pdf - -$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(PYPDFFILES) ../../header.tex - CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ - PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ - sed -i -e "s/setcounter{page}{.*}/setcounter{page}{$$PAGE}/; s/setcounter{chapter}{.*}/setcounter{chapter}{$$CHAPTER}/" $(BASENAME)-chapter.tex - pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true - -$(PYPDFFILES) : %.pdf : %.py - python $< +include ../../chapter.mk -clean : - rm -f *~ - rm -f $(BASENAME).aux $(BASENAME).log - rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out - rm -f $(PYPDFFILES) $(GPTTEXFILES) - -cleanall : clean - rm -f $(BASENAME)-chapter.pdf - -watchpdf : - while true; do ! make -q pdf && make pdf; sleep 0.5; done +# script: +pdf : chapter +clean : cleanchapter +cleanall : clean cleanchapter diff --git a/programmingstyle/lecture/programmingstyle-chapter.tex b/programmingstyle/lecture/programmingstyle-chapter.tex index df8f625..58fddce 100644 --- a/programmingstyle/lecture/programmingstyle-chapter.tex +++ b/programmingstyle/lecture/programmingstyle-chapter.tex @@ -5,8 +5,10 @@ \lstset{inputpath=../code} \graphicspath{{figures/}} -\setcounter{page}{45} -\setcounter{chapter}{2} +\typein[\pagenumber]{Number of first page} +\typein[\chapternumber]{Chapter number} +\setcounter{page}{\pagenumber} +\setcounter{chapter}{\chapternumber} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/programmingstyle/lecture/programmingstyle.tex b/programmingstyle/lecture/programmingstyle.tex index 35b3c88..04eaa8c 100644 --- a/programmingstyle/lecture/programmingstyle.tex +++ b/programmingstyle/lecture/programmingstyle.tex @@ -6,14 +6,16 @@ wissenschaftlichen Erkenntnisgewinn reproduzierbar zu machen. Programme sollten so geschrieben und strukturiert sein, dass es sowohl -einem Au{\ss}enstehenden als auch einem selbst, nach ein paar Monaten, -leicht f\"allt den Programmablauf nachzuvollziehen und zu -verstehen. Saubere Programmierung zahlt sich aber in erster Linie -f\"ur den Verfasser eines Programmes aus. +einem Au{\ss}enstehenden als auch einem selbst --- nach ein paar +Wochen oder Monaten! --- leicht f\"allt den Programmablauf +nachzuvollziehen und zu verstehen. Saubere Programmierung zahlt sich +in erster Linie f\"ur einen selbst aus und macht es aber gleichzeitig +f\"ur andere Personen leichter, den Code nachzuvollziehen und zu +benutzen. Guter Programmierstil greift auf unterschiedlichen Ebenen an: \begin{enumerate} -\item Die Struktur von Programmen. +\item Die Dateistruktur von Programmen. \item Die Namensgebung von Skripten und Funktionen. \item Die Namensgebung f\"ur Variablen und Konstanten. \item Die Verwendung von Einr\"uckungen und Leerzeilen um Bl\"ocke im @@ -65,7 +67,7 @@ aktuellen Ordner nach passenden Dateien sucht (mehr Information zum \matlab-Suchpfad in Box~\ref{matlabpathbox}). \begin{figure}[tp] - \includegraphics[width=0.75\textwidth]{program_organization} + \includegraphics[width=0.82\textwidth]{program_organization} \titlecaption{\label{fileorganizationfig} M\"ogliche Organisation von Programmcode im Dateisystem.}{ F\"ur jedes Projekt werden Unterordner f\"ur die einzelnen Analysen angelegt. Auf Ebene des @@ -82,46 +84,45 @@ aktuellen Ordner nach passenden Dateien sucht (mehr Information zum (siehe Abbildung). Der \codeterm{Suchpfad} ist eine Liste von Ordnern in denen \matlab{} nach Funktionen und Skripten suchen soll. Die Suche nach der aufgerufenen Funktion wird dabei von oben - nach unten durchgef\"uhrt. Das heisst, dass es, bei - Namensgleichheit, eine Rolle spielen kann an welcher Stelle im + nach unten durchgef\"uhrt. Das heisst, dass es bei + Namensgleichheit eine Rolle spielen kann an welcher Stelle im Suchpfad der erste Treffer gefunden wird. Wichtig: \matlab{} sucht nicht rekursiv! Wenn die gew\"unschte Funktion in einem Unterordner des aktuellen Arbeitsverzeichnisses liegt, dieses aber nicht explizit im Suchpfad enthalten ist, so wird die Funktion nicht - gefunden werden. + gefunden. \vspace{2ex} - \includegraphics[width=0.75\textwidth]{search_path} + \includegraphics[width=0.9\textwidth]{search_path} \vspace{1.5ex} - Der Suchpfad kann sowohl \"uber die in der Abbildung gezeigte GUI - oder auch \"uber die Kommandozeile eingestellt werden. Die GUI - erlaubt Ordner aus dem Suchpfad zu entfernen, neue - Ordner (optional inklusive aller Unterordner) hinzuzuf\"ugen oder - die Reihenfolge der Pfade zu ver\"andern. - - Zum Wechseln des aktuelle Arbeitsverzeichnis wechseln wird das - Kommando \code{cd} verwendet. \code{which} zeigt an, in welchem Pfad - eine bestimmte Funktion gefunden wurde. Das aktuelle - Areitsverzeichnis wird durch den Aufruf \code{pwd} auf der - Kommandozeile ausgegeben. + Der Suchpfad kann sowohl \"uber die Kommandozeile mit dem Kommandos + \code{addpath()} und \code{userpath()} als auch\"uber die in der + Abbildung gezeigte GUI angezeigt und eingestellt werden. Die GUI + erlaubt Ordner aus dem Suchpfad zu entfernen, neue Ordner (optional + inklusive aller Unterordner) hinzuzuf\"ugen oder die Reihenfolge der + Pfade zu ver\"andern. + + Zum Wechseln des aktuellen Arbeitsverzeichnisses wird das Kommando + \code{cd} verwendet. \code{which} zeigt an, in welchem Pfad eine + bestimmte Funktion gefunden wurde. Das aktuelle Areitsverzeichnis + wird durch den Aufruf \code{pwd} auf der Kommandozeile ausgegeben. \end{ibox} \section{Namensgebung von Funktionen und Skripten} \matlab{} sucht Funktionen und Skripte ausschlie{\ss}lich anhand des -Namens. Dabei spielt die Gro{\ss}- und Kleinschreibung eine Rolle. Das -hei{\ss}t, dass die beiden Dateien \file{test\_funktion.m} und -\file{Test\_funktion.m} zwei unterschiedliche Funktionen benennen -k\"onnen. Diese Art der Variation des Namens ist nat\"urlich nicht -sinnvoll. Sie tr\"agt keine Information \"uber den Unterschied der -beiden Funktionen. Auch sagt der Name nahezu nichts \"uber den Zweck -der Funktion aus. +Namens. Dabei spielt die Gro{\ss}- und Kleinschreibung eine Rolle. Die +beiden Dateien \file{test\_funktion.m} und \file{Test\_Funktion.m} +zwei unterschiedliche Funktionen benennen k\"onnen. Diese Art der +Variation des Namens ist nat\"urlich nicht sinnvoll. Sie tr\"agt keine +Information \"uber den Unterschied der beiden Funktionen. Auch sagt +der Name nahezu nichts \"uber den Zweck der Funktion aus. Die Namensgebung f\"allt mitunter nicht leicht --- manchmal ist es sogar der schwierigste Aspekt des Programmierens! Ausdrucksstarke Namen zu finden lohnt sich aber. Ausdrucksstark bedeutet, dass sich -aus dem Namen ein R\"uckschluss auf den Zweck ziehen lassen sollte. +aus dem Namen R\"uckschl\"usse auf den Zweck ziehen lassen sollte. \begin{important}[Benennung von Funktionen und Skripten] Die Namen von Funktionen und Skripten sollten m\"oglichst viel \"uber @@ -158,8 +159,8 @@ F\"ur die Bennennung von Variablen und Konstanten gelten die gleichen Regeln wie f\"ur die Namen von Funktionen und Skripten. Die Maxime von gutem Programmierstil ist: \emph{``Programmcode muss lesbar sein.''}. Dabei helfen gute Namen ungemein. Auch wenn es schwer -f\"allt passende und nicht zu lange Namen zu finden, sollte einer gute -Namensgebung ernst genommen werden. +f\"allt passende und trotzdem nicht zu lange Namen zu finden, sollte +einer gute Namensgebung sehr ernst genommen werden. W\"ahrend die Namen von Funktionen und Skripten ihren Zweck beschreiben, sollten die Namen von Variablen ihren Inhalt @@ -278,14 +279,17 @@ ein v\"ollig unn\"otiger Kommentar. Bei allen vordefinierten \matlab{} Funktionen findet sich am Anfang eine Kommentarblock, der den Zweck der Funktion, die verschiedenen M\"oglichkeiten des Funktionsaufrufs und die Argumente und -R\"uckgabewerte beschreibt. Auch in eingenen Funktionen sind diese -Kommentare sehr hilfreich. Siehe Listing~\ref{localfunctions} f\"ur -ein Beispiel einer gut Dokumentierten Funktion. +R\"uckgabewerte beschreibt. Mit dem \code{help}- Befehl wird dieser +Kommentarblock angezeigt. Auch in eigenen Funktionen sind +diese Kommentare sehr wichtig. Siehe Listing~\ref{localfunctions} +f\"ur ein Beispiel einer gut dokumentierten Funktion. \begin{important}[Dokumentation von Funktionen] Funktionen m\"ussen unbedingt kommentiert werde! \begin{itemize} \item In wenigen Zeilen kurz den Zweck der Funktion beschreiben. + \item Den Funktionskopf nocheinmal hinschreiben, damit + klar ist, in welcher Reihenfolge Argumente \"ubergeben werden. \item F\"ur jedes Funktionsargument die Bedeutung, der erwartete Datentyp (Zahl, Vektor, Matrix, etc.), und eventuell die Einheit, in der die Zahlen erwartet werden (z.B. Sekunden). @@ -333,7 +337,7 @@ lokale Funktion. \pagebreak[3] \lstinputlisting[label=localfunctions, caption={Beispiel f\"ur den - Einsatz von lokalen Funktionen.}]{calculate_sines.m} + Einsatz von lokalen Funktionen.}]{calculateSines.m} Lokale Funktionen existieren in der gleichen Datei und sind nur dort verf\"ugbar. Jede Funktion hat ihren eigenen G\"ultigkeitsbereich, das @@ -415,6 +419,6 @@ werden. Wenn diese nicht von globalem Interesse sind, kann mit Funktionen} die \"Ubersichtlichkeit erh\"oht werden. \noindent Es lohnt sich auf den eigenen Programmierstil zu -achten!\footnote{Literatur zum Programmierstil: z.B. Robert C. Martin: +achten!\footnote{Buchtip: Robert C. Martin: \textit{Clean Code: A Handbook of Agile Software Craftmanship}, Prentice Hall} diff --git a/regression/lecture/Makefile b/regression/lecture/Makefile index 1f7271d..0347e31 100644 --- a/regression/lecture/Makefile +++ b/regression/lecture/Makefile @@ -1,32 +1,12 @@ BASENAME=regression -PYFILES=$(wildcard *.py) -PYPDFFILES=$(PYFILES:.py=.pdf) - all : pdf -# script: -pdf : $(BASENAME)-chapter.pdf - -$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(PYPDFFILES) - CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ - PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ - sed -i -e "s/setcounter{page}{.*}/setcounter{page}{$$PAGE}/; s/setcounter{chapter}{.*}/setcounter{chapter}{$$CHAPTER}/" $(BASENAME)-chapter.tex - pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true - -$(PYPDFFILES) : %.pdf : %.py - python $< +include ../../chapter.mk -clean : - rm -f *~ - rm -f $(BASENAME).aux $(BASENAME).log - rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out - rm -f $(PYPDFFILES) $(GPTTEXFILES) - -cleanall : clean - rm -f $(BASENAME)-chapter.pdf - -watchpdf : - while true; do ! make -q pdf && make pdf; sleep 0.5; done +# script: +pdf : chapter +clean : cleanchapter +cleanall : clean cleanchapter diff --git a/regression/lecture/regression-chapter.tex b/regression/lecture/regression-chapter.tex index 27ab07c..0c37634 100644 --- a/regression/lecture/regression-chapter.tex +++ b/regression/lecture/regression-chapter.tex @@ -5,8 +5,10 @@ \lstset{inputpath=../code} \graphicspath{{figures/}} -\setcounter{page}{77} -\setcounter{chapter}{5} +\typein[\pagenumber]{Number of first page} +\typein[\chapternumber]{Chapter number} +\setcounter{page}{\pagenumber} +\setcounter{chapter}{\chapternumber} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/statistics/lecture/Makefile b/statistics/lecture/Makefile index 7cc97e2..ab88f11 100644 --- a/statistics/lecture/Makefile +++ b/statistics/lecture/Makefile @@ -1,32 +1,12 @@ BASENAME=statistics -PYFILES=$(wildcard *.py) -PYPDFFILES=$(PYFILES:.py=.pdf) - all : pdf -# script: -pdf : $(BASENAME)-chapter.pdf - -$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(PYPDFFILES) ../../header.tex - CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ - PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ - sed -i -e "s/setcounter{page}{.*}/setcounter{page}{$$PAGE}/; s/setcounter{chapter}{.*}/setcounter{chapter}{$$CHAPTER}/" $(BASENAME)-chapter.tex - pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true - -$(PYPDFFILES) : %.pdf : %.py - python $< +include ../../chapter.mk -clean : - rm -f *~ - rm -f $(BASENAME).aux $(BASENAME).log - rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out - rm -f $(PYPDFFILES) $(GPTTEXFILES) - -cleanall : clean - rm -f $(BASENAME)-chapter.pdf - -watchpdf : - while true; do ! make -q pdf && make pdf; sleep 0.5; done +# script: +pdf : chapter +clean : cleanchapter +cleanall : clean cleanchapter diff --git a/statistics/lecture/statistics-chapter.tex b/statistics/lecture/statistics-chapter.tex index fee3bac..1a87fc8 100644 --- a/statistics/lecture/statistics-chapter.tex +++ b/statistics/lecture/statistics-chapter.tex @@ -5,8 +5,10 @@ \lstset{inputpath=../code} \graphicspath{{figures/}} -\setcounter{page}{57} -\setcounter{chapter}{3} +\typein[\pagenumber]{Number of first page} +\typein[\chapternumber]{Chapter number} +\setcounter{page}{\pagenumber} +\setcounter{chapter}{\chapternumber} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%