diff --git a/pyssp/modeling.py b/pyssp/modeling.py index 5f4ee8b..886cfda 100644 --- a/pyssp/modeling.py +++ b/pyssp/modeling.py @@ -1,6 +1,5 @@ """Chapter 4 modeling algorithm implementations.""" -from numpy.linalg import inv import numpy as np import scipy as sp @@ -21,7 +20,7 @@ def pade(x, p, q): # Linear difference matrix spanning the number of zeros Xq = X[q + 1:q + p + 1, 1:p + 1].copy() print(Xq.shape) - a = linalg.solve(-Xq, X[q + 1: q + p + 1, 0]) + a = np.linalg.solve(-Xq, X[q + 1: q + p + 1, 0]) # a(0) normalized to 1 a = np.concatenate((np.ones(1), a)).reshape(-1, 1) b = X[:q + 1, :p + 1] @ a @@ -60,7 +59,7 @@ def prony(x, p, q): Xq1 = X[q + 1:N + p, 0].copy() Xq_H = Xq.conjugate().transpose() rx = Xq_H @ Xq1 - Xinv = linalg.inv(Xq_H @ Xq) + Xinv = np.linalg.inv(Xq_H @ Xq) a = -Xinv @ rx print(a.shape) # a(0) normalized to 1 @@ -94,7 +93,7 @@ def shanks(x, p, q): gx = G0_H @ x0 # the factorization does not guarantee nonsingularity! # resulting matrix is positive *semi*-definite - Ginv = linalg.inv(G0_H @ G0) + Ginv = np.linalg.inv(G0_H @ G0) print(f"{x.shape=}") print(f"{Ginv.shape=}") b = Ginv @ gx @@ -118,7 +117,7 @@ def spike(g, n0, n): G_H = np.transpose(G.conjugate()) print(f"{G_H.shape=}, {G.shape=}") - Ginv = linalg.inv(G_H @ G) + Ginv = np.linalg.inv(G_H @ G) h = Ginv @ G_H @ d return h @@ -162,7 +161,7 @@ def covm(x, p): cx = X[p:N, 0].copy() Xq_H = Xq.copy().conjugate().transpose() print(f"{Xq=}") - Xinv = linalg.inv(Xq_H @ Xq) + Xinv = np.linalg.inv(Xq_H @ Xq) a1 = -Xinv @ Xq_H @ cx a = np.concatenate((np.ones(1), a1)).reshape(-1, 1) err = np.abs(cx.transpose() @ X[p:N,] @ a)