matrix.pow() - Pine Script Function
matrix.pow()
Section titled “matrix.pow()”Overview
Section titled “Overview”The function calculates the product of the matrix by itself power times.
Syntax
Section titled “Syntax”matrix.pow(id, power) → matrix<float>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| id | matrix<int/float> | A matrix object. |
Returns
Section titled “Returns”The product of the id matrix by itself power times.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("`matrix.pow()` Example")// Display using a table.if barstate.islastconfirmedhistory // Create a 2x2 matrix.var m1 = matrix.new<int>(2, 2, 2) // Calculate the power of three of the matrix.var m2 = matrix.pow(m1, 3) // Display matrix elements.var t = table.new(position.top_right, 2, 2, color.green)table.cell(t, 0, 0, "Original Matrix:")table.cell(t, 0, 1, str.tostring(m1))table.cell(t, 1, 0, "Matrix³:")table.cell(t, 1, 1, str.tostring(m2))