COMP 605: Introduction to Parallel Computing Homework 8: ”GPU/CUDA Wave” Generator Using Matrix-Matrix Multiplication of Airy Disk Function Mary Thomas Department of Computer Science Computational Science Research Center (CSRC) San Diego State University (SDSU) Due: 05/14/15 Posted: 05/05/15 Updated: 05/05/15 DRAFT
31
Embed
COMP 605: Introduction to Parallel Computing Homework 8 ...€¦ · COMP 605: Introduction to Parallel Computing Homework 8: "GPU/CUDA Wave" Generator Using Matrix-Matrix Multiplication
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
COMP 605 Introduction to Parallel ComputingHomework 8
rdquoGPUCUDA Waverdquo Generator UsingMatrix-Matrix Multiplication of Airy Disk Function
Mary Thomas
Department of Computer ScienceComputational Science Research Center (CSRC)
San Diego State University (SDSU)
Due 051415Posted 050515
Updated 050515
DRAFT
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 231 Mary Thomas
Function6 Generating Sombrero using Hadamard Multiplication on Modified
Circle Function7 rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk
Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 331 Mary Thomas
Homework 8 Instructions
Comparing CUDA and MPI Matrix-Matrix Mult
Project goal is to compare the efficiencies of an MPI and a CUDAMatrix-Matrix Multiplication implementation for calculating the AiryDisk wave function See Lecture 27CUDA implementation
Your may choose your own CUDA reference codeSome source code will be provided in the COMP605hw8 directoryModified CUDA mat-mul example from the CUDA SDK
httpsdevelopernvidiacomgpu-computing-sdk
SDK examples on tuckoousrlocalcudasamples0S implematrixMulrdquoWorking copy of SDK placed in COMP605hw8gpumatrixMulbased on abovedescribed in Cuda Programming Guide Chapter 3httpdocsnvidiacomcudacuda-c-programming-guideindexhtml
You will need to modify the CUDA code so that is calculates theAiry functions for A and B internally
MPI codeUse HW5 MPI results (yours or a classmate ndash use references)Include summary table ampplot of data used or include on relevantCUDA tables and plots (see below)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 431 Mary Thomas
Homework 8 Instructions
Homework 8 Scaling studies
Matrix Size
Read N from the command lineUse square [NxN] matricesVary the size of matrices
Estimate amp justify an Nmax
Choose 10 measurement points between 1024 and Nmax
For an example see MPI vs CUDA example below
Vary the number of threadsblock for a given N (see rdquoCuda Twallrdquoplot below)Use cuda properties to check that your matrix fits on the device
Performance
Time code runs (use cudaEvent timers)Calculate statistics on the timingsVary number of device blocks and threads
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 531 Mary Thomas
Homework 8 Instructions
Homework 8 Writeup Instructions
Your work should be written up in the same report format andsubmitted materials used all semester
Source Code (reference source)
Write your own codeOnline sourcesModify code to calculate Airy disk function
Key variables should be read from command line or computeddynamically
You can use the samesimilar plotting that you used in hw5 (seeCOMP605hw5)
Teams of up to 4 members allowed
identify team and rolesplace copy of code data etc in each team members directoryremember the bigger the team the more work you should report
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 631 Mary Thomas
Homework 8 Instructions
Suggestions for comparing MPI and CUDA
You cannot directly compare the MPI PEscores against the CUDAnumber of threads
You can compare related run-time characteristics such as Toptimal as a function of the total problem size
Toptimal can be defined as
defined as the point where increasing the number of processors orthe number of threadsblock no longer significantly reduces therun-time (rsquoturnoverrsquo point)See Figure 1 below rdquo
See and figure 2 and Table3 below
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 731 Mary Thomas
Homework 8 Instructions
Figure 1 CUDA Twall for different Nthreadsblock vs Dim
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 831 Mary Thomas
Homework 8 Instructions
Figure 2 Toptimal as a function of matrix size for MPI and CUDAGPU
tests
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 931 Mary Thomas
Homework 8 Instructions
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1031 Mary Thomas
Homework 8 Instructions
Figure 4 runtime as a function of matrix size for
different thread block sizes
Source Fall 2012 K Withers
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
Function6 Generating Sombrero using Hadamard Multiplication on Modified
Circle Function7 rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk
Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 331 Mary Thomas
Homework 8 Instructions
Comparing CUDA and MPI Matrix-Matrix Mult
Project goal is to compare the efficiencies of an MPI and a CUDAMatrix-Matrix Multiplication implementation for calculating the AiryDisk wave function See Lecture 27CUDA implementation
Your may choose your own CUDA reference codeSome source code will be provided in the COMP605hw8 directoryModified CUDA mat-mul example from the CUDA SDK
httpsdevelopernvidiacomgpu-computing-sdk
SDK examples on tuckoousrlocalcudasamples0S implematrixMulrdquoWorking copy of SDK placed in COMP605hw8gpumatrixMulbased on abovedescribed in Cuda Programming Guide Chapter 3httpdocsnvidiacomcudacuda-c-programming-guideindexhtml
You will need to modify the CUDA code so that is calculates theAiry functions for A and B internally
MPI codeUse HW5 MPI results (yours or a classmate ndash use references)Include summary table ampplot of data used or include on relevantCUDA tables and plots (see below)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 431 Mary Thomas
Homework 8 Instructions
Homework 8 Scaling studies
Matrix Size
Read N from the command lineUse square [NxN] matricesVary the size of matrices
Estimate amp justify an Nmax
Choose 10 measurement points between 1024 and Nmax
For an example see MPI vs CUDA example below
Vary the number of threadsblock for a given N (see rdquoCuda Twallrdquoplot below)Use cuda properties to check that your matrix fits on the device
Performance
Time code runs (use cudaEvent timers)Calculate statistics on the timingsVary number of device blocks and threads
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 531 Mary Thomas
Homework 8 Instructions
Homework 8 Writeup Instructions
Your work should be written up in the same report format andsubmitted materials used all semester
Source Code (reference source)
Write your own codeOnline sourcesModify code to calculate Airy disk function
Key variables should be read from command line or computeddynamically
You can use the samesimilar plotting that you used in hw5 (seeCOMP605hw5)
Teams of up to 4 members allowed
identify team and rolesplace copy of code data etc in each team members directoryremember the bigger the team the more work you should report
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 631 Mary Thomas
Homework 8 Instructions
Suggestions for comparing MPI and CUDA
You cannot directly compare the MPI PEscores against the CUDAnumber of threads
You can compare related run-time characteristics such as Toptimal as a function of the total problem size
Toptimal can be defined as
defined as the point where increasing the number of processors orthe number of threadsblock no longer significantly reduces therun-time (rsquoturnoverrsquo point)See Figure 1 below rdquo
See and figure 2 and Table3 below
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 731 Mary Thomas
Homework 8 Instructions
Figure 1 CUDA Twall for different Nthreadsblock vs Dim
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 831 Mary Thomas
Homework 8 Instructions
Figure 2 Toptimal as a function of matrix size for MPI and CUDAGPU
tests
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 931 Mary Thomas
Homework 8 Instructions
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1031 Mary Thomas
Homework 8 Instructions
Figure 4 runtime as a function of matrix size for
different thread block sizes
Source Fall 2012 K Withers
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 331 Mary Thomas
Homework 8 Instructions
Comparing CUDA and MPI Matrix-Matrix Mult
Project goal is to compare the efficiencies of an MPI and a CUDAMatrix-Matrix Multiplication implementation for calculating the AiryDisk wave function See Lecture 27CUDA implementation
Your may choose your own CUDA reference codeSome source code will be provided in the COMP605hw8 directoryModified CUDA mat-mul example from the CUDA SDK
httpsdevelopernvidiacomgpu-computing-sdk
SDK examples on tuckoousrlocalcudasamples0S implematrixMulrdquoWorking copy of SDK placed in COMP605hw8gpumatrixMulbased on abovedescribed in Cuda Programming Guide Chapter 3httpdocsnvidiacomcudacuda-c-programming-guideindexhtml
You will need to modify the CUDA code so that is calculates theAiry functions for A and B internally
MPI codeUse HW5 MPI results (yours or a classmate ndash use references)Include summary table ampplot of data used or include on relevantCUDA tables and plots (see below)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 431 Mary Thomas
Homework 8 Instructions
Homework 8 Scaling studies
Matrix Size
Read N from the command lineUse square [NxN] matricesVary the size of matrices
Estimate amp justify an Nmax
Choose 10 measurement points between 1024 and Nmax
For an example see MPI vs CUDA example below
Vary the number of threadsblock for a given N (see rdquoCuda Twallrdquoplot below)Use cuda properties to check that your matrix fits on the device
Performance
Time code runs (use cudaEvent timers)Calculate statistics on the timingsVary number of device blocks and threads
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 531 Mary Thomas
Homework 8 Instructions
Homework 8 Writeup Instructions
Your work should be written up in the same report format andsubmitted materials used all semester
Source Code (reference source)
Write your own codeOnline sourcesModify code to calculate Airy disk function
Key variables should be read from command line or computeddynamically
You can use the samesimilar plotting that you used in hw5 (seeCOMP605hw5)
Teams of up to 4 members allowed
identify team and rolesplace copy of code data etc in each team members directoryremember the bigger the team the more work you should report
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 631 Mary Thomas
Homework 8 Instructions
Suggestions for comparing MPI and CUDA
You cannot directly compare the MPI PEscores against the CUDAnumber of threads
You can compare related run-time characteristics such as Toptimal as a function of the total problem size
Toptimal can be defined as
defined as the point where increasing the number of processors orthe number of threadsblock no longer significantly reduces therun-time (rsquoturnoverrsquo point)See Figure 1 below rdquo
See and figure 2 and Table3 below
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 731 Mary Thomas
Homework 8 Instructions
Figure 1 CUDA Twall for different Nthreadsblock vs Dim
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 831 Mary Thomas
Homework 8 Instructions
Figure 2 Toptimal as a function of matrix size for MPI and CUDAGPU
tests
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 931 Mary Thomas
Homework 8 Instructions
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1031 Mary Thomas
Homework 8 Instructions
Figure 4 runtime as a function of matrix size for
different thread block sizes
Source Fall 2012 K Withers
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 431 Mary Thomas
Homework 8 Instructions
Homework 8 Scaling studies
Matrix Size
Read N from the command lineUse square [NxN] matricesVary the size of matrices
Estimate amp justify an Nmax
Choose 10 measurement points between 1024 and Nmax
For an example see MPI vs CUDA example below
Vary the number of threadsblock for a given N (see rdquoCuda Twallrdquoplot below)Use cuda properties to check that your matrix fits on the device
Performance
Time code runs (use cudaEvent timers)Calculate statistics on the timingsVary number of device blocks and threads
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 531 Mary Thomas
Homework 8 Instructions
Homework 8 Writeup Instructions
Your work should be written up in the same report format andsubmitted materials used all semester
Source Code (reference source)
Write your own codeOnline sourcesModify code to calculate Airy disk function
Key variables should be read from command line or computeddynamically
You can use the samesimilar plotting that you used in hw5 (seeCOMP605hw5)
Teams of up to 4 members allowed
identify team and rolesplace copy of code data etc in each team members directoryremember the bigger the team the more work you should report
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 631 Mary Thomas
Homework 8 Instructions
Suggestions for comparing MPI and CUDA
You cannot directly compare the MPI PEscores against the CUDAnumber of threads
You can compare related run-time characteristics such as Toptimal as a function of the total problem size
Toptimal can be defined as
defined as the point where increasing the number of processors orthe number of threadsblock no longer significantly reduces therun-time (rsquoturnoverrsquo point)See Figure 1 below rdquo
See and figure 2 and Table3 below
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 731 Mary Thomas
Homework 8 Instructions
Figure 1 CUDA Twall for different Nthreadsblock vs Dim
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 831 Mary Thomas
Homework 8 Instructions
Figure 2 Toptimal as a function of matrix size for MPI and CUDAGPU
tests
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 931 Mary Thomas
Homework 8 Instructions
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1031 Mary Thomas
Homework 8 Instructions
Figure 4 runtime as a function of matrix size for
different thread block sizes
Source Fall 2012 K Withers
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 531 Mary Thomas
Homework 8 Instructions
Homework 8 Writeup Instructions
Your work should be written up in the same report format andsubmitted materials used all semester
Source Code (reference source)
Write your own codeOnline sourcesModify code to calculate Airy disk function
Key variables should be read from command line or computeddynamically
You can use the samesimilar plotting that you used in hw5 (seeCOMP605hw5)
Teams of up to 4 members allowed
identify team and rolesplace copy of code data etc in each team members directoryremember the bigger the team the more work you should report
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 631 Mary Thomas
Homework 8 Instructions
Suggestions for comparing MPI and CUDA
You cannot directly compare the MPI PEscores against the CUDAnumber of threads
You can compare related run-time characteristics such as Toptimal as a function of the total problem size
Toptimal can be defined as
defined as the point where increasing the number of processors orthe number of threadsblock no longer significantly reduces therun-time (rsquoturnoverrsquo point)See Figure 1 below rdquo
See and figure 2 and Table3 below
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 731 Mary Thomas
Homework 8 Instructions
Figure 1 CUDA Twall for different Nthreadsblock vs Dim
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 831 Mary Thomas
Homework 8 Instructions
Figure 2 Toptimal as a function of matrix size for MPI and CUDAGPU
tests
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 931 Mary Thomas
Homework 8 Instructions
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1031 Mary Thomas
Homework 8 Instructions
Figure 4 runtime as a function of matrix size for
different thread block sizes
Source Fall 2012 K Withers
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 631 Mary Thomas
Homework 8 Instructions
Suggestions for comparing MPI and CUDA
You cannot directly compare the MPI PEscores against the CUDAnumber of threads
You can compare related run-time characteristics such as Toptimal as a function of the total problem size
Toptimal can be defined as
defined as the point where increasing the number of processors orthe number of threadsblock no longer significantly reduces therun-time (rsquoturnoverrsquo point)See Figure 1 below rdquo
See and figure 2 and Table3 below
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 731 Mary Thomas
Homework 8 Instructions
Figure 1 CUDA Twall for different Nthreadsblock vs Dim
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 831 Mary Thomas
Homework 8 Instructions
Figure 2 Toptimal as a function of matrix size for MPI and CUDAGPU
tests
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 931 Mary Thomas
Homework 8 Instructions
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1031 Mary Thomas
Homework 8 Instructions
Figure 4 runtime as a function of matrix size for
different thread block sizes
Source Fall 2012 K Withers
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 731 Mary Thomas
Homework 8 Instructions
Figure 1 CUDA Twall for different Nthreadsblock vs Dim
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 831 Mary Thomas
Homework 8 Instructions
Figure 2 Toptimal as a function of matrix size for MPI and CUDAGPU
tests
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 931 Mary Thomas
Homework 8 Instructions
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1031 Mary Thomas
Homework 8 Instructions
Figure 4 runtime as a function of matrix size for
different thread block sizes
Source Fall 2012 K Withers
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 831 Mary Thomas
Homework 8 Instructions
Figure 2 Toptimal as a function of matrix size for MPI and CUDAGPU
tests
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 931 Mary Thomas
Homework 8 Instructions
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1031 Mary Thomas
Homework 8 Instructions
Figure 4 runtime as a function of matrix size for
different thread block sizes
Source Fall 2012 K Withers
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 931 Mary Thomas
Homework 8 Instructions
Source Fall 2012 G Pham
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1031 Mary Thomas
Homework 8 Instructions
Figure 4 runtime as a function of matrix size for
different thread block sizes
Source Fall 2012 K Withers
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1031 Mary Thomas
Homework 8 Instructions
Figure 4 runtime as a function of matrix size for
different thread block sizes
Source Fall 2012 K Withers
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1131 Mary Thomas
Homework 8 Instructions
Figure 5
Image Source Fall 2012 S Escobar
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1231 Mary Thomas
Matrix-Matrix Multiplication
Calculating Bessel Functions Using Matrix-Matrix Multiplication
minus3
minus2
minus1
0
1
2
minus3
minus2
minus1
0
1
2
X
Sombrero Plt Using Matlab Sinc(x) Function Ni=64 S=3 F=05
Y
Plot of a 2D rotationally symmetric Bessel function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 1331 Mary Thomas
Matrix-Matrix Multiplication
Radially symmetric phenomena in Nature
Diffraction of light through a smallcircular aperture (top image)
Particle diffraction at small scalesparticles behave like light photons andcan be scattered by nuclei (bottom)
Signal Processing A square wave iscomposed of all frequencies and acylinder is a 2D rotation of a squarewave the Fourier transform of acylinder is the Circ function (bottomimage)
Other phenomena that are wave like
water waves when a rock is droppedsounds waves on a snare drummechanical vibrations
Airy disk pattern made by light passing through a small
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
Wave theory eg the Point spread function and Xernike polynomials
Huyen-Fresnel Principle eg Diffraction of light through a small circularaperture
Bessel Functions solutions y(x) of Besselrsquos differential equation
Fourier transform of a cylinder rarr Circ functionUsing Gaussian profile to approximate the Airy DiskElectromagnetic waves in a waveguidemany other applications
sinc(x) = sin(x)x or rdquoSombrerordquo function ndash approximates some Besselfunctions
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2031 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
Fraunhofer diffraction pattern of a circular aperture is given by thesquared modulus of the Fourier transform (Bessel function) of thecircular aperture
I (θ) = I0(
2J1(ka sinθ)ka sinθ
)2
= I0J1
(2J1(x)
x
)2
I0 is the maximum intensity of the pattern at the Airy disc center
J1 Bessel function of the first kind of order one
k wavenumber = 2πλ
a is the radius of the aperture
θ the angle of observation
R is the focal length
The Airy pattern falls slowly to zero withincreasing distance from the center whichallows us to use a Gaussian profileapproximation for the intensity distribution
I (r) asymp I prime0exp(minusr2
λN
)asymp(
P0Aλ2R2
)exp
(minusr2
λN
)asymp(
Aλ2R cos
2 (r))exp
(minusr2
λN
) Airy disk pattern made by light passing through a smallaperture
httpenwikipediaorgwikiAiry_disk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2131 Mary Thomas
rdquoSombrerordquo Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Fraunhoffer Diffraction the Airy Disk Function
The intensity pattern can be written using cartesian coordinates as
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radic
x2 + y2 and f and gare constants that control the shape of the waves
This particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
The function is calculated using Hadamard (element-wise) matrixmultiplication RefhttpenwikipediaorgwikiHadamard_product_(matrices)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2231 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Hadamard (element-wise) Matrix Multiplication
The Hadamard (or Schur) product is a binary operator that operates on 2identically-shaped matrices and produces a third matrix of the samedimensions
Definition If A = [aij ] and B = [bij ] are mx n matrices then theHadamard product of A and B is defined to be
(A B)ij = (A)ij middot (B)ij
is an mx n matrix C = [cij ] suchthat
cij = aij lowast bij
The Matlab times operation (C = A ˙B) is a Hadamard product
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2331 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
File sombrero_using_bessel_formulation_hadamardm
Airy discDiffraction pattern Matlab code
By Mary Thomas
updated March 2015
Created March 2014
note ni does have to equal nj but it is for this problem
scaling factors affect max amplitude
number of wavelengths
clear all
ni=64
size=nini
fprintf(rsquobegin calc bessel sombreronrsquo)
Tweak control parameters to adjust amplitude
number of peaks and spacingdepth of peaks
f max amplitude
f=1
f=02
f= 025
f=03
f= 04
f=05
f=075
f=09
f=10]
f=famp(5)
g inverse wavelength
g=1
g=025
g=5 g=06
g=75 g=1
s number of wavelengths in hat ~ s+1
s=2
s=3 s=4 s=5
s=8
x = linspace(-s s ni)
y = linspace(-s s ni)
fprintf(rsquoinit xy completenrsquo)
serial matrix-matrix multiplication
C=zeros(nini)
for i=1ni
for j=1ni
r(ij)=sqrt(x(i)^2 + y(j)^2) fpi convert to radians
xpts(ij) = x(i) these are for plotting
ypts(ij) = y(j)
end
end
for i=1ni
for j=1ni
A(ij) = f(cos(r(ij)))^2
B(ij) = exp(-g(r(ij)^2))
end
end
calculate the Hadamard Product
for i=1ni
for j=1ni
C(ij) = A(ij) B(ij)
end
end
fprintf(rsquocalc C completenrsquo)
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2431 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Matlab code to generate Sombrero using Hadamard Multiplication onModified Circle Function
create 3D surface node mesh surf(c)
figure
surf(xptsyptsC)
title([rsquoSombrero Peaks -- C=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
create 3D surface node mesh surf(c)
D=AB
figure
surf(xptsyptsD)
title([rsquoSombrero Peaks -- D=AB Ni=rsquonum2str(ni)rsquo S=rsquonum2str(s)rsquo F=rsquonum2str(f)rsquo G=rsquonum2str(g)])
xlabel(rsquoXrsquo)
ylabel(rsquoYrsquo)
grid on
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2531 Mary Thomas
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Sombrero Function Using Hadamard Multipilcation ofModified Circle Function
Sombrero Plot Using Bessel Function Ni=64 S=3 Freq=05
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 3131 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy DiskFunction
Homework 8 Instructions
Matrix-Matrix Multiplication
Sombrero Shaped Functions sinc(x)=sin(x)x
Sombrero Shaped Functions Bessel Functions
Sombrero Shaped Functions Fraunhoffer Diffraction Airy Disk Function
Generating Sombrero using Hadamard Multiplication on Modified Circle Function
Wave Generator Using Matrix-Matrix Multiplication of Airy Disk Function
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2631 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
rdquoWaverdquo Generator Using Matrix-Matrix Multiplicationof Airy Disk Function
For this assignment you will use matrix-matrix multiplication (notthe Hadamard product see above) to calculate a matrix productusing the matrices defined by the Airy discFraunhaufer Diffractionpattern described above
F (x y) = f lowast cos2 (r) lowast e(minusgr2)
where (x y) are cartesian coordinates r =radicx2 + y2 and f and g
are constants that control the shape of the wavesThis particular form allows us to factor the function into a matrixmultiplication equation of the form
F (x y) = A lowast Bwhere
A = f lowast cos2(radic
x2 + y2)
and B = eminusg(x2+y2)
Notes1 (x y) are the grid cartesian coordinates and f and g are constants
that control the shape of the waves2 The results will differ from those obtained using Hadamard matrix
multiplication
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2731 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Serial_matrix_mult for (i = 0 i lt n i++)
for (j = 0 j lt n j++) C[i][j] = 00for (k = 0 k lt n k++)
C[i][j] = C[i][j] + A[i][k]B[k][j]printf( )
Dimensions [ROWS x COLS]A = mx kB = k x nC = mx n
a11 a1j a1k
ai1 aij aik
am1 amj amk
lowast
b11 b1j b1n
bi1 bij bin
bk1 bkj bkn
=
c11 c1j c1k
ci1 cij cik
cm1 cmj cmk
COMP 605 Homework 8 Due 051415 Posted 050515 Updated 050515 2831 Mary Thomas
rdquoWaverdquo Generator Using Matrix-Matrix Multiplication of Airy Disk Function
2D Matrix-Matrix Multiplication (Mat-Mat-Mult)
Definition Let A be an [mx k] matrix and B be a be an [k x n]then C will be a matrix with the dimensions [mx n]