99爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

合肥生活安徽新聞合肥交通合肥房產生活服務合肥教育合肥招聘合肥旅游文化藝術合肥美食合肥地圖合肥社保合肥醫院企業服務合肥法律

MATH4063代做、代寫C++編程設計

時間:2023-11-17  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯



1 MATH**3
The University of Nottingham
SCHOOL OF MATHEMATICAL SCIENCES
AUTUMN SEMESTER 2022-2023
MATH**3 - SCIENTIFIC COMPUTING AND C++
Coursework 1 - Released 30th October 2023, 4pm
Your work should be submitted electronically via the MATH**3 Moodle page by 12noon on Monday 20th
November (unless you have arranged an extension). Since this work is assessed, your submission must be
entirely your own work (see the University’s policy on Academic Misconduct). Submissions up to five working
days late will be marked, but subject to a penalty of 5% of the maximum mark per working day.
The marks for each question are given by means of a figure enclosed by square brackets, eg [20]. There are
a total of 100 marks available for the coursework and it contributes 45% to the module. The marking rubric
available on Moodle will be applied to each full question to further break down this mark.
You are free to name the functions you write as you wish, but bear in mind these names should be meaningful.
Functions should be grouped together in .cpp files and accessed in other files using correspondingly named
.hpp files.
All calculations should be done in double precision.
A single zip file containing your full solution should be submitted on Moodle. This zip file should contain three
folders called main, source and include, with the following files in them:
main:
• q1d.cpp
• q2c.cpp
• q3c.cpp
• q4b.cpp
source:
• vector.cpp
• dense_matrix.cpp
• csr_matrix.cpp
• linear_algebra.cpp
• finite_volume.cpp
include:
• vector.hpp
• dense_matrix.hpp
• csr_matrix.hpp
• linear_algebra.hpp
• finite_volume.hpp
Prior to starting the coursework, please download the CW1_code.zip from Moodle and extract the files. More
information about the contents of the files included in this zip file is given in the questions below.
Hint: When using a C++ struct with header files, the whole struct needs to be defined fully in the header file,
and the header file included in the corresponding .cpp file. Include guards should also be used.
MATH**3 Turn Over
2 MATH**3
In this coursework you will build a 2D finite volume solver for the following PDE boundary value problem
−𝛥w**6; + ∇ ⋅ (bw**6;) = 𝑓 (w**9;, 𝑦) ∈ 𝛺, (1)
w**6; = 𝑔, (w**9;, 𝑦) ∈ 𝜕𝛺, (2)
where 𝑓 ∶ 𝛺 → **7;, 𝑔 ∶ 𝜕𝛺 → **7; and b ∶ 𝛺 → **7;2
.
In order to solve this problem, you will first define a sparse matrix structure, then write functions to apply
the GMRES linear algebra solver and finally build and solve the linear system arising from the finite volume
approximation of (1)-(2).
1. Matrices arising from the discretisation of partial differential equations using, for example, finite volume
methods, are generally sparse in the sense that they have many more zero entries than nonzero ones.
We would like to avoid storing the zero entries and only store the nonzero ones.
A commonly employed sparse matrix storage format is the Compressed Sparse Row (CSR) format. Here,
the nonzero entries of an 𝑛 × 𝑛 matrix are stored in a vector matrix_entries, the vector column_no gives
the column position of the corresponding entries in matrix_entries, while the vector row_start of length
𝑛+1 is the list of indices which indicates where each row starts in matrix_entries. For example, consider
the following:
𝐴 =




8 0 0 2
0 3 1 0
0 0 4 0
6 0 0 7





