All problems
Coarse-Grid Correction
Problem
Apply a coarse-grid correction to the current fine-grid iterate x.
Solve the coarse problem e = A_coarse_inv * r_coarse for the error, prolong it with x_new = x + P*e, and return the corrected vector.
Hint
The correction removes the smooth part of the error that the fine smoother cannot fix.
Test cases
case 1
in: [[1,1],[[1],[0]],[[0.5]],[2]]
expected: [2,1]
case 2
in: [[0,0,0],[[1],[0],[0]],[[2]],[1]]
expected: [2,0,0]
case 3
in: [[1,2],[[1,0],[0,1]],[[1,0],[0,0.5]],[1,2]]
expected: [2,3]
case 4
in: [[0,0],[[1],[1]],[[1]],[0]]
expected: [0,0]
Starter codePython
def coarse_grid_correction(x, P, A_coarse_inv, r_coarse):
# Your code here
pass4 test cases · run your code against them in the editor