Module matrices: collection of explicit useful QTT-matrices

Package teneva, module matrices: various useful QTT-matrices.

This module contains the collection of functions for explicit construction of various useful QTT-matrices (delta function and others).




teneva.matrices.matrix_delta(q, i, j, v=1.0)[source]

Build QTT-matrix that is zero everywhere except for a given 2D index.

Parameters:
  • q (int) – quantization level. The resulting matrix will have the shape 2^q x 2^q.

  • i (int) – the col index for nonzero element (< 2^q). Note that “negative index notation” is supported.

  • j (int) – the row index for nonzero element (< 2^q). Note that “negative index notation” is supported.

  • v (float) – the value of the matrix at index i, j.

Returns:

TT-tensor with 4D TT-cores representing the QTT-matrix.

Return type:

list

Examples:

q = 5                               # Quantization level (the size is 2^q)
i = 2                               # The col index for nonzero element
j = 4                               # The row index for nonzero element
v = 42.                             # The value of the matrix at indices "i, j"
Y = teneva.matrix_delta(q, i, j, v) # Build QTT-matrix

We can also build some big QTT-matrix by “delta” function and check the norm of the result:

q = 100                             # Quantization level (the size is 2^q)
i = 2                               # The col index for nonzero element
j = 4                               # The row index for nonzero element
v = 42.                             # The value of the matrix at indices "i, j"
Y = teneva.matrix_delta(q, i, j, v) # Build QTT-matrix

teneva.norm(Y)

# >>> ----------------------------------------
# >>> Output:

# 42.0
#