TenEig — Tensor Eigenpairs Solver

teig

Tensor eigenvalues and eigenvectors

Syntax

  • [lambda,V] = teig(___) example
  • [lambda,V,res,cnd] = teig(___) example

Description

example

lambda = teig(A) returns a row vector containing the eigenvalues, that satisfy the equation Av m-1 = λ v [m-1], where A is an n-dimensional tensor of order m, v is a row vector of length n, and λ is a scalar. The values of λ that satisfy the equation are the eigenvalues. The corresponding values of v that satisfy the equation are the eigenvectors.

example

lambda = teig(A,k) specifies the eigenvalues of interest are mode-k eigenvalues.

example

lambda = teig(A,'symmetric') specifies that A is a symmetric tensor. If it is not, convert it to a symmetric tensor.

example

lambda = teig(P) specifies that a tensor A implicitly given by P = Av m.

example

lambda = teig(A,B) returns a vector containing the generalized eigenvalues of the pair, (A,B), that satisfy the equation Av m-1 = λBv m'-1, where A is an n-dimensional tensor of order m, B is an n-dimensional tensor of order m', v is a row vector of length n, and λ is a scalar. The values of λ that satisfy the equation are the B-eigenvalues. The corresponding values of v are the B-eigenvectors.

example

lambda = teig(A,B, k) specifies the eigenvalues of interest are mode-k B eigenvalues.

example

[lambda, V] = teig(___) returns two optional outputs for any of the previous input syntaxes. lambda row vector containing the eigenvalues. V is a matrix whose columns are the corresponding eigenvectors.

example

[lambda, V,res, cnd] = teig(___) also returns two row vectors containing the residue and reciprocal of the condition number of each eigenpair.

Examples

expand all

Eigenvalues of a tensor

A(1,1,1) = 1; A(1,2,1) = 2; A(2,1,1) = 3; A(2,2,1) = 4;
A(1,1,2) = 5; A(1,2,2) = 6; A(2,1,2) = 7; A(2,2,2) = 0
A(:,:,1) =

     1     2
     3     4


A(:,:,2) =

     5     6
     7     0

Calculate the eigenvalues of A. The result is a row vector.

lambda = teig(A)
lambda =

  -5.7625 - 4.1616i  -5.7625 + 4.1616i  -0.4750 + 0.0000i  14.0000 - 0.0000i

Mode k-Eigenvalues and Mode k-Eigenvectors of a tensor

Use the randn function to create a random complex tensor.

A = randn(2,2,2)+1i*randn(2,2,2)
A(:,:,1) =

   0.8622 + 3.0349i  -1.3077 - 0.0631i
   0.3188 + 0.7254i  -0.4336 + 0.7147i


A(:,:,2) =

   0.3426 - 0.2050i   2.7694 + 1.4897i
   3.5784 - 0.1241i  -1.3499 + 1.4090i

Calculate the mode 2-eigenvalues and mode 2-eigenvectors of A.

[lambda,V] = teig(A,2)
lambda =

  -2.6379 + 3.6233i  -1.0809 - 2.0668i   0.8874 + 2.3813i   1.8559 + 4.9501i


V =

  -0.1389 + 0.9147i  -0.5356 - 0.6158i   1.0000 + 0.0000i   1.0000 - 0.0000i
   1.0000 + 0.0000i   1.0000 - 0.0000i   0.2144 - 0.3530i   0.5724 + 0.3453i

Eigenvalues and Eigenvectors of a symmetric tensor

A = zeros(3,3,3,3);
A(1,1,1,1) =  0.2883; A(1,1,1,2) = -0.0031; A(1,1,1,3) =  0.1973;
A(1,1,2,2) = -0.2485; A(1,1,2,3) = -0.2939; A(1,1,3,3) =  0.3847;
A(1,2,2,2) =  0.2972; A(1,2,2,3) =  0.1862; A(1,2,3,3) =  0.0919;
A(1,3,3,3) = -0.3619; A(2,2,2,2) =  0.1241; A(2,2,2,3) = -0.3420;
A(2,2,3,3) =  0.2127; A(2,3,3,3) =  0.2727; A(3,3,3,3) = -0.3054;

Note that the above tensor A is nonsymmetric. Convert it to a symmetric tensor and calculate the eigenvalues and eigenvectors.

