def d_x2(self, factors=None):
"""Creates a sparse matrix for computing the second derivative with respect to x multiplied
by factors given for every point. Uses central difference quotient.
Args:
factors: Factor for each point to be applied after derivation.
Returns:
Sparse matrix the calculate second derivatives of field components.
"""
# use ones as factors if none are specified
if factors is None:
factors = np.array(1).repeat(self.num_points)
return sp.dia_matrix((np.array([factors, -2*factors, factors]), [-1, 0, 1]),
shape=(self.num_points, self.num_points))
评论列表
文章目录