ee.Array.eigen

Computes the real eigenvectors and eigenvalues of a square 2D array of A rows and A columns. Returns an array with A rows and A+1 columns, where each row contains an eigenvalue in the first column, and the corresponding eigenvector in the remaining A columns. The rows are sorted by eigenvalue, in descending order.

 This implementation uses DecompositionFactory.eig() from https://ejml.org.

UsageReturns
Array.eigen()Array
ArgumentTypeDetails
this: inputArrayA square, 2D array from which to compute the eigenvalue decomposition.

Examples

Code Editor (JavaScript)

print(ee.Array([[0, 0], [0, 0]]).eigen());  // [[0,0,1],[0,1,0]]

print(ee.Array([[1, 0], [0, 0]]).eigen());  // [[1,1,0],[0,0,1]]
print(ee.Array([[0, 1], [0, 0]]).eigen());  // [[0,0,1],[0,1,0]]
print(ee.Array([[0, 0], [1, 0]]).eigen());  // [[0,-1,0],[0,0,-1]]
print(ee.Array([[0, 0], [0, 1]]).eigen());  // [[1,0,1],[0,1,0]]

print(ee.Array([[1, 1], [0, 0]]).eigen());  // [[1,1,0],[0,-1/√2,1/√2]]
print(ee.Array([[0, 0], [1, 1]]).eigen());  // [[1,0,-1],[0,-1/√2,1/√2]]]

print(ee.Array([[1, 0], [1, 0]]).eigen());  // [[1,1/√2,1/√2],[0,0,1]]
print(ee.Array([[1, 0], [0, 1]]).eigen());  // [[1,1,0],[1,0,1]]
print(ee.Array([[0, 1], [1, 0]]).eigen());  // [[1,1/√2,1/√2],[-1,1/√2,-1/√2]]
print(ee.Array([[0, 1], [0, 1]]).eigen());  // [[1,1/√2,1/√2],[0,1,0]]

print(ee.Array([[1, 1], [1, 0]]).eigen());  // [[1.62,0.85,0.53],[-0.62,0.53]]
print(ee.Array([[1, 1], [0, 1]]).eigen());  // [[1,0,1],[1,1,0]]
print(ee.Array([[1, 0], [1, 1]]).eigen());  // [[1,-1,0],[1,0,-1]]
// [[1.62,-0.53,-0.85],[-0.62,-0.85,0.53]]
print(ee.Array([[0, 1], [1, 1]]).eigen());

print(ee.Array([[1, 1], [1, 1]]).eigen());  // [[2,1/√2,1/√2],[0,1/√2,-1/√2]]

var matrix = ee.Array([
  [1, 0, 0],
  [0, 1, 0],
  [0, 0, 1]]);
print(matrix.eigen());  // [[1,1,0,0],[1,0,1,0],[1,0,0,1]]

var matrix = ee.Array([
  [2, 0, 0],
  [0, 3, 0],
  [0, 0, 4]]);
print(matrix.eigen());  // [[4,0,0,1],[3,0,1,0],[2,1,0,0]]

matrix = ee.Array([
  [1, 0, 0],
  [0, 0, 0],
  [0, 0, 0]]);
print(matrix.eigen());  // [[1,1,0,0],[0,0,1,0],[0,0,0,1]]

matrix = ee.Array([
  [1, 1, 1],
  [1, 1, 1],
  [1, 1, 1]]);
// [[3,-0.58,-0.58,-0.58],[0,0,-1/√2,1/√2],[0,-0.82,0.41,0.41]]
print(matrix.eigen());

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

import ee
import geemap.core as geemap

Colab (Python)

display(ee.Array([[0, 0], [0, 0]]).eigen())  # [[0, 0, 1], [0, 1, 0]]

display(ee.Array([[1, 0], [0, 0]]).eigen())  # [[1, 1, 0], [0,0,1]]
display(ee.Array([[0, 1], [0, 0]]).eigen())  # [[0, 0, 1], [0, 1, 0]]
display(ee.Array([[0, 0], [1, 0]]).eigen())  # [[0, -1, 0], [0, 0, -1]]
display(ee.Array([[0, 0], [0, 1]]).eigen())  # [[1, 0, 1], [0, 1, 0]]

# [[1, 1, 0], [0, -1/√2, 1/√2]]
display(ee.Array([[1, 1], [0, 0]]).eigen())

# [[1, 0, -1], [0, -1/√2, 1/√2]]]
display(ee.Array([[0, 0], [1, 1]]).eigen())

# [[1, 1/√2, 1/√2], [0, 0, 1]]
display(ee.Array([[1, 0], [1, 0]]).eigen())
display(ee.Array([[1, 0], [0, 1]]).eigen())  # [[1, 1, 0], [1, 0, 1]]

# [[1, 1/√2, 1/√2], [-1, 1/√2, -1/√2]]
display(ee.Array([[0, 1], [1, 0]]).eigen())

# [[1, 1/√2, 1/√2], [0, 1, 0]]
display(ee.Array([[0, 1], [0, 1]]).eigen())

# [[1.62, 0.85, 0.53], [-0.62, 0.53]]
display(ee.Array([[1, 1], [1, 0]]).eigen())
display(ee.Array([[1, 1], [0, 1]]).eigen())  # [[1, 0, 1], [1, 1, 0]]
display(ee.Array([[1, 0], [1, 1]]).eigen())  # [[1, -1, 0], [1, 0, -1]]

# [[1.62, -0.53, -0.85], [-0.62, -0.85, 0.53]]
display(ee.Array([[0, 1], [1, 1]]).eigen())

# [[2, 1/√2, 1/√2], [0, 1/√2, -1/√2]]
display(ee.Array([[1, 1], [1, 1]]).eigen())

matrix = ee.Array([
  [1, 0, 0],
  [0, 1, 0],
  [0, 0, 1]])
display(matrix.eigen())  # [[1, 1, 0, 0], [1, 0, 1, 0], [1, 0, 0, 1]]

matrix = ee.Array([
  [2, 0, 0],
  [0, 3, 0],
  [0, 0, 4]])
display(matrix.eigen())  # [[4, 0, 0, 1], [3, 0, 1, 0], [2, 1, 0, 0]]

matrix = ee.Array([
  [1, 0, 0],
  [0, 0, 0],
  [0, 0, 0]])
display(matrix.eigen())  # [[1, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]

matrix = ee.Array([
  [1, 1, 1],
  [1, 1, 1],
  [1, 1, 1]])
# [[3, -0.58, -0.58, -0.58], [0, 0, -1/√2, 1/√2], [0, -0.82, 0.41, 0.41]]
display(matrix.eigen())