Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-213

Multigrid Prolongation Apply

Problem

Apply the 1D multigrid prolongation (linear interpolation) operator to a coarse vector of length m+1, producing a fine vector of length 2m+1:

fine[2i] = coarse[i] and fine[2i+1] = 0.5*(coarse[i] + coarse[i+1])

Hint

Fine-grid odd positions are averages of neighboring coarse values.

Test cases

case 1
in: [[1,1]]
expected: [1,1,1]
case 2
in: [[0,2]]
expected: [0,1,2]
case 3
in: [[1,2,3]]
expected: [1,1.5,2,2.5,3]
case 4
in: [[5]]
expected: [5]
Starter codePython
def multigrid_prolong(coarse):
    # Your code here
    pass

4 test cases · run your code against them in the editor