matrix_entries = (8 2 3 1 4 6 7)
column_no = (0 3 1 2 2 0 3)
row_start = (0 2 4 5 7)
Note, in the above, C++ indexing has been assumed, i.e, indices begin at 0.
(a) In csr_matrix.hpp, define a C++ struct called csr_matrix to store a matrix in CSR format. In
addition to matrix_entries, column_no and row_start, you should store the number of rows of the
matrix explicitly.
(b) In csr_matrix.cpp, write a C++ function that will set up the matrix 𝐴 from above in CSR format.
Remember, if you are using dynamically allocated memory, then you should also have corresponding
functions that will deallocate the memory you have set up.
(c) In csr_matrix.cpp, write a C++ function that takes as input a matrix 𝐴 stored in CSR format and a
vector x and computes the product 𝐴x. The prototype for your function should be:
void MultiplyMatrixVector ( csr_matrix & matrix ,double* vector ,
double* productVector )
Hence, the input vector and the output productVector should be pointers to dynamically allocated
arrays. In particular, it should be assumed that productVector has been preallocated to the correct
size already.
(d) By setting a vector x = (4, −1, 3, 6)⊤, write a test program in q1d.cpp to compute and print to the
screen the product 𝐴x, where 𝐴 is the matrix given above.
[20 marks]
MATH**3
3 MATH**3
2. Suppose we wish to find x ∈ **7;𝑛
such that
𝐴x = b, (3)
where 𝐴 is an 𝑛 × 𝑛 matrix and b ∈ **7;𝑛
.
One algorithm for solving this problem is the (restarted) Generalised Minimal RESidual (GMRES) algorithm.
The method is too complicated to explain here, but works to quickly find approximations x𝑘 = x0 + y𝑘
where y𝑘 ∈ 𝒦𝑘 ∶= Span{𝐴q0
, 𝐴2q0 … 𝐴𝑘q0
} for 𝑘 = 1, 2, …. y𝑘 is chosen to minimise the residual
‖b − 𝐴x𝑘‖2
.
Here x0
is some initial guess vector and q0
is the normed initial residual
q0 =
b − 𝐴x0
‖b − 𝐴x0‖2
.
𝒦𝑘 is called a Krylov subspace of 𝐴.
The algorithm stops when ‖b − 𝐴x𝑘‖2 < tol for some termination tolerance tol. As the method becomes
very memory inefficient when 𝑘 is large, the method is restarted every so often and x𝑘 reset to be x0
.
An incomplete GMRES algorithm function PerformGMRESRestarted() has been written in
linear_algebra.cpp.
A key component of the GMRES algorithm is the Arnoldi iteration that seeks to find an orthonormal basis
of 𝒦𝑘. At the 𝑘th step of the iteration, the Arnoldi method constructs the following matrix decomposition
of 𝐴:
𝐴𝑄𝑘 = 𝑄𝑘+1𝐻̃
𝑘,
where the columns of 𝑄𝑘 (𝑄𝑘+1) contain the orthonormal basis of 𝒦𝑘 (𝒦𝑘+1, resp.) and 𝐻̃
𝑘 is a (𝑘+1)× 𝑘
upper Hessenberg matrix. That is, a matrix that is nearly upper triangular but has non-zero components
on the first subdiagonal.
The 𝑘th step of the Arnoldi algorithm is:
Algorithm 1 One step of the Arnoldi Iteration.
Require: 𝑘 > 0, 𝐴, 𝑄𝑘:
1: Let q𝑖 be the 𝑖th column of 𝑄𝑘.
2: Let h = {ℎ𝑖
}
𝑘+1
𝑖=1 be a vector of length 𝑘 + 1.
3: Compute q𝑘+1 = 𝐴q𝑘
4: for 𝑖 = 1, … , 𝑘 do
5: ℎ𝑖 = q𝑘+1 ⋅ q𝑖
.
6: q𝑘+1 = q𝑘+1 − ℎ𝑖q𝑖
.
7: end for
8: ℎ𝑘+1 = ‖q𝑘+1‖2
.
9: q𝑘+1 = q𝑘+1/ℎ𝑘.
10: 𝑄𝑘+1 = [𝑄𝑘, q𝑘+1].
11: return 𝑄𝑘+1 and h.
(a) In linear_algebra.cpp, write a C++ function which implements one step of the Arnoldi iteration
method defined above.
The function should have the following prototype
void PerformArnoldiIteration ( csr_matrix & matrix ,
dense_matrix & krylov_matrix , int k, double* hessenberg )
MATH**3 Turn Over
4 MATH**3
Here, matrix is 𝐴, k is the step of the iteration to perform, krylov_matrix is the matrix containing
the orthonormal basis, where each row is a basis vector. Upon entry, krylov_matrix should have 𝑘
rows and upon exit it should contain 𝑘 + 1 rows, with the new basis vector in the last row.
Finally, upon exit, hessenberg should contain h, which is the final column of 𝐻̃
𝑘. You may assume that
hessenberg has been preallocated to be of length 𝑘+1 before the call to PerformArnoldiIteration.
Your function should make use, where possible, of prewritten functions defined in dense_matrix.cpp
and vector.cpp. Your code should also make use of the matrix multiplication function from Q1.
Once you have written PerformArnoldiIteration() the GMRES function should function as intended.
Note: Storage of the basis functions in the rows of krylov_matrix, rather than in the columns,
improves efficiency of the code.
(b) In csr_matrix.cpp, write a C++ function that will read from a file a matrix already stored in CSR
format and a vector. You may assume the file structures are as in matrix1.dat and vector1.dat on
Moodle and you may use these data files to test your function.
(c) Write a test program in file q2c.cpp that will read in the matrix 𝐴 from matrix2.dat and the vector
x from vector2.dat, compute b = 𝐴x, then use PerformGMRESRestarted() with the default input
arguments to find an approximation x̂to x. At the end of the calculation, print to the screen the error
‖x − ̂ x‖2
.
[30 marks]
3. The file mesh.hpp contains a struct that defines a mesh data structure mesh for a general mesh comprising
axis-aligned rectangular cells. In particular, each cell in the mesh has an additional struct called
cell_information that contains, among other things, information about the cell neighbours. Familiarise
yourself with these data structures by looking in mesh.hpp.
mesh.cpp contains two functions that will generate meshes, they are:
• ConstructRectangularMesh() - this constructs a mesh on the rectangular domain 𝛺𝑅 = [𝑎, 𝑏] ×
[𝑐, 𝑑].
• ConstructLShapedMesh() - this constructs a mesh on the L-shaped domain 𝛺𝐿 = 𝛺𝑅\𝛺𝐶, where
𝛺𝐶 = [(𝑎 + 𝑏)/2, 𝑏] × [(𝑐 + 𝑑)/2, 𝑑].
(a) In finite_volume.cpp, write a C++ function that will create the storage for a matrix 𝐴 in CSR format
and a RHS vector F required for a cell-centred finite volume method for solving (1)-(2). You should
follow the procedure outlined in the Unit 6 lecture notes. As one of the inputs, your function should
take in a variable of type mesh.
(b) In csr_matrix.cpp, write a C++ function that will output to the screen a matrix stored in CSR format
in the same style as in matrix1.dat.
(c) In Q3c.cpp, write a program that will ask the user to supply the number of cells in each coordinate
direction of a rectangular mesh, sets up the mesh using ConstructRectangularMesh() then calls the
function from part (a) to set up the corresponding matrix and finally prints it to the screen using the
function from part (b).
[30 marks]
MATH**3
5 MATH**3
4. (a) In finite_volume.cpp, write a function that takes in a mesh, uses the function from Q3(a) to construct
𝐴 and F, then populates it with the correct entries to solve problem (1)-(2) using the cell-centred finite
volume method, as outlined in the Unit 6 notes. The function should also take as input the functions
𝑓(w**9;, 𝑦), b(w**9;, 𝑦) and the Dirichlet boundary function 𝑔(w**9;, 𝑦).
(b) In Q4b.cpp, write a main program to ask the user to select from the following problems and supply
the number of cells in each coordinate direction.
1. • Rectangular Mesh - 𝑎 = 0, 𝑏 = 1, 𝑐 = 0 and 𝑑 = 1;
• 𝑓(w**9;, 𝑦) = 1;
• 𝑔(w**9;, 𝑦) = 0;
• b = 0.
2. • L-shaped Mesh - 𝑎 = 0, 𝑏 = 1, 𝑐 = 0 and 𝑑 = 1;
• 𝑓(w**9;, 𝑦) = 8𝜋2
cos(2𝜋w**9;) cos(2𝜋𝑦);
• 𝑔(w**9;, 𝑦) = cos(2𝜋w**9;) cos(2𝜋𝑦);
• b = 0.
3. • Rectangular Mesh - 𝑎 = −1, 𝑏 = 1, 𝑐 = −1 and 𝑑 = 1;
• 𝑓(w**9;, 𝑦) = 1;
• 𝑔(w**9;, 𝑦) = 0;
• b = (10, 10)⊤.
4. • L-Shaped Mesh - 𝑎 = 0, 𝑏 = 1, 𝑐 = 0 and 𝑑 = 1;
• 𝑓(w**9;, 𝑦) = 0;

