This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
e = 0.0 | |
for i in range(1000): | |
A = np.random.randn(10,10) | |
U, S, Vh = np.linalg.svd(A) | |
V = Vh.T | |
A1 = S[0] * (np.outer(U[:,0], V[:,0])) | |
e = e + np.linalg.norm(A - A1, 2)**2 | |
print(e / 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
e = 0.0 | |
for i in range(1000): | |
A = np.random.randn(10,10) | |
U, S, Vh = np.linalg.svd(A) | |
V = Vh.T | |
A1 = S[0] * (np.outer(U[:,0], V[:,0])) | |
e = e + np.linalg.norm(A - A1)**2 | |
print(e / 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import sys | |
# Parameters: (w_i, theta_i) | |
n_theta_vals = 6 | |
if len(sys.argv) > 1: | |
n_theta_vals = int(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Linde-Buzo-Gray / Generalized Lloyd algorithm implementation in Python *3*. | |
Heuristic process that can be used to generate cluster points from a big amount of multidimensional vectors. | |
""" | |
import numpy as np | |
import math | |
from functools import reduce | |
from collections import defaultdict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import numpy.linalg as LA | |
def flag_distance(mat1, mat2): | |
n_columns = mat1.shape[1] | |
running_metric = 0.0 | |
for i in range(n_columns): | |
running_metric = LA.norm(np.outer(mat1[:,i], mat1[:,i].conj()) - np.outer(mat2[:,i], mat2[:,i].conj()), 'fro')**2 | |
return np.sqrt(running_metric) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.linalg as la | |
import numpy.linalg as LA | |
import matplotlib.pyplot as plt | |
def gradient_descent(V1, V2, subopt=False, mu=1, epsilon=1e-11, permute=True): | |
""" Performs gradient descent over flag manifold. Attempts to find the | |
geodesic with the minimum length between two (given) square-matrices on the manifold """ | |
V1 = np.matrix(V1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
M = 4; | |
N = 4; | |
W = np.exp(1j * 2 * np.pi * np.outer(np.arange(M*N), np.arange(M*N)) / N / M) / np.sqrt(N * M); | |
Nt = 3; | |
Nr = 2; | |
## In the slide 39 of this: | |
## https://ecse.monash.edu/staff/eviterbo/OTFS-VTC18/Tutorial_ICC2019___OTFS_modulation.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
t = np.arange(-10, 10, 0.001) | |
r = np.zeros_like(t);N = 100; | |
for i in range(-N, N + 1): | |
r = r + np.exp(1j * 2 * np.pi * t * i) | |
plt.plot(t, np.real(r));plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear; | |
M = 4; | |
N = 4; | |
W = exp(1j * 2 * pi * (0:(M*N-1))' * (0:(M*N-1)) / N / M) / sqrt(N * M); | |
Nt = 3; | |
Nr = 2; | |
## In the slide 39 of this: | |
## https://ecse.monash.edu/staff/eviterbo/OTFS-VTC18/Tutorial_ICC2019___OTFS_modulation.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
A = np.array([[ 1, 0, 1, 0], | |
[-1, 1, 0, 1], | |
[ 0, -1, 0, -1], | |
[ 0, 0, -1, 0], | |
[ 0, 0, 0, 0]]) | |
def cluster_columns(M): | |
column_dict = {} |
NewerOlder