pysdic.numeric.assemble_central_finite_difference_matrix#

assemble_central_finite_difference_matrix(order, n_times, *, n_dim=1, spacing=1.0, accuracy=2, boundary='one_sided', sparse=True, return_indices=False)[source]#

Assemble the central finite difference operator of a derivative on a uniform sampling.

Shortcut for assemble_finite_difference_matrix() with the times \(0, h, \dots, (N_t - 1) h\): centered stencils inside the sampling and one-sided stencils of the same accuracy at its ends (or no row with boundary="valid").

Parameters:

Examples

assemble_central_finite_difference_matrix(2, 5, sparse=False)
# [[ 2, -5,  4, -1,  0],   (one-sided)
#  [ 1, -2,  1,  0,  0],
#  [ 0,  1, -2,  1,  0],
#  [ 0,  0,  1, -2,  1],
#  [ 0, -1,  4, -5,  2]]   (one-sided)