Skip to content

Commit 1ace6f2

Browse files
committed
5章q04を変更
1 parent a8e98fb commit 1ace6f2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

khashimoto/chapter05/q04.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,23 @@ def spatial_correlation_matrix(*X):
1212
sum = np.zeros((M, M), dtype=complex)
1313
for t in range(T):
1414
# a.
15-
x_ft = np.zeros((M, 1), dtype=complex)
15+
x_ft = np.zeros(M, dtype=complex)
1616
for m in range(M):
17-
x_ft[m][0] = X[m][f][t]
17+
x_ft[m] = X[m][f][t]
18+
x_ft = np.array([x_ft]).T
1819

1920
# b.
2021
sum = np.add(sum, x_ft @ np.conj(x_ft.T))
2122
R[f] = sum / T
22-
return tuple(R)
23+
return R
2324

2425

2526
X_1 = np.array([[1, -1j, -1, 1j], [2, -2j, -2, 2j], [3, -3j, -3, 3j]])
2627
X_2 = np.array([[4, -2j, 1, 0], [2, -1j, 0, 0], [1, -1j, 1, 0]])
27-
R_0, R_1, R_2 = spatial_correlation_matrix(X_1, X_2)
28-
print(R_0)
29-
print(R_1)
30-
print(R_2)
28+
R = spatial_correlation_matrix(X_1, X_2)
29+
print(R[0])
30+
print(R[1])
31+
print(R[2])
3132

3233
# # [[1. +0.j 1.25+0.j]
3334
# [1.25+0.j 5.25+0.j]]

0 commit comments

Comments
 (0)