Algorithmadvanced
Pade via Lanczos
Also called PVL, Feldmann-Freund PVL.
Feldmann and Freund's reduced-order model of a linear circuit that matches 2q moments of the transfer function stably using the nonsymmetric Lanczos process.
- Time
- O(F + q s + q N) worst
- Space
- O(N + q) extra
- Where
- F = the cost of one sparse LU factorization of G + s0 C; N = the number of MNA unknowns; q = the number of Lanczos steps (the order of the model); s = the cost of one solve with those factors plus one product with C
- Model
- Real RAM
- Properties
- deterministicnot exactiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Peter Feldmann, Roland W. Freund, 1995
Padé via Lanczos (PVL) replaces a large linear circuit, such as an extracted interconnect, by a small model whose transfer function agrees with that of the circuit in its first Taylor coefficients (moments) around an expansion point. It is the same Padé approximant that asymptotic waveform evaluation computes, but Feldmann and Freund (1995) obtain it from steps of the nonsymmetric Lanczos process, which never forms the moments and so stays accurate at orders where AWE fails. It belongs to the circuit simulation half of the logic and circuit simulation sub-area, next to PRIMA, which gives up some moments to keep passivity.
In plain words
A long wire on a chip, cut into many small resistors, capacitors and inductors, has thousands of equations. Its effect at its two ends can usually be described by a formula with a few terms. Model order reduction finds such a formula.
AWE finds it by measuring a list of numbers, the moments, and fitting a fraction of two polynomials to them. The trouble is that the later moments all look alike, so in computer arithmetic they carry almost no new information, and the fit stops getting better after about eight terms. PVL builds the same fraction another way: it walks step by step through the directions that the circuit reaches from its input and from its output, keeping each new direction separate from the old ones. Each step adds one pole to the model, and the accuracy keeps improving.
The problem
The circuit is linear, in modified nodal analysis form in the Laplace domain, , with input and output , so its transfer function is . This is the matrix pair of AC analysis. Choose an expansion point with nonsingular, and put and . Then
The are the moments at . Input: , , , , and the order . Output: a model of order with . This is the Padé approximant of at .
The algorithm
PVL(G, C, b, l, s₀, q)- 1
factor K = G + s₀C by sparse LU; r ← K⁻¹ b - 2
v₁ ← r/ρ₁; w₁ ← l/η₁; d₁ ← w₁ᵀv₁; if d₁ = 0 then report breakdown - 3
for k = 1, ..., q - 4
u ← A v_k = −K⁻¹(C v_k); t ← Aᵀ w_k = −Cᵀ(K⁻ᵀ w_k) - 5
α_k ← w_kᵀ u / d_k; β_k ← η_k d_k / d_{k−1}; γ_k ← ρ_k d_k / d_{k−1} (β₁ = γ₁ = 0) - 6
ρ_{k+1} v_{k+1} ← u − α_k v_k − β_k v_{k−1}; η_{k+1} w_{k+1} ← t − α_k w_k − γ_k w_{k−1} - 7
d_{k+1} ← w_{k+1}ᵀ v_{k+1}; if d_{k+1} = 0 and k < q then report breakdown - 8
T_q ← the tridiagonal matrix with diagonal α₁..α_q, subdiagonal ρ₂..ρ_q, superdiagonal β₂..β_q - 9
return H_q(s) = (lᵀr) e₁ᵀ (I − (s − s₀) T_q)⁻¹ e₁
The right vectors span the Krylov subspace of and , and the left vectors that of and . The coefficients make the two sequences biorthogonal, for , with three-term recurrences, as in the biconjugate gradient method. The scale factors and are free; the code divides by the largest entry, which keeps rational arithmetic exact. Line L4 solves with and with , both with the factors of line L1, so the whole run costs one factorization.
The model is cheap to use. at any costs one tridiagonal solve of order . Its poles are for the nonzero eigenvalues of , and its residues come from the eigenvectors, which give a time-domain response as a sum of exponentials. In a circuit simulator the model is written back as a small set of equations and connected to the rest of the circuit.
Example
Two nodes by hand. Node 1 has 1 S to ground and 1 S to node 2, each node has 1 F to ground, a current of 1 A enters node 1, and the output is the voltage of node 2. So , , , , and . At , with , and the moments are .
Step 1: , , , . Then and , so . With the model is , with moments : two match, the third does not. Its pole is the reciprocal of the Elmore delay 3, against the dominant pole of the circuit.
Step 2: and , both with scale 1, and : the left and right vectors are not equal and is negative, which a symmetric process would never give. , and gives . So and : with the model is exact.
An RC line. 60 sections of 10 Ω and 10 fF, driven by a current source with 50 Ω and loaded by 1 MΩ, output at the far end, expanded at . The table gives the largest error over 121 log-spaced frequencies from 1 MHz to 10 GHz, divided by the largest , for PVL and for AWE in floating point (Padé from explicit moments by a Hankel solve):
| q | 1 | 2 | 4 | 6 | 8 | 12 | 16 |
|---|---|---|---|---|---|---|---|
| PVL | 0.17 | 0.025 | |||||
| AWE | 0.17 | 0.025 |
The two agree while the moments carry information. From AWE stalls near , while PVL reaches rounding level.
An RLC line. 20 sections of 2 Ω, 1 nH and 1 pF (41 unknowns), with 25 Ω at the source and 50 Ω at the load, from 100 MHz to 3 GHz at 121 linear points, expanded at . The band holds several resonances, so a low order cannot follow it:
| q | 12 | 16 | 20 | 24 | 30 |
|---|---|---|---|---|---|
| PVL | 0.31 | ||||
| AWE | 0.31 | 0.014 | 0.018 | 0.094 |
At the AWE Hankel solve meets a zero pivot: the explicit moments shrink by a factor near per step and are 0 in floating point from on.
Correctness
The proof in proofs/correctness.md shows:
- q = 1 in full. with , so matches and .
- Any q, without breakdown. The vectors are biorthogonal; for ; and is the transpose of the left recurrence's matrix times . Together these give for . This is Feldmann and Freund's theorem, which they also prove with look-ahead.
- has a numerator of degree at most and a denominator of degree , so it is the Padé approximant, the model of AWE; with it equals .
Breakdown, rounding and passivity are not covered by the proof. The tests check, in exact rational arithmetic:
- The hand example, step by step.
- 40 random unsymmetric systems of order 3 to 6 (seed 91), every order , real expansion points from to 2: the first moments of the model equal the exact moments in every case, and moment differs in all 141 cases with .
- With seed 92, the model equals the AWE rational function at three rational points for each order.
- With seed 93, reproduces at three points.
- The transposed solve with the LU factors of equals a direct solve with (seed 94).
In floating point they check the two lines above: PVL below at on the RC line and below at on the RLC line, while AWE stays above and above .
Proof: PVL with q Lanczos steps matches 2q moments of the transfer functionfull
We use the notation of the page. The circuit is with output . For the expansion point with nonsingular, put and . Then for ,
for below , where is the spectral radius. The are the moments at .
The process. Take nonzero scalars and set , , . For , while :
with any nonzero scale factors (the code uses the largest entry). PVL returns , where is the tridiagonal matrix with diagonal , subdiagonal and superdiagonal . We assume , which is the condition that no breakdown occurs.
The case q = 1
Theorem 1. If , then matches and .
Proof. with , since the scale factors cancel. So
whose first two coefficients are and .
The third coefficient is , which is not in general: in the example of the page, and . At the one pole of the model is . For an RC circuit with , is the Elmore delay, so the pole is .
The general case
The full result is Feldmann and Freund's (1995). We give a complete proof for the version above, which has no look-ahead.
Lemma 1 (biorthogonality). If , then for all with .
Proof. Induction on : suppose the claim holds for all indices up to ; we show for (the claim for against is the same argument with and ). Up to the factor ,
For it is by the choice of . For write . If , the hypothesis leaves , and the sum is by the choice of . If , every index on the right is below , so every term is 0.
Matrix form. With , and , the recurrences read
where has the same diagonal, subdiagonal and superdiagonal . By Lemma 1, , and . Multiply the first identity by and the transpose of the second by :
Lemma 2. For , , and for a scalar . In the same way for .
Proof. is tridiagonal, so is zero below entry . Suppose for some . Then . The last factor is 0 when , and it is some scalar when . The case is .
Theorem 2 (moment matching). If , then for . Hence .
Proof. Write with and . By Lemma 2,
with unless , and . By (1), , so , and . Finally . The expansion gives the second claim.
Corollary 1 (it is the Padé approximant). By Cramer's rule, , where is without its first row and column. So is a rational function with a numerator of degree at most and a denominator of degree at most with value 1 at , and it matches moments. When the Padé approximant of at exists, it is the unique such function, so is that approximant: the same model that AWE computes from the explicit moments. The two methods differ only in rounding. The poles of are for the nonzero eigenvalues of .
Corollary 2 (q = N is exact). If for the order of , then .
Proof. is nonsingular, so and are. Then forces the vector to vanish, so , and . With and , .
What is not proved
- Breakdown. If some while , the process stops; the approximant may then not exist, or may need a look-ahead variant of the Lanczos process, which Feldmann and Freund use. The code reports the breakdown.
- Rounding. In floating point the vectors lose their biorthogonality, as in every Lanczos process. The tests measure the accuracy on two lines; they do not prove a bound.
- Stability and passivity. A Padé model of a stable or passive circuit can have poles in the right half plane, or fail to be passive. The theorem says nothing about that; PRIMA, a congruence method, was designed to keep passivity.
Complexity
Line L1 is one sparse factorization, cost . Each step costs one solve with , one with , two products with and for the dot products and vector updates, so steps cost . Only the last two vectors of each sequence are kept, , and takes . Evaluating the model at frequencies costs with a tridiagonal solver. AWE has the same cost for the moments; the difference is accuracy, not time. The implementation uses dense LU, so its is and its is .
Properties
- Padé accuracy. moments from steps, the most that a model of order with zeros can match.
- Numerically stable in practice. The vectors are rescaled at every step, and the recurrence orthogonalizes against the previous directions, so the information that AWE loses to rounding is kept. The tables are measurements, not a bound.
- Not passive in general. The model of a passive RLC circuit can have poles in the right half plane or produce energy at its ports. Passivity is not part of the Padé conditions.
- One input and one output. PVL is for a single transfer function; matrix-Padé variants with block Lanczos handle several ports.
- The expansion point sets the band. Accuracy is best near and fades with distance from it.
Variants and improvements
- Look-ahead Lanczos. When is 0 or tiny, look-ahead steps over the gap with small blocks. Feldmann and Freund use this version.
- Several ports. A block version of the Lanczos process handles circuits with several inputs and outputs and matches block moments.
- PRIMA. The Arnoldi process and a congruence projection give passive models of RLC circuits at the price of matching block moments instead of : PRIMA.
- Several expansion points. Rational Krylov methods combine expansions at several to cover a wide band.
When to use it
Use PVL to reduce a large linear network with one input and one output, such as an interconnect line or a filter, for a fast frequency or time response, or for many noise or AC evaluations. Use it instead of AWE whenever more than a few poles are needed. When the model is connected back to a nonlinear circuit for transient simulation, prefer a passive method such as PRIMA, or check the poles and the passivity of the PVL model.
Pitfalls
- Breakdown. with nonzero vectors stops the plain process. The code reports it; a robust code needs look-ahead.
- Unstable poles. A model of a stable circuit can have a pole with positive real part, which turns into a growing exponential in a time-domain simulation. Discard or reflect such poles, or use a passive method.
- Loss of biorthogonality. In floating point the vectors drift away from biorthogonality, as in every Lanczos process. The accuracy can stall: on the RLC line with the expansion point at , the error stopped at from to .
- The expansion point. suits RC circuits and step responses; resonant RLC lines need a point inside the band, or several points.
- Comparing with AWE at low order. At low order the two give the same model; the difference appears only where the explicit moments lose accuracy.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/pade-via-lanczos/. The authors are listed in prov/JW00K7.jsonl.
"""Pade via Lanczos (PVL) for a linear circuit G x + s C x = b u, y = l^T x.
With the expansion point s0, K = G + s0 C, A = -K^{-1} C and r = K^{-1} b,
the transfer function is H(s0 + sigma) = l^T (I - sigma A)^{-1} r, whose
Taylor coefficients are the moments m_k = l^T A^k r. The nonsymmetric Lanczos
process on A with the start vectors r and l gives a q x q tridiagonal T_q, and
H_q(s0 + sigma) = (l^T r) e1^T (I - sigma T_q)^{-1} e1 matches m_0..m_{2q-1}.
The code works with float or Fraction entries; with Fraction it is exact.
Vectors are scaled by their largest entry, which keeps Fractions exact.
"""
import sim3dense
class Breakdown(ArithmeticError):
"""w_k^T v_k = 0 with nonzero v_k, w_k: the process needs look-ahead."""
def lu_factor(a):
"""Partial-pivoting LU of a square matrix: returns (lu, perm)."""
n = len(a)
lu = [list(row) for row in a]
perm = list(range(n))
for k in range(n):
p = max(range(k, n), key=lambda i: abs(lu[i][k]))
if lu[p][k] == 0:
raise sim3dense.SingularMatrixError(f"zero pivot in column {k}")
lu[k], lu[p] = lu[p], lu[k]
perm[k], perm[p] = perm[p], perm[k]
for i in range(k + 1, n):
f = lu[i][k] / lu[k][k]
lu[i][k] = f
if f != 0:
for j in range(k + 1, n):
lu[i][j] -= f * lu[k][j]
return lu, perm
def lu_solve(fac, b):
"""Solve K x = b with the factors of K."""
lu, perm = fac
n = len(lu)
y = [b[p] for p in perm]
for i in range(n):
y[i] = y[i] - sum(lu[i][k] * y[k] for k in range(i))
for i in range(n - 1, -1, -1):
y[i] = (y[i] - sum(lu[i][k] * y[k] for k in range(i + 1, n))) / lu[i][i]
return y
def lu_solve_transposed(fac, b):
"""Solve K^T x = b with the same factors (P K = L U, so K^T = U^T L^T P)."""
lu, perm = fac
n = len(lu)
z = list(b)
for i in range(n):
z[i] = (z[i] - sum(lu[k][i] * z[k] for k in range(i))) / lu[i][i]
for i in range(n - 1, -1, -1):
z[i] = z[i] - sum(lu[k][i] * z[k] for k in range(i + 1, n))
x = [0 * z[0]] * n
for i, p in enumerate(perm):
x[p] = z[i]
return x
def _dot(x, y):
return sum(a * b for a, b in zip(x, y))
def _scale(x):
return max(abs(v) for v in x)
def pvl(G, C, b, l, s0, q, tol=0.0):
"""Run q steps of PVL. Returns (m0, T) with T the q x q tridiagonal matrix."""
n = len(G)
K = [[G[i][j] + s0 * C[i][j] for j in range(n)] for i in range(n)]
fac = lu_factor(K) # @line L1
r = lu_solve(fac, b)
rho, eta = _scale(r), _scale(l)
if rho == 0 or eta == 0:
raise ValueError("b and l must be nonzero")
v, w = [x / rho for x in r], [x / eta for x in l]
d = _dot(w, v) # @line L2
if abs(d) <= tol * _scale(v) * _scale(w) * n or d == 0:
raise Breakdown("l^T r = 0")
m0 = rho * eta * d
alpha, beta, sub = [], [], []
v_prev, w_prev, d_prev = [0 * x for x in v], [0 * x for x in w], None
rho_k, eta_k = None, None
for k in range(q): # @line L3
cv = sim3dense.matvec(C, v)
av = [-x for x in lu_solve(fac, cv)] # @line L4
y = lu_solve_transposed(fac, w)
aw = [-x for x in sim3dense.matvec(sim3dense.transpose(C), y)]
a = _dot(w, av) / d # @line L5
bt = eta_k * d / d_prev if k else 0 * a
gm = rho_k * d / d_prev if k else 0 * a
alpha.append(a)
if k:
beta.append(bt)
if k == q - 1:
break
vt = [x - a * y1 - bt * y0 for x, y1, y0 in zip(av, v, v_prev)] # @line L6
wt = [x - a * y1 - gm * y0 for x, y1, y0 in zip(aw, w, w_prev)]
rho_k, eta_k = _scale(vt), _scale(wt)
if rho_k == 0 or eta_k == 0: # an invariant subspace: H_k is exact
break
v_prev, w_prev, d_prev = v, w, d
v, w = [x / rho_k for x in vt], [x / eta_k for x in wt]
d = _dot(w, v) # @line L7
if d == 0 or abs(d) <= tol * n:
raise Breakdown(f"w^T v = 0 at step {k + 2}")
sub.append(rho_k)
size = len(alpha)
T = [[0 * m0] * size for _ in range(size)] # @line L8
for i in range(size):
T[i][i] = alpha[i]
if i + 1 < size:
T[i + 1][i] = sub[i]
T[i][i + 1] = beta[i]
return m0, T # @line L9
def model_eval(m0, T, s0, s):
"""H_q(s) = m0 e1^T (I - (s - s0) T)^{-1} e1."""
sig = s - s0
n = len(T)
M = [[(1 if i == j else 0) - sig * T[i][j] for j in range(n)] for i in range(n)]
e1 = [1] + [0] * (n - 1)
return m0 * sim3dense.solve(M, e1)[0]
def model_moments(m0, T, count):
"""m0 e1^T T^k e1 for k < count."""
n = len(T)
x = [1] + [0 * m0] * (n - 1)
out = []
for _ in range(count):
out.append(m0 * x[0])
x = [sum(T[i][j] * x[j] for j in range(n)) for i in range(n)]
return out
def exact_moments(G, C, b, l, s0, count):
"""m_k = l^T A^k r, computed by repeated solves (as in AWE)."""
n = len(G)
fac = lu_factor([[G[i][j] + s0 * C[i][j] for j in range(n)] for i in range(n)])
x = lu_solve(fac, b)
out = []
for _ in range(count):
out.append(_dot(l, x))
x = [-v for v in lu_solve(fac, sim3dense.matvec(C, x))]
return out
def awe(moments, q):
"""Pade [q-1/q] from 2q moments by the Hankel system (AWE).
Returns (num, den): num has q coefficients, den has q + 1 with den[0] = 1.
"""
m = moments
H = [[m[q + i - j - 1] for j in range(q)] for i in range(q)]
rhs = [-m[q + i] for i in range(q)]
tail = sim3dense.solve(H, rhs)
den = [1] + tail
num = [sum(den[j] * m[i - j] for j in range(i + 1)) for i in range(q)]
return num, den
def rational_eval(num, den, sig):
def poly(c):
acc = 0
for x in reversed(c):
acc = acc * sig + x
return acc
return poly(num) / poly(den)
def transfer(G, C, b, l, s):
n = len(G)
Y = [[G[i][j] + s * C[i][j] for j in range(n)] for i in range(n)]
return _dot(l, sim3dense.solve(Y, [complex(x) for x in b]))
def rlc_line(sections, r, ind, cap, rs, rl):
"""MNA matrices of a lumped RLC line: a 1 A source with resistance rs drives
node 1; each section has a series r and ind and a cap to ground; rl
terminates the far end. Unknowns: the node voltages, then the inductor
currents. The output is the far-end voltage."""
n = sections + 1 # nodes 0..sections, plus the inductor-current unknowns
N = n + sections
G = [[0.0] * N for _ in range(N)]
C = [[0.0] * N for _ in range(N)]
G[0][0] += 1 / rs
G[n - 1][n - 1] += 1 / rl
for k in range(sections):
a, c, j = k, k + 1, n + k # node a - r - L - node c, current j
# the series r and L as one branch: e_a - e_c - r j - ind dj/dt = 0
G[a][j] += 1
G[c][j] -= 1
G[j][a] += 1
G[j][c] -= 1
G[j][j] -= r
C[j][j] -= ind
C[c][c] += cap
b = [0.0] * N
b[0] = 1.0
l = [0.0] * N
l[n - 1] = 1.0
return G, C, b, l
sim3dense.py 70 lines
# SPDX-License-Identifier: MIT
# Shared helper of the sim3 eda pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Small dense linear algebra for Fraction, float or complex entries.
The circuit pages of group sim3 use this module as a reference solver and for
the small dense systems inside their tests. It holds no sparse method and no
circuit method. Matrices are lists of rows.
"""
from fractions import Fraction
class SingularMatrixError(ValueError):
"""The matrix has no inverse (a zero pivot in exact arithmetic)."""
def _exact(x):
return Fraction(x) if isinstance(x, int) else x
def solve(a, b, tol=0.0):
"""Solve a x = b by Gaussian elimination with partial pivoting.
With Fraction entries the result is exact. b is a vector or a matrix
(a list of rows); the result has the same shape.
"""
n = len(a)
m = [[_exact(x) for x in row] for row in a]
vec = not (b and isinstance(b[0], list))
rhs = [[_exact(x)] for x in b] if vec else [[_exact(x) for x in row] for row in b]
for k in range(n):
p = max(range(k, n), key=lambda i: abs(m[i][k]))
if abs(m[p][k]) <= tol:
raise SingularMatrixError(f"zero pivot in column {k}")
m[k], m[p] = m[p], m[k]
rhs[k], rhs[p] = rhs[p], rhs[k]
for i in range(k + 1, n):
if m[i][k] != 0:
f = m[i][k] / m[k][k]
for j in range(k, n):
m[i][j] -= f * m[k][j]
for j in range(len(rhs[i])):
rhs[i][j] -= f * rhs[k][j]
x = [[0] * len(rhs[0]) for _ in range(n)]
for i in range(n - 1, -1, -1):
for j in range(len(rhs[0])):
s = rhs[i][j] - sum(m[i][k] * x[k][j] for k in range(i + 1, n))
x[i][j] = s / m[i][i]
return [r[0] for r in x] if vec else x
def transpose(a):
return [list(r) for r in zip(*a)]
def matvec(a, x):
return [sum(aij * xj for aij, xj in zip(row, x)) for row in a]
def matmul(a, b):
bt = transpose(b)
return [[sum(x * y for x, y in zip(row, col)) for col in bt] for row in a]
def identity(n, one=1):
return [[one if i == j else 0 * one for j in range(n)] for i in range(n)]
def inverse(a):
return solve(a, identity(len(a)))
test_pade_via_lanczos.py 179 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/pade-via-lanczos/. The authors are listed in prov/JW00K7.jsonl.
import math
import random
from fractions import Fraction as Fr
import pytest
import sim3dense
from pade_via_lanczos import (
Breakdown,
awe,
exact_moments,
lu_factor,
lu_solve,
lu_solve_transposed,
model_eval,
model_moments,
pvl,
rational_eval,
rlc_line,
transfer,
)
def two_node():
"""1 S from node 1 to ground and from node 1 to node 2, 1 F from each node
to ground, 1 A into node 1, output node 2: G = [[2, -1], [-1, 1]], C = I."""
G = [[Fr(2), Fr(-1)], [Fr(-1), Fr(1)]]
C = [[Fr(1), Fr(0)], [Fr(0), Fr(1)]]
return G, C, [Fr(1), Fr(0)], [Fr(0), Fr(1)]
def test_hand_example():
G, C, b, l = two_node()
assert exact_moments(G, C, b, l, 0, 5) == [1, -3, 8, -21, 55]
m0, T = pvl(G, C, b, l, Fr(0), 1)
assert (m0, T) == (1, [[-3]])
assert model_moments(m0, T, 3) == [1, -3, 9] # two moments match, the third does not
m0, T = pvl(G, C, b, l, Fr(0), 2)
assert T == [[-3, -1], [1, 0]]
for s in (Fr(0), Fr(1), Fr(-1, 2), Fr(7, 3)):
assert model_eval(m0, T, 0, s) == 1 / (s * s + 3 * s + 1) # exact for q = n
def random_circuit(rng, n):
G = [[Fr(rng.randint(-3, 3)) for _ in range(n)] for _ in range(n)]
for i in range(n):
G[i][i] += 3 * n
C = [[Fr(rng.randint(-2, 2)) for _ in range(n)] for _ in range(n)]
b = [Fr(rng.randint(-2, 2)) for _ in range(n)]
l = [Fr(rng.randint(-2, 2)) for _ in range(n)]
b[0], l[-1] = Fr(1), Fr(1) # nonzero
return G, C, b, l
def test_exact_arithmetic_matches_2q_moments():
rng = random.Random(91)
short = more = 0
for _ in range(40):
n = rng.randint(3, 6)
G, C, b, l = random_circuit(rng, n)
s0 = Fr(rng.randint(-1, 2))
ref = exact_moments(G, C, b, l, s0, 2 * n + 1)
for q in range(1, n + 1):
m0, T = pvl(G, C, b, l, s0, q) # no breakdown occurs with this seed
got = model_moments(m0, T, 2 * q + 1)
assert got[: 2 * q] == ref[: 2 * q]
if q == n:
assert got[2 * q] == ref[2 * q] # the full model matches every moment
else:
short += 1
more += got[2 * q] != ref[2 * q]
assert short == 141 and more == short # moment 2q is missed in every case
def test_same_model_as_awe_in_exact_arithmetic():
rng = random.Random(92)
for _ in range(20):
n = rng.randint(3, 6)
G, C, b, l = random_circuit(rng, n)
for q in range(1, n):
try:
m0, T = pvl(G, C, b, l, Fr(0), q)
num, den = awe(exact_moments(G, C, b, l, 0, 2 * q), q)
except (Breakdown, sim3dense.SingularMatrixError):
break
for sig in (Fr(1, 7), Fr(-2, 5), Fr(3)):
try:
want = rational_eval(num, den, sig)
except ZeroDivisionError:
continue
assert model_eval(m0, T, 0, sig) == want
def test_q_equal_n_reproduces_the_transfer_function():
rng = random.Random(93)
for _ in range(10):
n = rng.randint(2, 5)
G, C, b, l = random_circuit(rng, n)
try:
m0, T = pvl(G, C, b, l, Fr(0), n)
except Breakdown:
continue
for s in (Fr(1, 3), Fr(2), Fr(-1, 5)):
Y = [[G[i][j] + s * C[i][j] for j in range(n)] for i in range(n)]
want = sum(a * x for a, x in zip(l, sim3dense.solve(Y, b)))
assert model_eval(m0, T, 0, s) == want
def test_breakdown_is_reported():
G = [[Fr(1), Fr(0)], [Fr(0), Fr(1)]]
C = [[Fr(1), Fr(1)], [Fr(0), Fr(1)]]
with pytest.raises(Breakdown):
pvl(G, C, [Fr(1), Fr(0)], [Fr(0), Fr(1)], Fr(0), 2) # l^T r = 0
def test_transposed_solve_reuses_the_factors():
rng = random.Random(94)
for _ in range(20):
n = rng.randint(1, 8)
K = [[Fr(rng.randint(-5, 5)) for _ in range(n)] for _ in range(n)]
for i in range(n):
K[i][i] += 11
w = [Fr(rng.randint(-5, 5)) for _ in range(n)]
fac = lu_factor(K)
assert lu_solve(fac, w) == sim3dense.solve(K, w)
assert lu_solve_transposed(fac, w) == sim3dense.solve(sim3dense.transpose(K), w)
def rc_line(n, r, c, rs, rload):
N = n + 1
G = [[0.0] * N for _ in range(N)]
C = [[0.0] * N for _ in range(N)]
for k in range(n):
g = 1 / r
G[k][k] += g
G[k + 1][k + 1] += g
G[k][k + 1] -= g
G[k + 1][k] -= g
C[k + 1][k + 1] += c
G[0][0] += 1 / rs
G[N - 1][N - 1] += 1 / rload
b = [0.0] * N
b[0] = 1.0
l = [0.0] * N
l[-1] = 1.0
return G, C, b, l
def errors(G, C, b, l, s0, fs, qs):
exact = [transfer(G, C, b, l, 2j * math.pi * f) for f in fs]
peak = max(abs(h) for h in exact)
mom = exact_moments(G, C, b, l, s0, 2 * max(qs))
out = {}
for q in qs:
m0, T = pvl(G, C, b, l, s0, q)
e_pvl = max(abs(model_eval(m0, T, s0, 2j * math.pi * f) - h) for f, h in zip(fs, exact)) / peak
num, den = awe(mom, q)
e_awe = max(abs(rational_eval(num, den, 2j * math.pi * f - s0) - h) for f, h in zip(fs, exact)) / peak
out[q] = (e_pvl, e_awe)
return out
def test_rc_line_pvl_converges_and_awe_stalls():
fs = [10 ** (6 + 4 * i / 120) for i in range(121)]
e = errors(*rc_line(60, 10.0, 10e-15, 50.0, 1e6), 0.0, fs, [2, 4, 8, 12])
assert e[2][0] == pytest.approx(e[2][1], rel=1e-6) # the same model while the moments are accurate
assert e[4][0] < 1e-4 and e[8][0] < 1e-12 and e[12][0] < 1e-12
assert e[8][1] > 1e-9 and e[12][1] > 1e-9 # explicit moments lose the later directions
def test_rlc_line_with_a_real_expansion_point():
G, C, b, l = rlc_line(20, 2.0, 1e-9, 1e-12, 25.0, 50.0)
fs = [1e8 + (3e9 - 1e8) * i / 120 for i in range(121)]
e = errors(G, C, b, l, 2 * math.pi * 1e9, fs, [20, 30])
assert e[20][0] < 1e-6 and e[30][0] < 1e-10
assert e[20][1] > 1e-3
History
Lanczos (1950) gave the two-sided process for nonsymmetric matrices, with left and right vectors that are biorthogonal. AWE (Pillage and Rohrer, 1990) made Padé approximation from moments a standard tool for interconnect analysis, but its explicit moments limit the useful order. Feldmann and Freund (1995) showed that the Lanczos process gives the same Padé approximant without the explicit moments, with look-ahead against breakdown, and named the method PVL. PVL gives no passivity guarantee, and PRIMA (1997 and 1998) was presented as a passive alternative.
References
- Peter Feldmann and Roland W. Freund, Efficient linear circuit analysis by Padé approximation via the Lanczos process, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 14(5), 639 to 649, 1995, the PVL algorithm, the theorem that q Lanczos steps give the Padé approximant with 2q matched moments, the look-ahead Lanczos process and the comparison with AWE
- Cornelius Lanczos, An iteration method for the solution of the eigenvalue problem of linear differential and integral operators, Journal of Research of the National Bureau of Standards 45(4), from page 255, 1950, the two-sided (biorthogonal) form of the process for a nonsymmetric matrix
- Yousef Saad, Iterative Methods for Sparse Linear Systems, second edition, SIAM, 2003, Section 7.1, Lanczos biorthogonalization (the recurrences, the biorthogonality and the breakdowns)
- Lawrence T. Pillage and Ronald A. Rohrer, Asymptotic waveform evaluation for timing analysis, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 9(4), 352 to 366, 1990, the Padé model from explicit moments that PVL replaces
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag JW00K7 Edit this page History Report an error Markdown