public final class **MatrixSetDiagV3** Returns a batched matrix tensor with new batched diagonal values.


Given \`input\` and \`diagonal\`, this operation returns a tensor with the
same shape and values as \`input\`, except for the specified diagonals of the
innermost matrices. These will be overwritten by the values in \`diagonal\`.


\`input\` has \`r+1\` dimensions \`\[I, J, ..., L, M, N\]\`. When \`k\` is scalar or
\`k\[0\] == k\[1\]\`, \`diagonal\` has \`r\` dimensions \`\[I, J, ..., L, max_diag_len\]\`.
Otherwise, it has \`r+1\` dimensions \`\[I, J, ..., L, num_diags, max_diag_len\]\`.
\`num_diags\` is the number of diagonals, \`num_diags = k\[1\] - k\[0\] + 1\`.
\`max_diag_len\` is the longest diagonal in the range \`\[k\[0\], k\[1\]\]\`,
\`max_diag_len = min(M + min(k\[1\], 0), N + min(-k\[0\], 0))\`


The output is a tensor of rank \`k+1\` with dimensions \`\[I, J, ..., L, M, N\]\`.
If \`k\` is scalar or \`k\[0\] == k\[1\]\`:

    output[i, j, ..., l, m, n]
       = diagonal[i, j, ..., l, n-max(k[1], 0)] ; if n - m == k[1]
         input[i, j, ..., l, m, n]              ; otherwise
     
Otherwise,

    output[i, j, ..., l, m, n]
       = diagonal[i, j, ..., l, diag_index, index_in_diag] ; if k[0] &lt;= d &lt;= k[1]
         input[i, j, ..., l, m, n]                         ; otherwise
     
where \`d = n - m\`, \`diag_index = k\[1\] - d\`, and \`index_in_diag = n - max(d, 0) + offset\`.


\`offset\` is zero except when the alignment of the diagonal is to the right.

    offset = max_diag_len - diag_len(d) ; if (`align` in {RIGHT_LEFT, RIGHT_RIGHT}
                                                and `d &gt;= 0`) or
                                              (`align` in {LEFT_RIGHT, RIGHT_RIGHT}
                                                and `d &lt;= 0`)
              0                          ; otherwise
     
where \`diag_len(d) = min(cols - max(d, 0), rows + min(d, 0))\`.


For example:

    # The main diagonal.
     input = np.array([[[7, 7, 7, 7],              # Input shape: (2, 3, 4)
                        [7, 7, 7, 7],
                        [7, 7, 7, 7]],
                       [[7, 7, 7, 7],
                        [7, 7, 7, 7],
                        [7, 7, 7, 7]]])
     diagonal = np.array([[1, 2, 3],               # Diagonal shape: (2, 3)
                          [4, 5, 6]])
     tf.matrix_set_diag(input, diagonal)
       ==&gt; [[[1, 7, 7, 7],  # Output shape: (2, 3, 4)
             [7, 2, 7, 7],
             [7, 7, 3, 7]],
            [[4, 7, 7, 7],
             [7, 5, 7, 7],
             [7, 7, 6, 7]]]
     
     # A superdiagonal (per batch).
     tf.matrix_set_diag(input, diagonal, k = 1)
       ==&gt; [[[7, 1, 7, 7],  # Output shape: (2, 3, 4)
             [7, 7, 2, 7],
             [7, 7, 7, 3]],
            [[7, 4, 7, 7],
             [7, 7, 5, 7],
             [7, 7, 7, 6]]]
     
     # A band of diagonals.
     diagonals = np.array([[[0, 9, 1],  # Diagonal shape: (2, 4, 3)
                            [6, 5, 8],
                            [1, 2, 3],
                            [4, 5, 0]],
                           [[0, 1, 2],
                            [5, 6, 4],
                            [6, 1, 2],
                            [3, 4, 0]]])
     tf.matrix_set_diag(input, diagonals, k = (-1, 2))
       ==&gt; [[[1, 6, 9, 7],  # Output shape: (2, 3, 4)
             [4, 2, 5, 1],
             [7, 5, 3, 8]],
            [[6, 5, 1, 7],
             [3, 1, 6, 2],
             [7, 4, 2, 4]]]
     
     # LEFT_RIGHT alignment.
     diagonals = np.array([[[9, 1, 0],  # Diagonal shape: (2, 4, 3)
                            [6, 5, 8],
                            [1, 2, 3],
                            [0, 4, 5]],
                           [[1, 2, 0],
                            [5, 6, 4],
                            [6, 1, 2],
                            [0, 3, 4]]])
     tf.matrix_set_diag(input, diagonals, k = (-1, 2), align="LEFT_RIGHT")
       ==&gt; [[[1, 6, 9, 7],  # Output shape: (2, 3, 4)
             [4, 2, 5, 1],
             [7, 5, 3, 8]],
            [[6, 5, 1, 7],
             [3, 1, 6, 2],
             [7, 4, 2, 4]]]
     
     
<br />

<br />

<br />

<br />

<br />

<br />

### Nested Classes

|---|---|---|---|
| class | [MatrixSetDiagV3.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3.Options) || Optional attributes for `https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3` |

### Public Methods

|---|---|
| static [MatrixSetDiagV3.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3.Options) | [align](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3#align(java.lang.String))(String align) |
| [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\> | [asOutput](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3#asOutput())() Returns the symbolic handle of a tensor. |
| static \<T\> [MatrixSetDiagV3](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3)\<T\> | [create](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3#create(org.tensorflow.op.Scope,%20org.tensorflow.Operand<T>,%20org.tensorflow.Operand<T>,%20org.tensorflow.Operand<java.lang.Integer>,%20org.tensorflow.op.core.MatrixSetDiagV3.Options...))([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<T\> input, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<T\> diagonal, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<Integer\> k, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3.Options) options) Factory method to create a class wrapping a new MatrixSetDiagV3 operation. |
| [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\> | [output](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3#output())() Rank \`r+1\`, with \`output.shape = input.shape\`. |

### Inherited Methods

From class [org.tensorflow.op.PrimitiveOp](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp)

|---|---|
| final boolean | [equals](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#equals(java.lang.Object))(Object obj) |
| final int | [hashCode](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#hashCode())() |
| [Operation](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operation) | [op](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#op())() Returns the underlying `https://www.tensorflow.org/api_docs/java/org/tensorflow/Operation` |
| final String | [toString](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#toString())() |

From class java.lang.Object

|---|---|
| boolean | equals(Object arg0) |
| final Class\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| String | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

From interface [org.tensorflow.Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)

|---|---|
| abstract [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\> | [asOutput](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand#asOutput())() Returns the symbolic handle of a tensor. |

## Public Methods

#### public static [MatrixSetDiagV3.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3.Options)
**align**
(String align)

<br />

##### Parameters

| align | Some diagonals are shorter than \`max_diag_len\` and need to be padded. \`align\` is a string specifying how superdiagonals and subdiagonals should be aligned, respectively. There are four possible alignments: "RIGHT_LEFT" (default), "LEFT_RIGHT", "LEFT_LEFT", and "RIGHT_RIGHT". "RIGHT_LEFT" aligns superdiagonals to the right (left-pads the row) and subdiagonals to the left (right-pads the row). It is the packing format LAPACK uses. cuSPARSE uses "LEFT_RIGHT", which is the opposite alignment. |
|---|---|

#### public [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\>
**asOutput**
()

Returns the symbolic handle of a tensor.

Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is
used to obtain a symbolic handle that represents the computation of the input.

<br />

#### public static [MatrixSetDiagV3](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3)\<T\>
**create**
([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<T\> input, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<T\> diagonal, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<Integer\> k, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/MatrixSetDiagV3.Options) options)

Factory method to create a class wrapping a new MatrixSetDiagV3 operation.

##### Parameters

| scope | current scope |
| input | Rank \`r+1\`, where \`r \>= 1\`. |
| diagonal | Rank \`r\` when \`k\` is an integer or \`k\[0\] == k\[1\]\`. Otherwise, it has rank \`r+1\`. \`k \>= 1\`. |
| k | Diagonal offset(s). Positive value means superdiagonal, 0 refers to the main diagonal, and negative value means subdiagonals. \`k\` can be a single integer (for a single diagonal) or a pair of integers specifying the low and high ends of a matrix band. \`k\[0\]\` must not be larger than \`k\[1\]\`. |
| options | carries optional attributes values |
|---|---|

##### Returns

- a new instance of MatrixSetDiagV3

#### public [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<T\>
**output**
()

Rank \`r+1\`, with \`output.shape = input.shape\`.