def build_win_mats(windows, frames): """Builds a window matrix of a given size for each window in a collection. `windows` specifies the collection of windows as a sequence of `(l, u, win_coeff)` triples, where `l` and `u` are non-negative integers specifying the left and right extents of the window and `win_coeff` is an array specifying the window coefficients. The returned value is a list of window matrices, one for each of the windows specified in `windows`. Each window matrix is a `frames` by `frames` Toeplitz matrix with lower bandwidth `l` and upper bandwidth `u`. The non-zero coefficients in each row of this Toeplitz matrix are given by `win_coeff`. The returned window matrices are stored as BandMats, i.e. using a banded representation. """ win_mats = [] for l, u, win_coeff in windows: assert l >= 0 and u >= 0 assert len(win_coeff) == l + u + 1 win_coeffs = np.tile(np.reshape(win_coeff, (l + u + 1, 1)), frames) win_mat = bm.band_c_bm(u, l, win_coeffs).T win_mats.append(win_mat) return win_mats
def _build_win_mats(windows, num_frames): r"""For MLPG. Builds a window matrix of a given size for each window in a collection. Parameters ---------- windows : list[window] Specifies the collection of windows as a sequence of `window` tuples with the structure `(l, u, win_coeff)`, where `l` and `u` are non-negative integers specifying the left and right extents of the window and `win_coeff` is an array specifying the window coefficients. num_frames : int Number of frames in the signal. Returns ------- list[BandMat] Window matrices, one for each of the windows specified in `windows`. Each window matrix is a `frames` by `frames` Toeplitz matrix with lower bandwidth `l` and upper bandwidth `u`. The non-zero coefficients in each row of this Toeplitz matrix are given by `win_coeff`. The window matrices are stored as BandMats, i.e. using a banded representation. """ win_mats = [] for l, u, win_coeff in windows: assert l >= 0 and u >= 0 assert len(win_coeff) == l + u + 1 win_coeffs = np.tile(np.reshape(win_coeff, (l + u + 1, 1)), num_frames) win_mat = bm.band_c_bm(u, l, win_coeffs).T win_mats.append(win_mat) return win_mats
def build_win_mats(self, windows, frames): win_mats = [] for l, u, win_coeff in windows: assert l >= 0 and u >= 0 assert len(win_coeff) == l + u + 1 win_coeffs = np.tile(np.reshape(win_coeff, (l + u + 1, 1)), frames) win_mat = bm.band_c_bm(u, l, win_coeffs).T win_mats.append(win_mat) return win_mats
def build_win_mats(windows, frames): """Builds a window matrix of a given size for each window in a collection. """ winMats = [] for l, u, winCoeff in windows: assert l >= 0 and u >= 0 assert len(winCoeff) == l + u + 1 winCoeffs = np.tile(np.reshape(winCoeff, (l + u + 1, 1)), frames) winMat = bm.band_c_bm(u, l, winCoeffs).T winMats.append(winMat) return winMats
def test_band_c_bm(self, its=50): for it in range(its): size = random.choice([0, 1, randint(0, 10), randint(0, 100)]) l = random.choice([0, 1, randint(0, 10)]) u = random.choice([0, 1, randint(0, 10)]) mat_rect = randn(l + u + 1, size) mat_bm = bm.band_c_bm(l, u, mat_rect) mat_full_good = fl.band_c(l, u, mat_rect) assert_allequal(mat_bm.full(), mat_full_good) assert not np.may_share_memory(mat_bm.data, mat_rect)
def build_win_mats(windows, T): win_mats = [] for l, u, win_coeff in windows: win_coeffs = numpy.tile(numpy.reshape(win_coeff, (l + u + 1, 1)), T) win_mat = bandmat.band_c_bm(u, l, win_coeffs).T win_mats.append(win_mat) return win_mats
def build_win_mats(windows, T): """Builds a window matrix of a given size for each window in a collection. Args: windows(list): specifies the collection of windows as a sequence of ``(l, u, win_coeff)`` triples, where ``l`` and ``u`` are non-negative integers pecifying the left and right extents of the window and ``win_coeff`` is an array specifying the window coefficients. T (int): Number of frames. Returns: list: The returned value is a list of window matrices, one for each of the windows specified in ``windows``. Each window matrix is a ``T`` by ``T`` Toeplitz matrix with lower bandwidth ``l`` and upper bandwidth ``u``. The non-zero coefficients in each row of this Toeplitz matrix are given by ``win_coeff``. The returned window matrices are stored as BandMats, i.e. using a banded representation. Examples: >>> from nnmnkwii import paramgen as G >>> import numpy as np >>> windows = [ ... (0, 0, np.array([1.0])), # static ... (1, 1, np.array([-0.5, 0.0, 0.5])), # delta ... (1, 1, np.array([1.0, -2.0, 1.0])), # delta-delta ... ] >>> win_mats = G.build_win_mats(windows, 3) """ win_mats = [] for l, u, win_coeff in windows: assert l >= 0 and u >= 0 assert len(win_coeff) == l + u + 1 win_coeffs = np.tile(np.reshape(win_coeff, (l + u + 1, 1)), T) win_mat = bm.band_c_bm(u, l, win_coeffs).T win_mats.append(win_mat) return win_mats