<divclass="platform-hinted "data-platform-hinted="data-platform-hinted"><divclass="content sourceset-dependent-content"data-active=""data-togglable=":kmath-tensors:dokkaHtmlPartial/commonMain"><divclass="symbol monospace"><spanclass="token keyword">abstract </span><spanclass="token keyword"></span><spanclass="token keyword">fun </span><ahref="diagonal-embedding.html"><spanclass="token function">diagonalEmbedding</span></a><spanclass="token punctuation">(</span><spanclass="parameters "><spanclass="parameter ">diagonalEntries<spanclass="token operator">: </span><ahref="../../../kmath-core/space.kscience.kmath.nd/-structure-n-d/index.html">StructureND</a><spanclass="token operator"><</span><spanclass="token keyword"></span><ahref="index.html">T</a><spanclass="token operator">></span><spanclass="token punctuation">, </span></span><spanclass="parameter ">offset<spanclass="token operator">: </span><ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a><spanclass="token operator"> = </span><spanclass="token constant">0</span><spanclass="token punctuation">, </span></span><spanclass="parameter ">dim1<spanclass="token operator">: </span><ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a><spanclass="token operator"> = </span>-2<spanclass="token punctuation">, </span></span><spanclass="parameter ">dim2<spanclass="token operator">: </span><ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a><spanclass="token operator"> = </span>-1</span></span><spanclass="token punctuation">)</span><spanclass="token operator">: </span><ahref="../index.html#-1680022905%2FClasslikes%2F-1345790395">Tensor</a><spanclass="token operator"><</span><spanclass="token keyword"></span><ahref="index.html">T</a><spanclass="token operator">></span><spanclass="clearfix"><spanclass="floating-right">(<ahref="https://github.com/SciProgCentre/kmath/tree/master/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt#L253">source</a>)</span></span></div><pclass="paragraph">Creates a tensor whose diagonals of certain 2D planes (specified by <ahref="diagonal-embedding.html">dim1</a> and <ahref="diagonal-embedding.html">dim2</a>) are filled by <ahref="diagonal-embedding.html">diagonalEntries</a>. To facilitate creating batched diagonal matrices, the 2D planes formed by the last two dimensions of the returned tensor are chosen by default.</p><pclass="paragraph">The argument <ahref="diagonal-embedding.html">offset</a> controls, which diagonal to consider:</p><ol><li><pclass="paragraph">If <ahref="diagonal-embedding.html">offset</a> = 0, it is the main diagonal.</p></li><li><pclass="paragraph">If <ahref="diagonal-embedding.html">offset</a> 0, it is above the main diagonal.</p></li><li><pclass="paragraph">If <ahref="diagonal-embedding.html">offset</a>< 0, it is below the main diagonal.</p></li></ol><pclass="paragraph">The size of the new matrix will be calculated to make the specified diagonal of the size of the last input dimension. For more information: https://pytorch.org/docs/stable/generated/torch.diag_embed.html</p><spanclass="kdoc-tag"><h4class="">Return</h4><pclass="paragraph">tensor whose diagonals of certain 2D planes (specified by <ahref="diagonal-embedding.html">dim1</a> and <ahref="diagonal-embedding.html">dim2</a>) are filled by <ahref="diagonal-embedding.html">diagonalEntries</a></p></span><h4class="">Parameters</h4><divclass="table"><divclass="table-row"data-filterable-current=":kmath-tensors:dokkaHtmlPartial/commonMain"data-filterable-set=":kmath-tensors:dokkaHtmlPartial/commonMain"><divclass="main-subrow keyValue "><divclass=""><spanclass="inline-flex"><div><u><span>diagonal</span><wbr><span><span>Entries</span></span></u></div></span></div><div><divclass="title"><pclass="paragraph">the input tensor. Must be at least 1-dimensional.</p></div></div></div></div><divclass="table-row"data-filterable-current=":kmath-tensors:dokkaHtmlPartial/commonMain