𝑔(w**9;, 𝑦) = {
1, w**9; = 0, 0.25 < 𝑦 < 0.75,
0, otherwise;
• b = (
50𝑦
√w**9;2+𝑦2
,
−50w**9;
√w**9;2+𝑦2
)

.
The code should then set up the linear system arising from the finite volume discretisation and solve
the system
𝐴uℎ = F
using PerformGMRESRestarted().
Finally, print to the screen the maximum value of uℎ.
Hint: Once you have computed uℎ you can output it to together with the mesh to a file using
OutputSolution() in mesh.cpp. plot_solution.py can then be used to plot the solution in Python.
Note, if you are unable to get the iterative solver from Q2 working, then you may create the finite volume
matrix 𝐴 as if it were a dense matrix (i.e store all the zero entries) and use the function
PerformGaussianElimination() from dense_matrix.cpp to solve the system of equations. This will incur
a small penalty. Note, an illustration of the use of PerformGaussianElimination() can be found in the
main program inside gaussian_elimination_test.cpp.
[20 marks]
MATH**3 End

請加QQ:99515681 或郵箱:99515681@qq.com   WX:codehelp

掃一掃在手機打開當前頁
  • 上一篇:COMP9021代做、代寫Python程序語言
  • 下一篇:代寫CSE 30程序、代做c/c++編程設計
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    2025年10月份更新拼多多改銷助手小象助手多多出評軟件
    2025年10月份更新拼多多改銷助手小象助手多
    有限元分析 CAE仿真分析服務-企業/產品研發/客戶要求/設計優化
    有限元分析 CAE仿真分析服務-企業/產品研發
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    出評 開團工具
    出評 開團工具
    挖掘機濾芯提升發動機性能
    挖掘機濾芯提升發動機性能
    海信羅馬假日洗衣機亮相AWE  復古美學與現代科技完美結合
    海信羅馬假日洗衣機亮相AWE 復古美學與現代
    合肥機場巴士4號線
    合肥機場巴士4號線
    合肥機場巴士3號線
    合肥機場巴士3號線
  • 短信驗證碼 目錄網 排行網

    關于我們 | 打賞支持 | 廣告服務 | 聯系我們 | 網站地圖 | 免責聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網 版權所有
    ICP備06013414號-3 公安備 42010502001045

    99爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

          9000px;">

                亚洲福利视频一区| 国产精品国产自产拍高清av| av毛片久久久久**hd| 蜜臀精品久久久久久蜜臀| 最近日韩中文字幕| 国产精品久久久久久久久久久免费看| 91精品国产综合久久香蕉的特点| 欧美美女直播网站| 欧美美女一区二区三区| 在线电影欧美成精品| 欧美理论片在线| 欧美一区2区视频在线观看| 日韩一区二区三区在线观看 | 国产精品88av| 国v精品久久久网| 99热99精品| 一本到高清视频免费精品| 91福利视频网站| 欧美一区在线视频| 亚洲精品一区二区三区影院| 国产欧美日产一区| 一区二区成人在线视频| 日韩激情视频网站| 国产不卡视频一区| 色婷婷激情综合| 欧美一区二区三区婷婷月色 | 成人欧美一区二区三区小说| 中文字幕一区视频| 亚洲国产精品一区二区www| 首页国产丝袜综合| 韩国三级中文字幕hd久久精品| 狠狠狠色丁香婷婷综合激情| 成人手机电影网| 欧美日韩久久久| 久久精品视频一区二区三区| 亚洲欧美偷拍另类a∨色屁股| 国产91综合一区在线观看| 国产成都精品91一区二区三| 色噜噜狠狠色综合欧洲selulu| 91精品在线观看入口| 国产欧美精品一区二区色综合 | 一个色在线综合| 久久超碰97人人做人人爱| 成人性色生活片| 欧美精品日韩综合在线| 国产精品色呦呦| 日韩成人精品视频| heyzo一本久久综合| 91精品国产一区二区三区| 国产精品久久久久久久午夜片| 亚洲va欧美va天堂v国产综合| 国产经典欧美精品| 日韩一区二区中文字幕| 国产精品大尺度| 精品一区二区三区的国产在线播放| 波多野结衣精品在线| 日韩欧美三级在线| 亚洲第一电影网| av网站免费线看精品| 337p粉嫩大胆噜噜噜噜噜91av| 一区二区三区四区不卡在线| 成人激情综合网站| 精品入口麻豆88视频| 香蕉久久一区二区不卡无毒影院 | 一区二区三区波多野结衣在线观看| 国模少妇一区二区三区| 日韩欧美一级在线播放| 亚洲国产wwwccc36天堂| 色综合一区二区| 中文字幕在线观看一区二区| 国产伦精品一区二区三区免费迷| 日韩视频免费直播| 午夜在线成人av| 欧美最新大片在线看| 一区二区三区在线免费| 99久久精品99国产精品| 17c精品麻豆一区二区免费| 国产91精品久久久久久久网曝门 | 一区二区三区在线影院| 在线免费观看日本一区| 亚洲制服欧美中文字幕中文字幕| 色噜噜狠狠成人网p站| 一区二区久久久久| 欧美亚洲一区二区在线观看| 亚洲成人av福利| 欧美日韩国产bt| 美女视频免费一区| 精品免费日韩av| 国产成人在线色| 亚洲欧洲在线观看av| 91香蕉国产在线观看软件| 亚洲视频在线一区观看| 欧美性生交片4| 婷婷中文字幕综合| 日韩一区二区三区在线视频| 国产一区二区视频在线| 日本一区二区在线不卡| 色综合久久久久综合| 亚洲一区二区视频在线| 欧美一区二区三区四区五区| 久久激情五月婷婷| 亚洲欧洲无码一区二区三区| 欧美色精品在线视频| 七七婷婷婷婷精品国产| 亚洲精品一区二区三区精华液| 成人性生交大片免费看中文网站| 亚洲欧美日韩中文播放| 555www色欧美视频| av中文字幕不卡| 麻豆国产精品777777在线| 国产欧美日韩在线| 精品视频1区2区| 风间由美一区二区av101| 亚洲123区在线观看| 国产日本欧美一区二区| 欧美日韩久久久久久| 国产69精品久久777的优势| 亚洲国产综合视频在线观看| 国产亚洲美州欧州综合国| 91久久精品一区二区三| 国产美女视频一区| 亚洲一区在线视频| 国产精品国产自产拍在线| 欧美一三区三区四区免费在线看| 成人激情免费网站| 黑人巨大精品欧美一区| 亚洲美女精品一区| 国产日韩欧美不卡| 日韩欧美色电影| 欧美体内she精高潮| 99国产欧美久久久精品| 国产伦理精品不卡| 日韩电影一区二区三区四区| 亚洲另类春色国产| 国产精品久久久久久久久免费桃花| 欧美不卡视频一区| 91麻豆精品国产自产在线观看一区 | 蜜臀av性久久久久蜜臀av麻豆| 亚洲综合色婷婷| 日韩一区日韩二区| 26uuu国产日韩综合| 日韩一区二区三区视频在线观看| 91福利国产精品| 91免费小视频| 粉嫩av亚洲一区二区图片| 国产一区二区三区综合| 蜜桃视频免费观看一区| 午夜视频一区二区三区| 午夜精品久久久久影视| 午夜精品成人在线| 亚洲成人精品一区二区| 亚洲电影欧美电影有声小说| 亚洲电影在线免费观看| 亚洲高清久久久| 亚洲国产视频网站| 午夜久久久久久| 亚洲成a人片综合在线| 天堂成人免费av电影一区| 一区二区三区美女视频| 又紧又大又爽精品一区二区| 日韩理论片网站| 亚洲综合小说图片| 亚洲成a天堂v人片| 丝袜美腿一区二区三区| 免费成人在线网站| 美国三级日本三级久久99| 青青草国产成人av片免费| 九九精品视频在线看| 国产麻豆一精品一av一免费| 国产精品18久久久久久久久久久久| 国模冰冰炮一区二区| 国产精品99久久久久久似苏梦涵| www.av亚洲| 欧美日韩亚洲综合一区| 日韩精品专区在线影院重磅| 久久这里只精品最新地址| 国产精品毛片a∨一区二区三区| 亚洲精品精品亚洲| 舔着乳尖日韩一区| 国产一区欧美一区| 一本一本大道香蕉久在线精品| 欧美三区在线观看| 久久久精品天堂| 亚洲黄色尤物视频| 日本不卡的三区四区五区| 成人黄页在线观看| 欧美丰满一区二区免费视频| 国产欧美日韩视频一区二区| 亚洲一区二区三区四区在线| 极品少妇一区二区| 在线视频国产一区| 久久久久久久综合日本| 亚洲一区二区三区三| 国产精品一区二区免费不卡| 欧美天堂一区二区三区| 国产午夜亚洲精品羞羞网站| 亚洲成人一区二区| 成人精品在线视频观看| 欧美片网站yy| 亚洲女同ⅹxx女同tv|