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 withboundary="valid").- Parameters:
order (Integral) – The order \(n \geq 1\) of the derivative.
n_times (Integral) – The number of samples \(N_t\).
accuracy (Integral, optional (default:
2)) – The order \(p\) of the error, a positive even integer.n_dim (Integral) – See
assemble_forward_finite_difference_matrix().spacing (Real) – See
assemble_forward_finite_difference_matrix().boundary (str) – See
assemble_forward_finite_difference_matrix().sparse (bool) – See
assemble_forward_finite_difference_matrix().return_indices (bool) – See
assemble_forward_finite_difference_matrix().
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)