The discrete second derivative is assembled as an matrix acting on the interior grid…

PHYSICS · Multi-part · Fermi University Physics · Mathematical Methods for Physics · Computational Physics · Scientific programming for physicists

Scientific Computing for Physicists, Ch Arrays in memory: layout, cost and the data structures of physical problems

Problem

The discrete second derivative d2udx2∣i≈ui−1−2ui+ui+1Δx2\dfrac{d^2u}{dx^2}\Big|_i \approx \dfrac{u_{i-1}-2u_i+u_{i+1}}{\Delta x^2} is assembled as an N×NN\times N matrix acting on the N=5N=5 interior grid values, with Dirichlet boundaries (the boundary values are not among the unknowns) and grid spacing Δx=0.1 m\Delta x = 0.1\,\mathrm{m}. ((a)) State the nonzero pattern of the matrix and compute nnz\mathrm{nnz} from nnz=3N−2\mathrm{nnz}=3N-2. ((b)) Write the CSR arrays data, indices and indptr for this matrix, using 3232-bit integers for indices and indptr. ((c)) Using storage=8 nnz+4 nnz+4(N+1)\text{storage} = 8\,\mathrm{nnz} + 4\,\mathrm{nnz} + 4(N+1) bytes (float64 values, 3232-bit indices), compute the total CSR storage in bytes.

Browse the problem library