Код: Выделить всё
def capacitance_matrix_inv_sqrt(Cg, Cc, Cja, N):
diagonal = np.ones(N) * (2 * Cja + Cg)
diagonal[0] = Cja + Cg + Cc # Special condition for the first element
diagonal[-1] = Cja + Cg + Cc
off_diagonal = np.ones(N - 1) * (-Cja)
# Construct the capacitance matrix
C = np.diag(diagonal) + np.diag(off_diagonal, k=1) + np.diag(off_diagonal, k=-1)
return C
Подробнее здесь: https://stackoverflow.com/questions/784 ... -in-python