mgplvm.fast_utils.toeplitz module

MIT License

Copyright (c) 2017 Jake Gardner

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

mgplvm.fast_utils.toeplitz.sym_toeplitz(toeplitz_column)[source]

Constructs tensor version of symmetric toeplitz matrix from column vector Args:

  • toeplitz_column (vector n) - column of Toeplitz matrix

Returns:
  • Matrix (n x n) - matrix representation

mgplvm.fast_utils.toeplitz.sym_toeplitz_derivative_quadratic_form(left_vectors, right_vectors)[source]
Given a left vector v1 and a right vector v2, computes the quadratic form:

v1’*(dT/dc_i)*v2

for all i, where dT/dc_i is the derivative of the Toeplitz matrix with respect to the ith element of its first column. Note that dT/dc_i is the same for any symmetric Toeplitz matrix T, so we do not require it as an argument. In particular, dT/dc_i is given by:

[0 0; I_{m-i+1} 0] + [0 I_{m-i+1}; 0 0]

where I_{m-i+1} is the (m-i+1) dimensional identity matrix. In other words, dT/dc_i for i=1..m is the matrix with ones on the ith sub- and superdiagonal. Args:

  • left_vectors (vector m or matrix s x m) - s left vectors u[j] in the quadratic form.

  • right_vectors (vector m or matrix s x m) - s right vectors v[j] in the quadratic form.

Returns:
  • vector m - a vector so that the ith element is the result of sum_j(u[j]*(dT/dc_i)*v[j])

mgplvm.fast_utils.toeplitz.sym_toeplitz_getitem(toeplitz_column, i, j)[source]

Gets the (i,j)th entry of a symmetric Toeplitz matrix T. Args:

  • toeplitz_column (vector n) - column of symmetric Toeplitz matrix

  • i (scalar) - row of entry to get

  • j (scalar) - column of entry to get

Returns:
  • T[i,j], where T is the Toeplitz matrix specified by c and r.

mgplvm.fast_utils.toeplitz.sym_toeplitz_matmul(toeplitz_column, tensor)[source]

Performs a matrix-matrix multiplication TM where the matrix T is symmetric Toeplitz. Args:

  • toeplitz_column (vector n) - First column of the symmetric Toeplitz matrix T.

  • matrix (matrix n x p) - Matrix or vector to multiply the Toeplitz matrix with.

Returns:
  • tensor

mgplvm.fast_utils.toeplitz.toeplitz(toeplitz_column, toeplitz_row)[source]

Constructs tensor version of toeplitz matrix from column vector Args:

  • toeplitz_column (vector n) - column of toeplitz matrix

  • toeplitz_row (vector n-1) - row of toeplitz matrix

Returns:
  • Matrix (n x n) - matrix representation

mgplvm.fast_utils.toeplitz.toeplitz_getitem(toeplitz_column, toeplitz_row, i, j)[source]

Gets the (i,j)th entry of a Toeplitz matrix T. Args:

  • toeplitz_column (vector n) - column of Toeplitz matrix

  • toeplitz_row (vector n) - row of Toeplitz matrix

  • i (scalar) - row of entry to get

  • j (scalar) - column of entry to get

Returns:
  • T[i,j], where T is the Toeplitz matrix specified by c and r.

mgplvm.fast_utils.toeplitz.toeplitz_matmul(toeplitz_column, toeplitz_row, tensor)[source]

Performs multiplication T * M where the matrix T is Toeplitz. Args:

  • toeplitz_column (vector n or b x n) - First column of the Toeplitz matrix T.

  • toeplitz_row (vector n or b x n) - First row of the Toeplitz matrix T.

  • tensor (matrix n x p or b x n x p) - Matrix or vector to multiply the Toeplitz matrix with.

Returns:
  • tensor (n x p or b x n x p) - The result of the matrix multiply T * M.