matrix.kron() - Pine Script Function
matrix.kron()
Section titled “matrix.kron()”Overview
Section titled “Overview”The function returns the Kronecker product for the id1 and id2 matrices.
Syntax
Section titled “Syntax”matrix.kron(id1, id2) → matrix<float>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| id1 | matrix<int/float> | First matrix object. |
Returns
Section titled “Returns”A new matrix containing the Kronecker product of id1 and id2.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("`matrix.kron()` Example")// Display using a table.if barstate.islastconfirmedhistory // Create two matrices with default values `1` and `2`.var m1 = matrix.new<float>(2, 2, 1)var m2 = matrix.new<float>(2, 2, 2) // Calculate the Kronecker product of the matrices.var m3 = matrix.kron(m1, m2) // Display matrix elements.var t = table.new(position.top_right, 5, 2, color.green)table.cell(t, 0, 0, "Matrix 1:")table.cell(t, 0, 1, str.tostring(m1))table.cell(t, 1, 1, "⊗")table.cell(t, 2, 0, "Matrix 2:")table.cell(t, 2, 1, str.tostring(m2))table.cell(t, 3, 1, "=")table.cell(t, 4, 0, "Kronecker product:")table.cell(t, 4, 1, str.tostring(m3))