[lambda,V] = teig(A,'symmetric')
lambda =

  Columns 1 through 5

  -2.6841 + 0.0000i  -1.8370 - 1.1859i  -1.8370 + 1.1859i  -1.6969 - 0.2787i  -1.6969 + 0.2787i

  Columns 6 through 10

  -1.6687 - 3.4926i  -1.6687 + 3.4926i  -1.0358 - 0.9961i  -1.0358 + 0.9961i  -0.6665 - 0.0000i

  Columns 11 through 15

  -0.0887 + 0.0000i   0.2499 - 0.0000i   0.2528 + 0.0000i   0.4108 - 0.0000i   0.7228 - 0.0000i

  Columns 16 through 20

   0.7281 - 0.3884i   0.7281 + 0.3884i   0.7732 - 0.8385i   0.7732 + 0.8385i   0.8944 - 0.0000i

  Columns 21 through 25

   0.9780 - 0.0000i   1.2553 - 1.0002i   1.2553 + 1.0002i   1.8063 + 0.7308i   1.8063 - 0.7308i

  Columns 26 through 27

   1.9316 + 0.0000i   2.3129 - 0.0000i


V =

  Columns 1 through 5

  -0.8983 - 0.0000i   0.0150 + 0.9127i   0.0150 - 0.9127i   0.0141 - 0.8848i   0.0141 + 0.8848i
   1.0000 + 0.0000i  -0.4541 + 0.0486i  -0.4541 - 0.0486i   0.2039 - 0.7897i   0.2039 + 0.7897i
   0.5814 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i

  Columns 6 through 10

   0.0228 + 0.9552i   0.0228 - 0.9552i   0.2959 - 0.1603i   0.2959 + 0.1603i   0.2296 + 0.0000i
  -0.0397 - 0.9609i  -0.0397 + 0.9609i   0.0757 - 0.8626i   0.0757 + 0.8626i  -0.2584 + 0.0000i
   1.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i

  Columns 11 through 15

   1.0000 + 0.0000i   0.4213 - 0.0000i   1.0000 + 0.0000i  -0.2073 + 0.0000i   1.0000 + 0.0000i
   0.8054 + 0.0000i   1.0000 + 0.0000i   0.1020 + 0.0000i   0.5241 + 0.0000i   0.5792 - 0.0000i
   0.1703 + 0.0000i   0.2203 - 0.0000i  -0.0868 - 0.0000i   1.0000 - 0.0000i   0.9396 + 0.0000i

  Columns 16 through 20

   0.1469 - 0.5485i   0.1469 + 0.5485i   1.0000 - 0.0000i   1.0000 + 0.0000i   0.6193 + 0.0000i
   1.0000 + 0.0000i   1.0000 + 0.0000i   0.1514 + 0.8045i   0.1514 - 0.8045i   0.9542 + 0.0000i
  -0.2765 + 0.1510i  -0.2765 - 0.1510i   0.3994 - 0.0446i   0.3994 + 0.0446i   1.0000 + 0.0000i

  Columns 21 through 25

  -0.1546 - 0.0000i   0.2248 - 0.9012i   0.2248 + 0.9012i   1.0000 + 0.0000i   1.0000 + 0.0000i
   1.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 - 0.0000i   0.1192 + 0.6584i   0.1192 - 0.6584i
  -0.6742 + 0.0000i   0.6678 + 0.0395i   0.6678 - 0.0395i  -0.9237 + 0.0724i  -0.9237 - 0.0724i

  Columns 26 through 27

   1.0000 + 0.0000i  -0.9677 + 0.0000i
  -0.7471 + 0.0000i  -0.7966 - 0.0000i
   0.7928 - 0.0000i   1.0000 + 0.0000i

Eigenvalues and Eigenvectors of a symmetric tensor implicitly given in a polynomial

Create a cell of string P which equals Av m.

 P = {'3*x1^4+x2^4+3*x1^2*x2^2'};

Calculate the eigenvalues, lambda and the eigenvectors, V.

[lambda, V] = teig(P)
lambda =

  Columns 1 through 5

   0.1972 + 0.0000i   0.1972 - 0.0000i   1.0000 + 0.0000i   3.0000 + 0.0000i   3.8028 + 0.0000i

  Column 6

   3.8028 + 0.0000i


V =

  Columns 1 through 5

  -0.0000 - 0.7316i   0.0000 + 0.7316i   0.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i
   1.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i   0.0000 + 0.0000i   0.7316 + 0.0000i

  Column 6

   1.0000 + 0.0000i
  -0.7316 - 0.0000i

Generalized Eigenvalues and Eigenvectors

Create two tensors, A and B, then solve the generalized eigenvalue problem for the eigenvalues and eigenvectors of the pair (A,B).

