Skip to content

Commit

Permalink
testin 1, 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdi committed Nov 21, 2023
1 parent 828aa30 commit 2b03a60
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pyssp/modeling.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Chapter 4 modeling algorithm implementations."""

from numpy.linalg import inv
import numpy as np
import scipy as sp

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2b03a60

Please sign in to comment.