# tf.linalg.tridiagonal_matmul

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/linalg/linalg_impl.py#L670-L748) |

Multiplies tridiagonal matrix by matrix.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.linalg.tridiagonal_matmul`](https://www.tensorflow.org/api_docs/python/tf/linalg/tridiagonal_matmul)

<br />

    tf.linalg.tridiagonal_matmul(
        diagonals, rhs, diagonals_format='compact', name=None
    )

`diagonals` is representation of 3-diagonal NxN matrix, which depends on
`diagonals_format`.

In `matrix` format, `diagonals` must be a tensor of shape `[..., M, M]`, with
two inner-most dimensions representing the square tridiagonal matrices.
Elements outside of the three diagonals will be ignored.

If `sequence` format, `diagonals` is list or tuple of three tensors:
`[superdiag, maindiag, subdiag]`, each having shape \[..., M\]. Last element
of `superdiag` first element of `subdiag` are ignored.

In `compact` format the three diagonals are brought together into one tensor
of shape `[..., 3, M]`, with last two dimensions containing superdiagonals,
diagonals, and subdiagonals, in order. Similarly to `sequence` format,
elements `diagonals[..., 0, M-1]` and `diagonals[..., 2, 0]` are ignored.

The `sequence` format is recommended as the one with the best performance.

`rhs` is matrix to the right of multiplication. It has shape `[..., M, N]`.

#### Example:

    superdiag = tf.constant([-1, -1, 0], dtype=tf.float64)
    maindiag = tf.constant([2, 2, 2], dtype=tf.float64)
    subdiag = tf.constant([0, -1, -1], dtype=tf.float64)
    diagonals = [superdiag, maindiag, subdiag]
    rhs = tf.constant([[1, 1], [1, 1], [1, 1]], dtype=tf.float64)
    x = tf.linalg.tridiagonal_matmul(diagonals, rhs, diagonals_format='sequence')

<br />

<br />

<br />

| ## Args ||
|---|---|
| `diagonals` | A `Tensor` or tuple of `Tensor`s describing left-hand sides. The shape depends of `diagonals_format`, see description above. Must be `float32`, `float64`, `complex64`, or `complex128`. |
| `rhs` | A `Tensor` of shape \[..., M, N\] and with the same dtype as `diagonals`. |
| `diagonals_format` | one of `sequence`, or `compact`. Default is `compact`. |
| `name` | A name to give this `Op` (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor` of shape \[..., M, N\] containing the result of multiplication. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | An unsupported type is provided as input, or when the input tensors have incorrect shapes. |

<br />