matrix.eigenvectors() - Pine Script Function
matrix.eigenvectors()
Section titled “matrix.eigenvectors()”Overview
Section titled “Overview”Returns a matrix of eigenvectors, in which each column is an eigenvector of the id matrix.
Syntax
Section titled “Syntax”matrix.eigenvectors(id) → matrix<float>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| id | matrix<int/float> | A matrix object. |
Returns
Section titled “Returns”A new matrix containing the eigenvectors of the id matrix.
Remarks
Section titled “Remarks”- The function is calculated using “The Implicit QL Algorithm”.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("`matrix.eigenvectors()` Example")// For efficiency, execute this code only once.if barstate.islastconfirmedhistory // Create a 2x2 matrixvar m1 = matrix.new<int>(2, 2, 1) // Fill the matrix with values. matrix.set(m1, 0, 0, 2)matrix.set(m1, 0, 1, 4)matrix.set(m1, 1, 0, 6)matrix.set(m1, 1, 1, 8) // Get the eigenvectors of the matrix. m2 = matrix.eigenvectors(m1) // Display matrix elements.var t = table.new(position.top_right, 2, 2, color.green)table.cell(t, 0, 0, "Matrix Elements:")table.cell(t, 0, 1, str.tostring(m1))table.cell(t, 1, 0, "Matrix Eigenvectors:")table.cell(t, 1, 1, str.tostring(m2))