A(1,1,1) = 1; A(1,2,1) = 2; A(2,1,1) = 3; A(2,2,1) = 4;
A(1,1,2) = 5; A(1,2,2) = 6; A(2,1,2) = 7; A(2,2,2) = 0;
B = eye(2);
[lambda,V] = teig(A,B)
lambda =

  -9.8995 - 0.0000i  -4.3820 - 0.0000i  -0.4105 - 0.0000i   0.4105 + 0.0000i   4.3820 - 0.0000i   9.8995 + 0.0000i


V =

   1.0000 + 0.0000i  -0.5252 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i  -0.5252 + 0.0000i   1.0000 + 0.0000i
   1.0000 - 0.0000i   1.0000 + 0.0000i  -0.2626 - 0.0000i  -0.2626 - 0.0000i   1.0000 + 0.0000i   1.0000 - 0.0000i

Generalized mode k-Eigenvalues and mode k-Eigenvectors

Create two tensors, A and B, then solve the generalized mode k-eigenvalue problem for the mode 3-eigenvalues and mode 3-eigenvectors of the pair (A,B).

A(1,1,1) = 1; A(1,2,1) = 2; A(2,1,1) = 3; A(2,2,1) = 4;
A(1,1,2) = 5; A(1,2,2) = 6; A(2,1,2) = 7; A(2,2,2) = 0;
B = eye(2);
[lambda,V] = teig(A,B,3)
lambda =

  -9.4025 + 0.0000i  -4.3007 + 0.0000i  -0.2936 - 0.0000i   0.2936 + 0.0000i   4.3007 + 0.0000i   9.4025 - 0.0000i


V =

   0.6950 - 0.0000i  -0.4323 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i   0.6950 - 0.0000i
   1.0000 + 0.0000i   1.0000 + 0.0000i  -0.3756 - 0.0000i  -0.3756 - 0.0000i  -2.3133 + 0.0000i   1.0000 + 0.0000i

Residue and reciprocal of the condition number of eigenpairs

Create a cell of string P which equals Av m.

 P = {'3*x1^4+x2^4'};

Calculate the eigenvalues, lambda, the eigenvectors, V, the residule, res and the reciprocal of the condition number, cnd.

[lambda, V, res, cnd] = teig(P)
lambda =

   1.0000 - 0.0000i   1.0000 - 0.0000i   1.0000 - 0.0000i   3.0000 - 0.0000i   3.0000 + 0.0000i   3.0000 + 0.0000i


V =

  -0.0000 + 0.0000i  -0.0000 - 0.0000i   0.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i
   1.0000 + 0.0000i   1.0000 + 0.0000i   1.0000 + 0.0000i  -0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 - 0.0000i


res =

   1.0e-15 *

    0.0362    0.0997    0.1115    0.0007    0.6281    0.1140


cnd =

   1.0e-10 *

    0.2067    0.9141    0.2067    0.0145    0.1698    0.1655

Input Arguments

expand all

A — Input tensor n-dimensional tensor of order m

Input tensor, specified as a real or complex tensor.

Data Types: double | single
Complex Number Support: Yes

B — Generalized eigenvalue problem input tensor n-dimensional tensor of order m'

Generalized eigenvalue problem input tensor, specified as a real or complex tensor.

Data Types: double | single
Complex Number Support: Yes

k — mode-k eigenvalue probelm input k constant

Specified the mode-k eigenvalue problem

Data Types: integer

P — Eigenvalue problem input polynomial cell

Specifies the tensor implicitly defined by the polynomial P = Av m.

Data Types: cell of one string

Output Arguments

expand all

lambda — Eigenvaluesrow vector

Eigenvalues, returned as a row vector containing the eigenvalues (or generalized eigenvalues of a pair).

V — Eigenvectors or mode-k B eigenvectorsmatrix

Eigenvectors, returned as a square matrix whose columns are the eigenvectors of A or generalized mode-k eigenvectors of the pair, (A,B). The form of V is given by normalizing the vector so that the largest magnitude of the elments in the vector is 1.

res — Residue row vector

Residue, returned as a row vector containing the residue of each eigenpair.

cnd — reciprocal of the condition numberrow vector

reciprocal of the condition number, returned as a row vector containing the reciprocal of the condition number of each eigenpair.

More About

expand all

Tips

  • The teig function returns all eigenvalues of a tensor for the syntax, lambda = teig(A). Use the heig function if only the real eigenvalues are interested.