diff --git a/exo2/.SRCINFO b/exo2/.SRCINFO new file mode 100644 index 0000000..e69de29 diff --git a/exo2/FArcEllipse.m b/exo2/FArcEllipse.m new file mode 100644 index 0000000..fc3781b --- /dev/null +++ b/exo2/FArcEllipse.m @@ -0,0 +1,34 @@ +classdef FArcEllipse < FEllipse + properties + angles + end + methods + function obj=FArcEllipse(a,b,angles,C) + obj = obj@FEllipse(a,b,C); + + obj.angles = zeros(1,2); + + % shift form -pi to pi + obj.angles(1) = rem(angles(1), 2*pi); + obj.angles(2) = rem(angles(2), 2*pi); + + while obj.angles(2) < obj.angles(1) + obj.angles(2) = obj.angles(2) + 2 * pi; + end + + % adjust boundaries + if obj.angles(2) < obj.angles(1) + obj.angles(2) = obj.angles(2) + 2 * pi; + end + end + + function flag=inside(obj,x,y) + flag = inside@FEllipse(obj,x,y); + ang = atan2((y - obj.Cy) / obj.b, (x - obj.Cx) / obj.a); + while ang < obj.angles(1) + ang = ang + 2 * pi; + end + flag = flag & (ang < obj.angles(2)); + end + end +end diff --git a/exo2/FBandPassFilter.m b/exo2/FBandPassFilter.m new file mode 100644 index 0000000..7372927 --- /dev/null +++ b/exo2/FBandPassFilter.m @@ -0,0 +1,15 @@ +classdef FBandPassFilter < FFilter + methods + % band = [lower, upper] normalized as an image radius + % angles = [lower, upper] angular,region to check + function obj=FBandPassFilter(band, angles) + angles = [angles(2), angles(1) + pi; angles(2) + pi, angles(1)]; + doms = {{FEllipse(band(2), band(2), [0,0]), false}, ... + {FEllipse(band(1), band(1), [0,0]), true}, ... + {FArcEllipse(1, 1, angles(1,:), [0,0]), true}, ... + {FArcEllipse(1, 1, angles(2,:), [0,0]), true}}; + + obj = obj@FFilter(doms); + end + end +end diff --git a/exo2/FDiscMap.m b/exo2/FDiscMap.m new file mode 100644 index 0000000..fb28686 --- /dev/null +++ b/exo2/FDiscMap.m @@ -0,0 +1,31 @@ +% discretized map image +classdef FDiscMap + properties + data % data set + Nx % size along X + Ny % size along Y + Cx % center point X + Cy % center point Y + end + methods + function obj=FDiscMap(data) + obj.data = data; % take referencies of the data + S = double(size(data)); + obj.Nx = S(2); + obj.Ny = S(1); + obj.Cx = obj.Nx / 2.0 + 1.0; % offset 1 + obj.Cy = obj.Ny / 2.0 + 1.0; % offset 1 + end + function [i,j]=pixel(obj,x,y) + % first comp = Y + % second comp = X + i = int32(- (obj.Ny - 1) * y / 2 + obj.Cy); + j = int32((obj.Nx - 1) * x / 2 + obj.Cx); + end + % i <-> y, j <-> x + function [x,y]=point(obj,i,j) + x = (double(j) - obj.Cx) * 2 / (obj.Nx - 1); + y = -(double(i) - obj.Cy) * 2 / (obj.Ny - 1); + end + end +end diff --git a/exo2/FDomain.m b/exo2/FDomain.m new file mode 100644 index 0000000..029d01a --- /dev/null +++ b/exo2/FDomain.m @@ -0,0 +1,6 @@ +classdef (Abstract) FDomain + methods (Abstract) + % abstract method, check if point is inside the domain + inside(obj,x,y) + end +end diff --git a/exo2/FEllipse.m b/exo2/FEllipse.m new file mode 100644 index 0000000..8f6481b --- /dev/null +++ b/exo2/FEllipse.m @@ -0,0 +1,23 @@ +classdef FEllipse < FDomain + properties + a % horizontal semi-axis + b % vertical semi-axis + Cx % centre x + Cy % centre y + end + methods + % constructor + function obj=FEllipse(a,b,C) + obj.a = a; + obj.b = b; + obj.Cx = C(1); % copy array + obj.Cy = C(2); + end + + % inside method override + function flag=inside(obj,x,y) + % ellipse equation + flag = ((x - obj.Cx) / obj.a)^2 + ((y - obj.Cy) / obj.b)^2 < 1; + end + end +end diff --git a/exo2/FFilter.m b/exo2/FFilter.m new file mode 100644 index 0000000..f1100ae --- /dev/null +++ b/exo2/FFilter.m @@ -0,0 +1,60 @@ +% collect domains to filter, then apply +classdef FFilter + properties + domains {} % cell of domains to verify + % each element of the cell is composed by + % an array [dom, flag] where: + % dom = domain of filtering + % flag = invert if false (apply domain filtering for all points outside the domain instead of inside) + end + methods + function obj=FFilter(domains) + K = length(domains); + obj.domains = cell(K); + % verify domain integrity + for k=1:K + if length(domains{k}) == 2 + obj.domains{k} = {domains{k}{1}, domains{k}{2}}; + else + warning('Invalid input, skipping it') + obj.domains = obj.domains{1:end-1}; + end + end + end + % add a specific domain with the corresponding flag + function add(obj,dom,flag) + obj.domains = {obj.domains, [dom, flag]}; + end + + % img = a discmap object + function out=apply(obj, img) + [Ni, Nj] = size(img); % get image boundaries + map = FDiscMap(img); % create a discrete map of the image + out = zeros(Ni,Nj); + minval = min(min(img)); + for i=1:Ni + for j=1:Nj + [x,y] = map.point(i,j); % get corresponding point + if obj.mustfilter(x,y) + out(i,j) = minval; % apply filter, minval supports log scaling + else + out(i,j) = img(i,j); % don't apply + end + end + end + end + % find whether the point is inside at least one of the specific domains + function match=mustfilter(obj,x,y) + match = false; + K = length(obj.domains); + k = 1; + while k <= K && ~match + dom = obj.domains{k}{1}; + flag = obj.domains{k}{2}; + % oscure if + match = match | ~xor(dom.inside(x,y), flag); + k = k + 1; + end + end + end +end diff --git a/exo2/FSquare.m b/exo2/FSquare.m new file mode 100644 index 0000000..cbdb8b0 --- /dev/null +++ b/exo2/FSquare.m @@ -0,0 +1,24 @@ +classdef FSquare < FDomain + properties + Bx {0.0} % bottom-left x + By {0.0} % bottom-left y + Tx {1.0} % top-right x + Ty {1.0} % top-right y + end + methods + % constructor + function obj=FSquare(B, T) + if T(1) < B(1) | T(2) < B(2) + warning('Square construction: Top corner is less than bottom corner') + end + obj.Bx = B(1); + obj.By = B(2); + obj.Tx = T(1); + obj.Ty = T(2); + end + % inside method override + function flag=inside(obj,x,y) + flag = (obj.x < Tx) & (obj.x > Bx) & (obj.y < Ty) & (obj.y > By); + end + end +end diff --git a/exo2/Lecture3.pdf b/exo2/Lecture3.pdf new file mode 100644 index 0000000..7133472 Binary files /dev/null and b/exo2/Lecture3.pdf differ diff --git a/exo2/analyseimg.m b/exo2/analyseimg.m new file mode 100644 index 0000000..0b2a775 --- /dev/null +++ b/exo2/analyseimg.m @@ -0,0 +1,37 @@ +filename = "stm.png"; + +%filter = @(L) region_filter(region_filter(L, [0, 0.5 - 0.005], [1, 0.5 + 0.005]), [0.5 - 0.005, 0], [0.5 + 0.005, 1]); +%filter = @(L) ellipt_filter(L, 0.01, 0.01, [0.5, 0.5]); +%filter = @(L) ellipt_ifilter(L, 0.05, 0.05, [0.5, 0.5]); +%filter = @(L) ellipt_ifilter(region_ifilter(L, [0.5 - 0.01, 0], [0.5 + 0.01, 1]), 0.05, 0.05, [0.5, 0.5]); + +rgbimage = imread(filename); +grayimg = rgb2gray(rgbimage); + +fftimg = fftshift(fft2(grayimg)); + +%filtfftimg = filter(fftimg); +filt = FBandPassFilter([0.04, 0.12], [pi/2 - 0.3, pi/2 + 0.3]); +filtfftimg = filt.apply(fftimg); + +filtimg = ifft2(fftshift(filtfftimg)); + +figure +imshow(grayimg) + +figure +imshow(contrast(log(abs(fftimg)))) + +figure +imshow(contrast(filt.apply(log(abs(fftimg))))) + +figure +imshow(contrast(abs(filtimg))) + +function out=contrast(L) + % renormalize + minval = min(min(L)); + maxval = max(max(L)); + + out = uint8((L - minval) * 255 / (maxval - minval)); +end diff --git a/exo2/angular_filter.m b/exo2/angular_filter.m new file mode 100644 index 0000000..c69b25d --- /dev/null +++ b/exo2/angular_filter.m @@ -0,0 +1,3 @@ +% angles = angles [a1, a2] bounded from 0 to 2 * pi, C = center +function out=angular_filter(L, angles, C) + diff --git a/exo2/ellipt_filter.m b/exo2/ellipt_filter.m new file mode 100644 index 0000000..f577910 --- /dev/null +++ b/exo2/ellipt_filter.m @@ -0,0 +1,20 @@ +function out=ellipt_filter(L, a, b, C) + [Ni, Nj] = size(L); + out = L(:,:); + Na = int32((Nj-1) * a); % x + Nb = int32((Ni-1) * b); % y + C = [int32((Nj-1) * C(1)), int32((Ni-1) * C(2))]; % center + % ellipse parametrisation + ellipt = @(x) int32(Nb * sqrt(1.0 - (double(x - C(2))/double(Na))^2)); + xmin = C(2) - Na + 1; + xmax = C(2) + Na + 1; + % loop through x + for i=xmin:xmax + range = ellipt(double(i-1)); + ymin = C(1) - range + 1; + ymax = C(1) + range + 1; + for j=ymin:ymax + out(j,i) = 0; + end + end +end diff --git a/exo2/ellipt_ifilter.m b/exo2/ellipt_ifilter.m new file mode 100644 index 0000000..6e795ef --- /dev/null +++ b/exo2/ellipt_ifilter.m @@ -0,0 +1,20 @@ +function out=ellipt_ifilter(L, a, b, C) + [Ni, Nj] = size(L); + out = zeros(Ni, Nj); + Na = int32((Nj-1) * a); % x + Nb = int32((Ni-1) * b); % y + C = [int32((Nj-1) * C(1)), int32((Ni-1) * C(2))]; % center + % ellipse parametrisation + ellipt = @(x) int32(Nb * sqrt(1.0 - (double(x - C(2))/double(Na))^2)); + xmin = C(2) - Na + 1; + xmax = C(2) + Na + 1; + % loop through x + for i=xmin:xmax + range = ellipt(double(i-1)); + ymin = C(1) - range + 1; + ymax = C(1) + range + 1; + for j=ymin:ymax + out(j,i) = L(j,i); + end + end +end diff --git a/exo2/exercises4_5.pdf b/exo2/exercises4_5.pdf index 81eabdc..00caaff 100644 Binary files a/exo2/exercises4_5.pdf and b/exo2/exercises4_5.pdf differ diff --git a/exo2/fourier.aux b/exo2/fourier.aux new file mode 100644 index 0000000..fd2ede0 --- /dev/null +++ b/exo2/fourier.aux @@ -0,0 +1,33 @@ +\relax +\citation{stubbe} +\citation{stubbe} +\@writefile{toc}{\contentsline {section}{Introduction}{3}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{Theoretical basis}{3}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{The fourier transform}{3}\protected@file@percent } +\@writefile{toc}{\contentsline {paragraph}{Definition in $L^2$}{3}\protected@file@percent } +\newlabel{defnt}{{1}{3}} +\@writefile{toc}{\contentsline {paragraph}{Properties}{3}\protected@file@percent } +\@writefile{toc}{\contentsline {paragraph}{Convolution definition and theorem}{3}\protected@file@percent } +\newlabel{convolution}{{2}{3}} +\newlabel{conv_thm}{{3}{3}} +\@writefile{toc}{\contentsline {section}{Discrete Fourier transform}{3}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{Discretization}{3}\protected@file@percent } +\newlabel{dft_deriv}{{4}{4}} +\newlabel{dft_fake}{{5}{4}} +\newlabel{inverse_dft}{{6}{4}} +\newlabel{dft}{{7}{4}} +\@writefile{toc}{\contentsline {section}{\textit {Matlab} implementation}{4}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{Problem 1}{5}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{(1) Straigh forward implementation}{5}\protected@file@percent } +\newlabel{mydft}{{1}{5}} +\@writefile{lol}{\contentsline {lstlisting}{\numberline {1}A \textit {matlab} implementation of the DFT}{5}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{(2) Testing}{5}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{(3)}{5}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{(4)}{5}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{Problem 2}{6}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{(1) Straigh forward implementation of the inverse DFT}{6}\protected@file@percent } +\newlabel{mydftinverse}{{2}{6}} +\@writefile{lol}{\contentsline {lstlisting}{\numberline {2}A \textit {matlab} implementation of the inverse DFT}{6}\protected@file@percent } +\newlabel{LastPage}{{}{6}} +\xdef\lastpage@lastpage{6} +\gdef\lastpage@lastpageHy{} diff --git a/exo2/fourier.log b/exo2/fourier.log new file mode 100644 index 0000000..e68f783 --- /dev/null +++ b/exo2/fourier.log @@ -0,0 +1,506 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Arch Linux) (preloaded format=pdflatex 2020.3.10) 25 MAR 2020 16:36 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**fourier.tex +(./fourier.tex +LaTeX2e <2019-10-01> patch level 1 +(/usr/share/texmf-dist/tex/latex/base/article.cls +Document Class: article 2019/08/27 v1.4j Standard LaTeX document class +(/usr/share/texmf-dist/tex/latex/base/size10.clo +File: size10.clo 2019/08/27 v1.4j Standard LaTeX file (size option) +) +\c@part=\count80 +\c@section=\count81 +\c@subsection=\count82 +\c@subsubsection=\count83 +\c@paragraph=\count84 +\c@subparagraph=\count85 +\c@figure=\count86 +\c@table=\count87 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +(/usr/share/texmf-dist/tex/latex/amsmath/amsmath.sty +Package: amsmath 2019/04/01 v2.17c AMS math features +\@mathmargin=\skip43 + +For additional information on amsmath, use the `?' option. +(/usr/share/texmf-dist/tex/latex/amsmath/amstext.sty +Package: amstext 2000/06/29 v2.01 AMS text + +(/usr/share/texmf-dist/tex/latex/amsmath/amsgen.sty +File: amsgen.sty 1999/11/30 v2.0 generic functions +\@emptytoks=\toks14 +\ex@=\dimen103 +)) +(/usr/share/texmf-dist/tex/latex/amsmath/amsbsy.sty +Package: amsbsy 1999/11/29 v1.2d Bold Symbols +\pmbraise@=\dimen104 +) +(/usr/share/texmf-dist/tex/latex/amsmath/amsopn.sty +Package: amsopn 2016/03/08 v2.02 operator names +) +\inf@bad=\count88 +LaTeX Info: Redefining \frac on input line 227. +\uproot@=\count89 +\leftroot@=\count90 +LaTeX Info: Redefining \overline on input line 389. +\classnum@=\count91 +\DOTSCASE@=\count92 +LaTeX Info: Redefining \ldots on input line 486. +LaTeX Info: Redefining \dots on input line 489. +LaTeX Info: Redefining \cdots on input line 610. +\Mathstrutbox@=\box27 +\strutbox@=\box28 +\big@size=\dimen105 +LaTeX Font Info: Redeclaring font encoding OML on input line 733. +LaTeX Font Info: Redeclaring font encoding OMS on input line 734. +\macc@depth=\count93 +\c@MaxMatrixCols=\count94 +\dotsspace@=\muskip10 +\c@parentequation=\count95 +\dspbrk@lvl=\count96 +\tag@help=\toks15 +\row@=\count97 +\column@=\count98 +\maxfields@=\count99 +\andhelp@=\toks16 +\eqnshift@=\dimen106 +\alignsep@=\dimen107 +\tagshift@=\dimen108 +\tagwidth@=\dimen109 +\totwidth@=\dimen110 +\lineht@=\dimen111 +\@envbody=\toks17 +\multlinegap=\skip44 +\multlinetaggap=\skip45 +\mathdisplay@stack=\toks18 +LaTeX Info: Redefining \[ on input line 2855. +LaTeX Info: Redefining \] on input line 2856. +) +(/usr/share/texmf-dist/tex/latex/amsfonts/amsfonts.sty +Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support +\symAMSa=\mathgroup4 +\symAMSb=\mathgroup5 +LaTeX Font Info: Redeclaring math symbol \hbar on input line 98. +LaTeX Font Info: Overwriting math alphabet `\mathfrak' in version `bold' +(Font) U/euf/m/n --> U/euf/b/n on input line 106. +) +(/usr/share/texmf-dist/tex/latex/amscls/amsthm.sty +Package: amsthm 2017/10/31 v2.20.4 +\thm@style=\toks19 +\thm@bodyfont=\toks20 +\thm@headfont=\toks21 +\thm@notefont=\toks22 +\thm@headpunct=\toks23 +\thm@preskip=\skip46 +\thm@postskip=\skip47 +\thm@headsep=\skip48 +\dth@everypar=\toks24 +) +(/usr/share/texmf-dist/tex/latex/amsfonts/amssymb.sty +Package: amssymb 2013/01/14 v3.01 AMS font symbols +) +(/usr/share/texmf-dist/tex/latex/setspace/setspace.sty +Package: setspace 2011/12/19 v6.7a set line spacing +) +(/usr/share/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty +Package: fancyhdr 2019/01/31 v3.10 Extensive control of page headers and footer +s +\f@nch@headwidth=\skip49 +\f@nch@O@elh=\skip50 +\f@nch@O@erh=\skip51 +\f@nch@O@olh=\skip52 +\f@nch@O@orh=\skip53 +\f@nch@O@elf=\skip54 +\f@nch@O@erf=\skip55 +\f@nch@O@olf=\skip56 +\f@nch@O@orf=\skip57 +) +(/usr/local/share/texmf/tex/latex/lastpage/lastpage.sty +Package: lastpage 2015/03/29 v1.2m Refers to last page's name (HMM; JPG) +) +(/usr/share/texmf-dist/tex/latex/fancyhdr/extramarks.sty +Package: extramarks 2019/01/31 v3.10 Extra marks for LaTeX +\@temptokenb=\toks25 +) +(/usr/local/share/texmf/tex/latex/changepage/chngpage.sty +Package: chngpage 2009/10/20 v1.2b change page layout +\c@cp@cnt=\count100 +\c@cp@tempcnt=\count101 +) +(/usr/local/share/texmf/tex/latex/soul/soul.sty +Package: soul 2003/11/17 v2.4 letterspacing/underlining (mf) +\SOUL@word=\toks26 +\SOUL@lasttoken=\toks27 +\SOUL@cmds=\toks28 +\SOUL@buffer=\toks29 +\SOUL@token=\toks30 +\SOUL@spaceskip=\skip58 +\SOUL@ttwidth=\dimen112 +\SOUL@uldp=\dimen113 +\SOUL@ulht=\dimen114 +) +(/usr/share/texmf-dist/tex/latex/graphics/color.sty +Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC) + +(/usr/share/texmf-dist/tex/latex/graphics-cfg/color.cfg +File: color.cfg 2016/01/02 v1.6 sample color configuration +) +Package color Info: Driver file: pdftex.def on input line 147. + +(/usr/share/texmf-dist/tex/latex/graphics-def/pdftex.def +File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex +) +(/usr/share/texmf-dist/tex/latex/graphics/dvipsnam.def +File: dvipsnam.def 2016/06/17 v3.0m Driver-dependent file (DPC,SPQR) +)) +(/usr/share/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR) + +(/usr/share/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2014/10/28 v1.15 key=value parser (DPC) +\KV@toks@=\toks31 +) +(/usr/share/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2019/10/08 v1.3c Standard LaTeX Graphics (DPC,SPQR) + +(/usr/share/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 2016/01/03 v1.10 sin cos tan (DPC) +) +(/usr/share/texmf-dist/tex/latex/graphics-cfg/graphics.cfg +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 105. +) +\Gin@req@height=\dimen115 +\Gin@req@width=\dimen116 +) +(/usr/share/texmf-dist/tex/latex/float/float.sty +Package: float 2001/11/08 v1.3d Float enhancements (AL) +\c@float@type=\count102 +\float@exts=\toks32 +\float@box=\box29 +\@float@everytoks=\toks33 +\@floatcapt=\box30 +) +(/usr/local/share/texmf/tex/latex/wrapfig/wrapfig.sty +\wrapoverhang=\dimen117 +\WF@size=\dimen118 +\c@WF@wrappedlines=\count103 +\WF@box=\box31 +\WF@everypar=\toks34 +Package: wrapfig 2003/01/31 v 3.6 +) +(/usr/share/texmf-dist/tex/latex/base/ifthen.sty +Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC) +) +(/usr/share/texmf-dist/tex/latex/listings/listings.sty +\lst@mode=\count104 +\lst@gtempboxa=\box32 +\lst@token=\toks35 +\lst@length=\count105 +\lst@currlwidth=\dimen119 +\lst@column=\count106 +\lst@pos=\count107 +\lst@lostspace=\dimen120 +\lst@width=\dimen121 +\lst@newlines=\count108 +\lst@lineno=\count109 +\lst@maxwidth=\dimen122 + +(/usr/share/texmf-dist/tex/latex/listings/lstmisc.sty +File: lstmisc.sty 2019/09/10 1.8c (Carsten Heinz) +\c@lstnumber=\count110 +\lst@skipnumbers=\count111 +\lst@framebox=\box33 +) +(/usr/share/texmf-dist/tex/latex/listings/listings.cfg +File: listings.cfg 2019/09/10 1.8c listings configuration +)) +Package: listings 2019/09/10 1.8c (Carsten Heinz) + +(/usr/share/texmf-dist/tex/latex/psnfss/courier.sty +Package: courier 2005/04/12 PSNFSS-v9.2a (WaS) +) +(/usr/share/texmf-dist/tex/latex/mathtools/mathtools.sty +Package: mathtools 2019/07/31 v1.22 mathematical typesetting tools + +(/usr/share/texmf-dist/tex/latex/tools/calc.sty +Package: calc 2017/05/25 v4.3 Infix arithmetic (KKT,FJ) +\calc@Acount=\count112 +\calc@Bcount=\count113 +\calc@Adimen=\dimen123 +\calc@Bdimen=\dimen124 +\calc@Askip=\skip59 +\calc@Bskip=\skip60 +LaTeX Info: Redefining \setlength on input line 80. +LaTeX Info: Redefining \addtolength on input line 81. +\calc@Ccount=\count114 +\calc@Cskip=\skip61 +) +(/usr/share/texmf-dist/tex/latex/mathtools/mhsetup.sty +Package: mhsetup 2017/03/31 v1.3 programming setup (MH) +) +LaTeX Info: Thecontrolsequence`\('isalreadyrobust on input line 129. +LaTeX Info: Thecontrolsequence`\)'isalreadyrobust on input line 129. +LaTeX Info: Thecontrolsequence`\['isalreadyrobust on input line 129. +LaTeX Info: Thecontrolsequence`\]'isalreadyrobust on input line 129. +\g_MT_multlinerow_int=\count115 +\l_MT_multwidth_dim=\dimen125 +\origjot=\skip62 +\l_MT_shortvdotswithinadjustabove_dim=\dimen126 +\l_MT_shortvdotswithinadjustbelow_dim=\dimen127 +\l_MT_above_intertext_sep=\dimen128 +\l_MT_below_intertext_sep=\dimen129 +\l_MT_above_shortintertext_sep=\dimen130 +\l_MT_below_shortintertext_sep=\dimen131 +) +(/usr/local/share/texmf/tex/latex/was/gensymb.sty +Package: gensymb 2003/07/02 v1.0 (WaS) +) +(/usr/local/share/texmf/tex/latex/scalerel/scalerel.sty +Package: scalerel 2016/12/29 v1.8 Routines for constrained scaling and stretchi +ng of objects, relative to a reference object or in absolute terms + +(/usr/share/texmf-dist/tex/latex/etoolbox/etoolbox.sty +Package: etoolbox 2019/09/21 v2.5h e-TeX tools for LaTeX (JAW) +\etb@tempcnta=\count116 +) +\thesrwidth=\skip63 +\thesrheight=\skip64 +\srblobheight=\skip65 +\srblobdepth=\skip66 +\mnxsrwidth=\skip67 +\LMex=\skip68 +\LMpt=\skip69 +) +(/usr/local/share/texmf/tex/latex/stackengine/stackengine.sty +Package: stackengine 2017/02/13 v4.01\ Stacking text and objects in convenient +ways + +(/usr/share/texmf-dist/tex/generic/listofitems/listofitems.sty +(/usr/share/texmf-dist/tex/generic/listofitems/listofitems.tex +\loi_cnt_foreach_nest=\count117 +\loi_nestcnt=\count118 +) +Package: listofitems 2019/08/21 v1.63 Grab items in lists using user-specified +sep char (CT) +) +\c@@stackindex=\count119 +\@boxshift=\skip70 +\stack@tmplength=\skip71 +\temp@stkl=\skip72 +\@stackedboxwidth=\skip73 +\@addedbox=\box34 +\@anchorbox=\box35 +\stackedbox=\box36 +\@centerbox=\box37 +\c@ROWcellindex@=\count120 +) +(/usr/share/texmf-dist/tex/latex/listings/lstlang1.sty +File: lstlang1.sty 2019/09/10 1.8c listings language file +) +\labelLength=\skip74 +\c@homeworkProblemCounter=\count121 +\homeworkSectionLabelLength=\skip75 + (./fourier.aux) +\openout1 = `fourier.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 250. +LaTeX Font Info: ... okay on input line 250. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 250. +LaTeX Font Info: ... okay on input line 250. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 250. +LaTeX Font Info: ... okay on input line 250. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 250. +LaTeX Font Info: ... okay on input line 250. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 250. +LaTeX Font Info: ... okay on input line 250. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 250. +LaTeX Font Info: ... okay on input line 250. +Package lastpage Info: Please have a look at the pageslts package at +(lastpage) https://www.ctan.org/pkg/pageslts +(lastpage) ! on input line 250. + +(/usr/share/texmf-dist/tex/context/base/mkii/supp-pdf.mkii +[Loading MPS to PDF converter (version 2006.09.02).] +\scratchcounter=\count122 +\scratchdimen=\dimen132 +\scratchbox=\box38 +\nofMPsegments=\count123 +\nofMParguments=\count124 +\everyMPshowfont=\toks36 +\MPscratchCnt=\count125 +\MPscratchDim=\dimen133 +\MPnumerator=\count126 +\makeMPintoPDFobject=\count127 +\everyMPtoPDFconversion=\toks37 +) (/usr/share/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty +Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf + +(/usr/share/texmf-dist/tex/generic/oberdiek/infwarerr.sty +Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO) +) +(/usr/share/texmf-dist/tex/latex/oberdiek/grfext.sty +Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO) + +(/usr/share/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty +Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO) + +(/usr/share/texmf-dist/tex/generic/oberdiek/ltxcmds.sty +Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO) +))) +(/usr/share/texmf-dist/tex/latex/oberdiek/kvoptions.sty +Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO) + +(/usr/share/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty +Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO) + +(/usr/share/texmf-dist/tex/generic/oberdiek/etexcmds.sty +Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO) + +(/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty +Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO) +Package ifluatex Info: LuaTeX not detected. +)))) +(/usr/share/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty +Package: pdftexcmds 2019/07/25 v0.30 Utility functions of pdfTeX for LuaTeX (HO +) + +(/usr/share/texmf-dist/tex/generic/oberdiek/ifpdf.sty +Package: ifpdf 2018/09/07 v3.3 Provides the ifpdf switch +) +Package pdftexcmds Info: LuaTeX not detected. +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +) +Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4 +38. +Package grfext Info: Graphics extension search list: +(grfext) [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE +G,.JBIG2,.JB2,.eps] +(grfext) \AppendGraphicsExtensions on input line 456. + +(/usr/share/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg +File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv +e +)) +\c@lstlisting=\count128 +LaTeX Info: Redefining \celsius on input line 250. +Package gensymb Info: Faking symbols for \degree and \celsius on input line 250 +. + + +Package gensymb Warning: Not defining \perthousand. + +LaTeX Info: Redefining \ohm on input line 250. +Package gensymb Info: Using \Omega for \ohm on input line 250. + +Package gensymb Warning: Not defining \micro. + +LaTeX Font Info: Trying to load font information for U+msa on input line 252 +. +(/usr/share/texmf-dist/tex/latex/amsfonts/umsa.fd +File: umsa.fd 2013/01/14 v3.01 AMS symbols A +) +LaTeX Font Info: Trying to load font information for U+msb on input line 252 +. + +(/usr/share/texmf-dist/tex/latex/amsfonts/umsb.fd +File: umsb.fd 2013/01/14 v3.01 AMS symbols B +) [1 + +{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./fourier.toc) +\tf@toc=\write3 +\openout3 = `fourier.toc'. + + [2] + +LaTeX Warning: Citation `stubbe' on page 3 undefined on input line 278. + +LaTeX Font Info: Trying to load font information for OMS+cmr on input line 2 +84. +(/usr/share/texmf-dist/tex/latex/base/omscmr.fd +File: omscmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions +) +LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10> not available +(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 284. +\tmpboxcontent=\box39 + + +LaTeX Warning: Citation `stubbe' on page 3 undefined on input line 288. + + +Underfull \hbox (badness 10000) in paragraph at lines 298--300 + + [] + +[3] [4] +LaTeX Font Info: Trying to load font information for OT1+pcr on input line 3 +81. + (/usr/share/texmf-dist/tex/latex/psnfss/ot1pcr.fd +File: ot1pcr.fd 2001/06/04 font definitions for OT1/pcr. +) (./mydft.m +LaTeX Font Info: Trying to load font information for T1+pcr on input line 2. + + +(/usr/share/texmf-dist/tex/latex/psnfss/t1pcr.fd +File: t1pcr.fd 2001/06/04 font definitions for T1/pcr. +)) +Overfull \hbox (191.7019pt too wide) in paragraph at lines 381--381 +[] $[]$ $[]$ + [] + + +Overfull \hbox (14.78941pt too wide) in paragraph at lines 381--382 +$[]$ + [] + + +Underfull \hbox (badness 10000) in paragraph at lines 381--382 + + [] + +[5] (./mydftinverse.m) +AED: lastpage setting LastPage +[6] (./fourier.aux) + +LaTeX Warning: There were undefined references. + + ) +Here is how much of TeX's memory you used: + 7104 strings out of 492167 + 93344 string characters out of 6131558 + 403800 words of memory out of 5000000 + 11312 multiletter control sequences out of 15000+600000 + 15393 words of font info for 57 fonts, out of 8000000 for 9000 + 1141 hyphenation exceptions out of 8191 + 46i,13n,45p,801b,2181s stack positions out of 5000i,500n,10000p,200000b,80000s +{/usr/share/texmf-dist/fonts/enc/dvips/base/8r.enc}</usr/share/texmf-dist/fon +ts/type1/public/amsfonts/cm/cmbx10.pfb></usr/share/texmf-dist/fonts/type1/publi +c/amsfonts/cm/cmbx12.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/ +cmbx9.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmbxti10.pfb></ +usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb></usr/share/texm +f-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texmf-dist/fonts/t +ype1/public/amsfonts/cm/cmmi5.pfb></usr/share/texmf-dist/fonts/type1/public/ams +fonts/cm/cmmi7.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10. +pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr5.pfb></usr/share/ +texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/share/texmf-dist/fonts +/type1/public/amsfonts/cm/cmr9.pfb></usr/share/texmf-dist/fonts/type1/public/am +sfonts/cm/cmsy10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy +7.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb></usr/sh +are/texmf-dist/fonts/type1/public/amsfonts/cm/cmti12.pfb></usr/share/texmf-dist +/fonts/type1/public/amsfonts/symbols/msam10.pfb></usr/share/texmf-dist/fonts/ty +pe1/public/amsfonts/symbols/msbm10.pfb></usr/share/texmf-dist/fonts/type1/urw/c +ourier/ucrr8a.pfb></usr/share/texmf-dist/fonts/type1/urw/courier/ucrro8a.pfb> +Output written on fourier.pdf (6 pages, 209482 bytes). +PDF statistics: + 104 PDF objects out of 1000 (max. 8388607) + 75 compressed objects within 1 object stream + 0 named destinations out of 1000 (max. 500000) + 1 words of extra memory for PDF output out of 10000 (max. 10000000) + diff --git a/exo2/fourier.pdf b/exo2/fourier.pdf new file mode 100644 index 0000000..f48d355 Binary files /dev/null and b/exo2/fourier.pdf differ diff --git a/exo2/fourier.tex b/exo2/fourier.tex index a26335e..4ab5676 100644 --- a/exo2/fourier.tex +++ b/exo2/fourier.tex @@ -1,266 +1,421 @@ \documentclass{article} % Change "article" to "report" to get rid of page number on title page \usepackage{amsmath,amsfonts,amsthm,amssymb} \usepackage{setspace} \usepackage{fancyhdr} \usepackage{lastpage} \usepackage{extramarks} \usepackage{chngpage} \usepackage{soul} \usepackage[usenames,dvipsnames]{color} \usepackage{graphicx,float,wrapfig} \usepackage{ifthen} \usepackage{listings} \usepackage{courier} +\usepackage{mathtools} +\usepackage{gensymb} +% definition of the absolute value +\DeclarePairedDelimiter\abs{\lvert}{\rvert} + +\usepackage{scalerel,stackengine} + +\stackMath +\newcommand\reallywidehat[1]{% +\savestack{\tmpbox}{\stretchto{% + \scaleto{% + \scalerel*[\widthof{\ensuremath{#1}}]{\kern-.6pt\bigwedge\kern-.6pt}% + {\rule[-\textheight/2]{1ex}{\textheight}}%WIDTH-LIMITED BIG WEDGE + }{\textheight}% +}{0.5ex}}% +\stackon[1pt]{#1}{\tmpbox}% +} % !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! % % Here put your info (name, due date, title etc). % the rest should be left unchanged. % % % % !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! % Homework Specific Information \newcommand{\hmwkTitle}{Report 1} \newcommand{\hmwkSubTitle}{Fourier transforms and analysis} \newcommand{\hmwkDueDate}{March 27, 2014} \newcommand{\hmwkClass}{Computational Physics III} \newcommand{\hmwkClassTime}{\today} %\newcommand{\hmwkClassInstructor}{Prof. Oleg Yazyev} \newcommand{\hmwkAuthorName}{Raffaele Ancarola} % % % In case you need to adjust margins: \topmargin=-0.45in % \evensidemargin=0in % \oddsidemargin=0in % \textwidth=6.5in % \textheight=9.5in % \headsep=0.25in % % This is the color used for comments below \definecolor{MyDarkGreen}{rgb}{0.0,0.4,0.0} % For faster processing, load Matlab syntax for listings \lstloadlanguages{Matlab}% \lstset{language=Matlab, % Use MATLAB frame=single, % Single frame around code basicstyle=\small\ttfamily, % Use small true type font keywordstyle=[1]\color{Blue}\bf, % MATLAB functions bold and blue keywordstyle=[2]\color{Purple}, % MATLAB function arguments purple keywordstyle=[3]\color{Blue}\underbar, % User functions underlined and blue identifierstyle=, % Nothing special about identifiers % Comments small dark green courier commentstyle=\usefont{T1}{pcr}{m}{sl}\color{MyDarkGreen}\small, stringstyle=\color{Purple}, % Strings are purple showstringspaces=false, % Don't put marks in string spaces tabsize=3, % 5 spaces per tab + breaklines=True, + linewidth=\textwidth, % %%% Put standard MATLAB functions not included in the default %%% language here morekeywords={xlim,ylim,var,alpha,factorial,poissrnd,normpdf,normcdf}, % %%% Put MATLAB function parameters here morekeywords=[2]{on, off, interp}, % %%% Put user defined functions here morekeywords=[3]{FindESS, homework_example}, % morecomment=[l][\color{Blue}]{...}, % Line continuation (...) like blue comment numbers=left, % Line numbers on left firstnumber=1, % Line numbers start with line 1 numberstyle=\tiny\color{Blue}, % Line numbers are blue stepnumber=1 % Line numbers go in steps of 5 } % Setup the header and footer \pagestyle{fancy} % \lhead{\hmwkAuthorName} % %\chead{\hmwkClass\ (\hmwkClassInstructor\ \hmwkClassTime): \hmwkTitle} % \rhead{\hmwkClass\ : \hmwkTitle} % %\rhead{\firstxmark} % \lfoot{\lastxmark} % \cfoot{} % \rfoot{Page\ \thepage\ of\ \protect\pageref{LastPage}} % \renewcommand\headrulewidth{0.4pt} % \renewcommand\footrulewidth{0.4pt} % % This is used to trace down (pin point) problems % in latexing a document: %\tracingall %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Some tools \newcommand{\enterProblemHeader}[1]{\nobreak\extramarks{#1}{#1 continued on next page\ldots}\nobreak% \nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak}% \newcommand{\exitProblemHeader}[1]{\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak% \nobreak\extramarks{#1}{}\nobreak}% \newlength{\labelLength} \newcommand{\labelAnswer}[2] {\settowidth{\labelLength}{#1}% \addtolength{\labelLength}{0.25in}% \changetext{}{-\labelLength}{}{}{}% \noindent\fbox{\begin{minipage}[c]{\columnwidth}#2\end{minipage}}% \marginpar{\fbox{#1}}% % We put the blank space above in order to make sure this % \marginpar gets correctly placed. \changetext{}{+\labelLength}{}{}{}}% \setcounter{secnumdepth}{0} \newcommand{\homeworkProblemName}{}% \newcounter{homeworkProblemCounter}% \newenvironment{homeworkProblem}[1][Problem \arabic{homeworkProblemCounter}]% {\stepcounter{homeworkProblemCounter}% \renewcommand{\homeworkProblemName}{#1}% \section{\homeworkProblemName}% \enterProblemHeader{\homeworkProblemName}}% {\exitProblemHeader{\homeworkProblemName}}% \newcommand{\problemAnswer}[1] {\noindent\fbox{\begin{minipage}[c]{\columnwidth}#1\end{minipage}}}% \newcommand{\problemLAnswer}[1] {\labelAnswer{\homeworkProblemName}{#1}} \newcommand{\homeworkSectionName}{}% \newlength{\homeworkSectionLabelLength}{}% \newenvironment{homeworkSection}[1]% {% We put this space here to make sure we're not connected to the above. % Otherwise the changetext can do funny things to the other margin \renewcommand{\homeworkSectionName}{#1}% \settowidth{\homeworkSectionLabelLength}{\homeworkSectionName}% \addtolength{\homeworkSectionLabelLength}{0.25in}% \changetext{}{-\homeworkSectionLabelLength}{}{}{}% \subsection{\homeworkSectionName}% \enterProblemHeader{\homeworkProblemName\ [\homeworkSectionName]}}% {\enterProblemHeader{\homeworkProblemName}% % We put the blank space above in order to make sure this margin % change doesn't happen too soon (otherwise \sectionAnswer's can % get ugly about their \marginpar placement. \changetext{}{+\homeworkSectionLabelLength}{}{}{}}% \newcommand{\sectionAnswer}[1] {% We put this space here to make sure we're disconnected from the previous % passage \noindent\fbox{\begin{minipage}[c]{\columnwidth}#1\end{minipage}}% \enterProblemHeader{\homeworkProblemName}\exitProblemHeader{\homeworkProblemName}% \marginpar{\fbox{\homeworkSectionName}}% % We put the blank space above in order to make sure this % \marginpar gets correctly placed. }% +\newcommand{\unlimwrap}[3][0.45\linewidth] + { + \begin{minipage}{1.05\linewidth} + \hspace{-0.5cm} + \begin{minipage}{#1} + #2 + \end{minipage} + \hspace{1cm} + \begin{minipage}{\linewidth} + #3 + \end{minipage} + \end{minipage} + } + %%% I think \captionwidth (commented out below) can go away %%% %% Edits the caption width %\newcommand{\captionwidth}[1]{% % \dimen0=\columnwidth \advance\dimen0 by-#1\relax % \divide\dimen0 by2 % \advance\leftskip by\dimen0 % \advance\rightskip by\dimen0 %} % Includes a figure % The first parameter is the label, which is also the name of the figure % with or without the extension (e.g., .eps, .fig, .png, .gif, etc.) % IF NO EXTENSION IS GIVEN, LaTeX will look for the most appropriate one. % This means that if a DVI (or PS) is being produced, it will look for % an eps. If a PDF is being produced, it will look for nearly anything % else (gif, jpg, png, et cetera). Because of this, when I generate figures % I typically generate an eps and a png to allow me the most flexibility % when rendering my document. % The second parameter is the width of the figure normalized to column width % (e.g. 0.5 for half a column, 0.75 for 75% of the column) % The third parameter is the caption. \newcommand{\scalefig}[3]{ \begin{figure}[ht!] % Requires \usepackage{graphicx} \centering \includegraphics[width=#2\columnwidth]{#1} %%% I think \captionwidth (see above) can go away as long as %%% \centering is above %\captionwidth{#2\columnwidth}% \caption{#3} \label{#1} \end{figure}} % Includes a MATLAB script. % The first parameter is the label, which also is the name of the script % without the .m. % The second parameter is the optional caption. +%\newcommand{\matlabscript}[2] +% {\begin{itemize}\item[]\lstinputlisting[caption=#2,label=#1]{#1.m}\end{itemize}} \newcommand{\matlabscript}[2] - {\begin{itemize}\item[]\lstinputlisting[caption=#2,label=#1]{#1.m}\end{itemize}} + {\lstinputlisting[caption=#2,label=#1]{#1.m}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Make title %\title{\vspace{2in}\textmd{\textbf{\hmwkClass:\ \hmwkTitle\ifthenelse{\equal{\hmwkSubTitle}{}}{}{\\\hmwkSubTitle}}}\\\normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate}\\\vspace{0.1in}\large{\textit{\hmwkClassInstructor\ \hmwkClassTime}}\vspace{3in}} \title{\vspace{2in}\textmd{\textbf{\hmwkClass:\ \hmwkTitle\ifthenelse{\equal{\hmwkSubTitle}{}}{}{\\\hmwkSubTitle}}}\\\normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate}\\\vspace{0.1in}\large{\textit{ \hmwkClassTime}}\vspace{3in}} \date{} \author{\textbf{\hmwkAuthorName}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \begin{spacing}{1.1} \maketitle % Uncomment the \tableofcontents and \newpage lines to get a Contents page % Uncomment the \setcounter line as well if you do NOT want subsections % listed in Contents %\setcounter{tocdepth}{1} \newpage \tableofcontents \newpage -% When problems are long, it may be desirable to put a \newpage or a -% \clearpage before each homeworkProblem environment +\section{Introduction} -\newpage +%Interpolating and analysing signals is a problem -\begin{homeworkProblem} +\section{Theoretical basis} + +\subsection{The fourier transform} + +\paragraph{Definition in $L^2$} +Let $f \in L^2(\mathbb{R})$, then it's \textit{Fourier transform} $\hat{f}$ is defined as + +\begin{align} \label{defnt} + \hat{f}(k) := \int_{-\infty}^{\infty} f(x) \cdot e^{-2 \pi k x} dx & & + f(x) := \int_{-\infty}^{\infty} \hat{f}(k) \cdot e^{2 \pi x k} dk +\end{align} + +where the second definition is called the \textit{inverse Fourier transform} and +the bijection is a consequence of $L^2(\mathbb{R})$ [\cite{stubbe}]. + +\paragraph{Properties} +The following properties can be straigh-forward demonstrated: + +\begin{itemize} + \item Linearity: $\forall f,g \in L^2, a \in \mathbb{R}: \reallywidehat{f + a \cdot g} = \hat{f} + a \cdot \hat{g}$ + \item Scaling: $\forall a \in \mathbb{R}: \reallywidehat{f(a \cdot x)} = \frac{1}{\abs*{a}} \hat{f}(\frac{k}{a})$ + \item Translation: $\forall x_0 \in \mathbb{R}: \reallywidehat{f(x - x_0)} = e^{-2 \pi i x_0 k} \hat{f}(k)$ + \item Modulation: $\forall k_0 \in \mathbb{R}: \reallywidehat{e^{2 \pi i x k_0} f(x)} = \hat{f}(k - k_0)$ + \item Parseval identity: $\forall f,g \in L^2: \langle f, g \rangle = \langle \hat{f}, \hat{g} \rangle$ where $\langle \cdot , \cdot \rangle$ is the canonical $L^2$ scalar product (see [\cite{stubbe}]) +\end{itemize} + +\paragraph{Convolution definition and theorem} +Let $f, g \in L^2(\mathbb{R})$, then the \textit{convolution} of $f$ with respect to $g$ is defined as follow: + +\begin{equation} \label{convolution} + (f \circledast g)(x) := \int_{-\infty}^{\infty} f(y)g(x - y) dy +\end{equation} + +Having listed enough properties of the \textit{Fourier transform}, it's now possible to relate these two concepts by stating the \textit{convolution} theorem: +\newline + +\begin{equation} \label{conv_thm} + \reallywidehat{f \circledast g} = \hat{f} \cdot \hat{g} +\end{equation} + +This result is very useful in its practical applications, because it allows to convert +a convolution into a product operation. -First Problem +\section{Discrete Fourier transform} - \begin{homeworkSection}{(1)} - Answer to q.1 -\matlabscript{simple}{A script which does the calculation for q.1.} - \end{homeworkSection} +The passage from the continous to a discrete expression of the Fourier transform is +necessary in order to process digital signals. The interest on doing such an elaboration +is that an analogic circuit which computes the continous +Fourier transform on a generic signal doesn't forcely exist. - \begin{homeworkSection}{(2)} - Answer to q.2 - \end{homeworkSection} +\subsection{Discretization} -\begin{homeworkSection}{(3)} - Answer to q.3 - \end{homeworkSection} +In order to pass to a discrete representation of the Fourier transform, some conventions need to be set: +\begin{itemize} + \item The signal is evaluated on a limited set of time arguments. + \item The first time of the sequence is $0$ + \item The function is supposed to be constant between one sample and another. + \item The function is zero in all other points. +\end{itemize} -\begin{homeworkSection}{(4)} - Answer to q.4 - \end{homeworkSection} +Let $\{f_n\}_{0 < n < N}$ be the signal samples derived from a function $f(x)$, where +$N$ is the total number of samples and $T$ the sampling period. +Because $\forall x \in \mathbb{R} \setminus [0, (N-1)T]: f(x) = 0$ the fourier integration domain +restricts to $[0, (N-1)T]$, then applying a discretisation on $x$, given by $x_n = nT, 0 < n < N$, +the integral reduces itself into a sum: + +\begin{equation} \label{dft_deriv} + \hat{f}(k) = \sum_{n=0}^{N-1} \int_{nT}^{(n+1)T} f_n \cdot e^{-2\pi i nT k} dx = T \sum_{n=0}^{N-1} f_n \cdot e^{-2\pi i nT k} +\end{equation} + +Then taking the indicisation of the $k$-space as $k_m = \frac{m}{NT}, 0 < m < N$, the +output results a $N$-sized set of values $\{\hat{f}_m\}_{0 < m < N}$: + +\begin{equation} \label{dft_fake} + \hat{f}_m = T \sum_{n=0}^{N-1} f_n \cdot e^{-2\pi i \frac{nm}{N}} +\end{equation} + +Notice that this expression of the discrete Fourier transform (or DFT) still depends on $T$ and since it's a scaling term, +it's presence is arbitrary and it could be removed. +In order to guaratee the application bijectivity, it's important evaluate the +inverse discrete fourier transform by taking the adjoint of the sum given in equation (\ref{dft_fake}) +on the $\{\hat{f}_m\}_{0 < m < N}$ set and setting it to $\{f_n\}_{0 < n < N}$. + +\begin{equation} \label{inverse_dft} + f_n = \frac{T}{NT} \sum_{m=0}^{N-1} \hat{f}_m \cdot e^{2\pi i \frac{nm}{N}} = \frac{1}{N} \sum_{m=0}^{N-1} \hat{f}_m \cdot e^{2\pi i \frac{nm}{N}} +\end{equation} + +The previous expression shows that the inverse DFT doesn't depend on the sampling period $T$, then +there's no reason to keep that dependency for the DFT. This consideration allows to redefine the DFT as follow: + +\begin{equation} \label{dft} + \hat{f}_m = \sum_{n=0}^{N-1} f_n \cdot e^{-2\pi i \frac{nm}{N}} +\end{equation} + +\section{\textit{Matlab} implementation} + +\newpage + +\begin{homeworkProblem} + +% When problems are long, it may be desirable to put a \newpage or a +% \clearpage before each homeworkProblem environment + + \begin{homeworkSection}{(1) Straigh forward implementation} + + \unlimwrap[0.55\linewidth]{ + Using the formulas given in the equations (\ref{inverse_dft}) and (\ref{dft}), + the resulting \textit{matlab} code for the DFT is straight forward as it + shows to listing (\ref{mydft}). + \textit{Matlab} storage system of vectors and matrices is very flexible but + it's not clear how a matrix is treated when the initialisation is handled externally. + So, in order to determine the size of the output, the best approach is to + adapt it to the input size. That's what the lines (3) and (5) do: they take the input size format + and expand it into the output initialization. + }{ + \matlabscript{mydft}{A \textit{matlab} implementation of the DFT} + } + + \end{homeworkSection} + + \begin{homeworkSection}{(2) Testing} + There are two essential aspects to check whether the algorithm works: + \begin{enumerate} + \item No bugs, all behaviours are expected + \item Lowest possible time complexity + \end{enumerate} + + Both tasks can be executed using a script which compares the code execution of (\ref{mydft}) with + the \textit{Matlab} built-in \textit{fft}. + At first glance, the complexity is supposed to be $\mathcal{O}(N^2)$ where $N$ is the size of the input array, + which is justified by the fact that the code loops $N$ times (index $j$) inside another + $N$ sized loop (index $i$). + On the other hand the \textit{Matlab} built-in function \textit{assert} helps in order to verify + that the output of \textit{mydft} and \textit{fft} correspond. + + \end{homeworkSection} \end{homeworkProblem} \newpage \begin{homeworkProblem} -Second problem.... +Second problem: Spectral and cepstral analysis + + \begin{homeworkSection}{(1) Straigh forward implementation of the inverse DFT} + \matlabscript{mydftinverse}{A \textit{matlab} implementation of the inverse DFT} + + \end{homeworkSection} \end{homeworkProblem} \end{spacing} \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/exo2/fourier.toc b/exo2/fourier.toc new file mode 100644 index 0000000..7c98df9 --- /dev/null +++ b/exo2/fourier.toc @@ -0,0 +1,16 @@ +\contentsline {section}{Introduction}{3}% +\contentsline {section}{Theoretical basis}{3}% +\contentsline {subsection}{The fourier transform}{3}% +\contentsline {paragraph}{Definition in $L^2$}{3}% +\contentsline {paragraph}{Properties}{3}% +\contentsline {paragraph}{Convolution definition and theorem}{3}% +\contentsline {section}{Discrete Fourier transform}{3}% +\contentsline {subsection}{Discretization}{3}% +\contentsline {section}{\textit {Matlab} implementation}{4}% +\contentsline {section}{Problem 1}{5}% +\contentsline {subsection}{(1) Straigh forward implementation}{5}% +\contentsline {subsection}{(2) Testing}{5}% +\contentsline {subsection}{(3)}{5}% +\contentsline {subsection}{(4)}{5}% +\contentsline {section}{Problem 2}{6}% +\contentsline {subsection}{(1) Straigh forward implementation of the inverse DFT}{6}% diff --git a/exo2/mydft.m b/exo2/mydft.m index 72da226..63ebc2c 100644 --- a/exo2/mydft.m +++ b/exo2/mydft.m @@ -1,14 +1,15 @@ function result=mydft(input_array) % convert to cell s = mat2cell(size(input_array), 1, 2); % expand into an argument list result = zeros(s{:}); N = length(result); - + for m=1:N result(m) = 0; for n=1:N - result(m) = result(m) + input_array(n) * exp(-2 * pi * 1i * (n-1) * (m-1) / N); + w = exp(-2 * pi * 1i * (n-1) * (m-1) / N); + result(m) = result(m) + input_array(n) * w; end end end diff --git a/exo2/mydftinverse.m b/exo2/mydftinverse.m index 6cb2253..6833345 100644 --- a/exo2/mydftinverse.m +++ b/exo2/mydftinverse.m @@ -1,15 +1,16 @@ function result=mydftinverse(input_array) % convert to cell s = mat2cell(size(input_array), 1, 2); % expand into an argument list result = zeros(s{:}); N = length(result); for m=1:N result(m) = 0; for n=1:N - result(m) = result(m) + input_array(n) * exp(2 * pi * 1i * (n-1) * (m-1) / N); + w = exp(2 * pi * 1i * (n-1) * (m-1) / N); + result(m) = result(m) + input_array(n) * w; end result(m) = result(m) / N; end end diff --git a/exo2/output/testmydft.out b/exo2/output/testmydft.out new file mode 100644 index 0000000..98b731c --- /dev/null +++ b/exo2/output/testmydft.out @@ -0,0 +1,18 @@ +Ns times +1024 0.007726 +2048 0.002314 +4096 0.002574 +8192 0.003421 +16384 0.010608 +32768 0.016271 +65536 0.039539 +131072 0.036993 +262144 0.048733 +524288 0.070934 +1.04858e+06 0.141809 +2.09715e+06 0.211301 +4.1943e+06 0.322412 +8.38861e+06 0.618665 +1.67772e+07 1.16364 +3.35544e+07 2.40053 +6.71089e+07 7.27462 diff --git a/exo2/region_filter.m b/exo2/region_filter.m new file mode 100644 index 0000000..5dfbcbe --- /dev/null +++ b/exo2/region_filter.m @@ -0,0 +1,12 @@ +% t = top boundary point, b = bottom boundary point +function out=region_filter(L, t, b) + [Ni, Nj] = size(L); + out = L(:,:); + abst = [int32((Nj-1) * t(1)) + 1, int32((Ni-1) * t(2)) + 1]; + absb = [int32((Nj-1) * b(1)) + 1, int32((Ni-1) * b(2)) + 1]; + for i=abst(1):absb(1) + for j=abst(2):absb(2) + out(j,i) = 0; + end + end +end diff --git a/exo2/region_ifilter.m b/exo2/region_ifilter.m new file mode 100644 index 0000000..6cd32bc --- /dev/null +++ b/exo2/region_ifilter.m @@ -0,0 +1,12 @@ +% t = top boundary point, b = bottom boundary point +function out=region_ifilter(L, t, b) + [Ni, Nj] = size(L); + out = zeros(Ni,Nj); + abst = [int32((Nj-1) * t(1)) + 1, int32((Ni-1) * t(2)) + 1]; + absb = [int32((Nj-1) * b(1)) + 1, int32((Ni-1) * b(2)) + 1]; + for i=abst(1):absb(1) + for j=abst(2):absb(2) + out(j,i) = L(j,i); + end + end +end diff --git a/exo2/stm.png b/exo2/stm.png new file mode 100644 index 0000000..1ff37a5 Binary files /dev/null and b/exo2/stm.png differ diff --git a/exo2/test.m b/exo2/test.m index ae27750..23bdce6 100644 --- a/exo2/test.m +++ b/exo2/test.m @@ -1,32 +1,52 @@ % This script tests functor.m for correctness -functor = @(x) myfft(x); +functor = @(x) mydft(x); fprintf('Test 1: Gaussian ...'); sample = exp(-linspace(-4,4,256).^2); assert(all(abs(functor(sample) - fft(sample))<1e-10)); fprintf('\tpassed\n'); fprintf('Test 1.1: Gaussian with a different Matlab dimension ...'); sample = exp(-linspace(-4,4,256).^2)'; assert(all(abs(functor(sample) - fft(sample))<1e-10)); fprintf('\tpassed\n'); fprintf('Test 1.2: Gaussian complex ...'); sample = 1i*exp(-linspace(-4,4,256).^2); assert(all(abs(functor(sample) - fft(sample))<1e-10)); fprintf('\tpassed\n'); fprintf('Test 2: sawtooth ...'); sample = linspace(-1,1,256); assert(all(abs(functor(sample) - fft(sample))<1e-10)); fprintf('\tpassed\n'); fprintf('Test 3: sin and sin2 ...'); sample = sin(linspace(-pi,pi,256)); assert(all(abs(functor(sample) - fft(sample))<1e-10)); sample = sin(2*linspace(-pi,pi,256)); assert(all(abs(functor(sample) - fft(sample))<1e-10)); fprintf('\tpassed\n'); +Ns = 10:26; +times = zeros(length(Ns),1); + +% Time complexity test +for k=Ns + fprintf('\tEvaluating step %d \n', k); + sample = exp(-linspace(-4,4,2^k).^2)'; + tic; + fft(sample); + times(k-Ns(1)+1) = toc; +end + +Ns = 2.^Ns + +figure +grid on +xlabel('N') +ylabel('Elapsed time') +loglog(Ns, times) + fprintf('All tests passed!\n'); diff --git a/exo2/texput.log b/exo2/texput.log new file mode 100644 index 0000000..81e7944 --- /dev/null +++ b/exo2/texput.log @@ -0,0 +1,21 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Arch Linux) (preloaded format=pdflatex 2020.3.10) 18 MAR 2020 09:04 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**fourier.t + +! Emergency stop. +<*> fourier.t + +End of file on the terminal! + + +Here is how much of TeX's memory you used: + 4 strings out of 492167 + 115 string characters out of 6131558 + 59016 words of memory out of 5000000 + 4468 multiletter control sequences out of 15000+600000 + 3640 words of font info for 14 fonts, out of 8000000 for 9000 + 1141 hyphenation exceptions out of 8191 + 0i,0n,0p,12b,6s stack positions out of 5000i,500n,10000p,200000b,80000s +! ==> Fatal error occurred, no output PDF file produced!