tensor_eigenvalues
This file contains a set of utilities to compute tensor eigenvalues since there is no standard library to do so.
- tensiometer.utilities.tensor_eigenvalues.GtRq(x, A, B)[source]
Generalized tensor Rayleigh quotient.
- Parameters:
x – the input vector
A – the input tensor at the numerator
B – the input tensor at the denumerator
- tensiometer.utilities.tensor_eigenvalues.GtRq_Hess_brute(x, m, Axm, Bxm, Axmm1, Bxmm1, Axmm2, Bxmm2)[source]
The Euclidean Hessian of the Generalized tensor Rayleigh quotient problem. Taken from https://arxiv.org/abs/1401.1183 Requires precomputations since many things can be cached.
- Parameters:
x – the input vector
m – the rank of the tensor
Axm – first tensor contraction A*x^m
Bxm – second tensor contraction B*x^m
Axmm1 – first tensor contraction A*x^(m-1)
Bxmm1 – second tensor contraction B*x^(m-1)
Axmm2 – first tensor contraction A*x^(m-2)
Bxmm2 – second tensor contraction B*x^(m-2)
- tensiometer.utilities.tensor_eigenvalues.GtRq_Jac_brute(x, m, Axm, Bxm, Axmm1, Bxmm1)[source]
The Euclidean Jacobian of the Generalized tensor Rayleigh quotient problem. Taken from https://arxiv.org/abs/1401.1183 Requires precomputations since many things can be cached.
- Parameters:
x – the input vector
m – the rank of the tensor
Axm – first tensor contraction A*x^m
Bxm – second tensor contraction B*x^m
Axmm1 – first tensor contraction A*x^(m-1)
Bxmm1 – second tensor contraction B*x^(m-1)
- tensiometer.utilities.tensor_eigenvalues.GtRq_brute_2D(A, B, num_points=2000)[source]
Brute force maximization of the Generalized Tensor Rayleigh quotient on the circle. Works for problems of any rank and 2 dimensions. Since the problem is one dimensional samples the function on num_points and returns the maximum.
- Parameters:
A – the first input tensor
B – the second input tensor
num_points – the number of points of the search
- tensiometer.utilities.tensor_eigenvalues.eu_to_sphere_grad(x, egrad)[source]
Converts euclidean gradient to gradient on the n-sphere.
- Parameters:
x – vector x on the sphere
egrad – euclidean gradient
- tensiometer.utilities.tensor_eigenvalues.eu_to_sphere_hess(x, egrad, ehess, u)[source]
Derivative of gradient in direction u (tangent to the sphere)
- Parameters:
x – vector x on the sphere
egrad – euclidean gradient
ehess – euclidean Hessian matrix
u – direction vector that should belong on the tangent space of the sphere
- tensiometer.utilities.tensor_eigenvalues.identity_tensor(d, m)[source]
Returns the identity tensor that has 1 on the (multidimensional) diagonal and 0 elsewhere.
- Parameters:
d – number of dimensions
m – rank of the tensor
- Returns:
the random symmetric tensor
- tensiometer.utilities.tensor_eigenvalues.max_GtRq_brute(A, B, feedback=0, optimizer='ParticleSwarm', **kwargs)[source]
Brute force maximization of the Generalized Tensor Rayleigh quotient on the sphere. Optimization is performed with Pymanopt.
- Parameters:
A – the input tensor
B – the second input tensor
feedback – the feedback level for pymanopt
optimizer – the name of the pymanopt minimizer
kwargs – keyword arguments to pass to the pymanopt solver
- tensiometer.utilities.tensor_eigenvalues.max_GtRq_geap_power(A, B, maxiter=1000, tau=1e-06, tol=1e-10, x0=None, history=False)[source]
Shifted adaptive power iterations algorithm, also called GEAP, for the Generalized Tensor Rayleigh quotient. Described in https://arxiv.org/pdf/1401.1183.pdf The algorithm is not guaranteed to produce the global maximum but only a convex maximum. We advice to run the algorithm multiple times to make sure that the solution that is found is the global maximum.
- Parameters:
A – the input symmetric tensor
B – the second input symmetric tensor
maxiter – (default 500) maximum number of iterations.
tau – (default 1.e-6) tolerance on being positive definite
tol – (default 1.e-10) tolerance on the solution of the eigenvalue problem
x0 – (default random on the sphere) starting point
history – (default False) wether to return the history of the power iterations
- tensiometer.utilities.tensor_eigenvalues.max_tRq_brute(A, feedback=0, optimizer='ParticleSwarm', **kwargs)[source]
Brute force maximization of the Tensor Rayleigh quotient on the sphere. Optimization is performed with Pymanopt.
- Parameters:
A – the input tensor
feedback – the feedback level for pymanopt
optimizer – the name of the pymanopt minimizer
kwargs – keyword arguments to pass to the pymanopt solver
- tensiometer.utilities.tensor_eigenvalues.max_tRq_dynsys(A, maxiter=1000, tol=1e-10, x0=None, h0=0.5, history=False)[source]
Solves for the maximum eigenvalue with a dynamical system. Described in https://arxiv.org/abs/1805.00903 Uses odeint to perform the differential equation evolution.
- Parameters:
A – the input symmetric tensor
maxiter – (default 500) maximum number of iterations.
tol – (default 1.e-10) tolerance on the solution of the eigenvalue problem
x0 – (default random on the sphere) starting point
h0 – (default 0.5) initial time step
history – (default False) wether to return the history of the power iterations
- tensiometer.utilities.tensor_eigenvalues.max_tRq_geap(A, tau=1e-06, maxiter=1000, tol=1e-10, x0=None, history=False)[source]
Shifted adaptive power iterations algorithm, also called GEAP, for tensor eigenvalues. Described in https://arxiv.org/pdf/1401.1183.pdf The algorithm is not guaranteed to produce the global maximum but only a convex maximum. We advice to run the algorithm multiple times to make sure that the solution that is found is the global maximum.
- Parameters:
A – the input symmetric tensor
tau – (default 1.e-6) tolerance on being positive definite
maxiter – (default 500) maximum number of iterations.
tol – (default 1.e-10) tolerance on the solution of the eigenvalue problem
x0 – (default random on the sphere) starting point
history – (default False) wether to return the history of the power iterations
- tensiometer.utilities.tensor_eigenvalues.max_tRq_power(A, maxiter=1000, tol=1e-10, x0=None, history=False)[source]
Symmetric power iterations, also called S-HOPM, for tensors eigenvalues. Described in https://arxiv.org/abs/1007.1267 The algorithm is not guaranteed to produce the global maximum but only a convex maximum. We advice to run the algorithm multiple times to make sure that the solution that is found is the global maximum.
- Parameters:
A – the input symmetric tensor
maxiter – (default 500) maximum number of iterations
tol – (default 1.e-10) tolerance on the solution of the eigenvalue problem
x0 – (default random on the sphere) starting point
history – (default False) wether to return the history of the power iterations
- tensiometer.utilities.tensor_eigenvalues.max_tRq_shift_power(A, alpha, maxiter=1000, tol=1e-10, x0=None, history=False)[source]
Shifted symmetric power iterations, also called SS-HOPM, for tensor eigenvalues. Described in https://arxiv.org/abs/1007.1267 The algorithm is not guaranteed to produce the global maximum but only a convex maximum. We advice to run the algorithm multiple times to make sure that the solution that is found is the global maximum.
- Parameters:
A – the input symmetric tensor
alpha – the input fixed shift
maxiter – (default 500) maximum number of iterations.
tol – (default 1.e-10) tolerance on the solution of the eigenvalue problem
x0 – (default random on the sphere) starting point
history – (default False) wether to return the history of the power iterations
- tensiometer.utilities.tensor_eigenvalues.number_eigenvalues(d, m)[source]
Number of eigenvalues of a symmetric tensor of order m and dimension d.
- Parameters:
d – number of dimensions
m – rank of the tensor
- Returns:
the number of eigenvalues
- tensiometer.utilities.tensor_eigenvalues.random_symm_positive_tensor(d, m, vmin=0.0, vmax=1.0)[source]
Generate a random positive symmetric tensor of even order. There is no guarantee on the distribution of the elements, just that they are all different…
- Parameters:
d – number of dimensions
m – rank of the tensor
vmin – minimum value of the tensor elements
vmax – maximum value of the tensor elements
- Returns:
the random symmetric tensor
- tensiometer.utilities.tensor_eigenvalues.random_symm_tensor(d, m, vmin=0.0, vmax=1.0)[source]
Generate a random symmetric tensor of dimension d and rank m. There is no guarantee on the distribution of the elements, just that they are all different…
- Parameters:
d – number of dimensions
m – rank of the tensor
vmin – minimum value of the tensor elements
vmax – maximum value of the tensor elements
- Returns:
the random symmetric tensor
- tensiometer.utilities.tensor_eigenvalues.tRq(x, A)[source]
Symmetric Tensor Rayleigh quotient.
- Parameters:
x – the input vector
A – the input tensor
- tensiometer.utilities.tensor_eigenvalues.tRq_brute_2D(A, num_points=2000)[source]
Brute force maximization of the Tensor Rayleigh quotient on the circle. Works for problems of any rank and 2 dimensions. Since the problem is one dimensional samples the function on num_points and returns the maximum.
- Parameters:
A – the input tensor
num_points – the number of points of the search
- tensiometer.utilities.tensor_eigenvalues.tRq_dyn_sys_brute(t, x, A, d, m)[source]
Dynamical system to solve for the biggest tensor eigenvalue. Derivative function. Described in https://arxiv.org/abs/1805.00903
- Parameters:
t – input time
x – input position
A – input symmetric tensor
d – input number of dimensions
m – input rank of the tensor A
- Returns:
the derivative of the dynamical system
- tensiometer.utilities.tensor_eigenvalues.tRq_nder(x, A, n)[source]
Euclidean derivative of order n of the Tensor Rayleigh quotient problem.
- Parameters:
x – the input vector
A – the input tensor
n – the order of the derivative
- tensiometer.utilities.tensor_eigenvalues.tensor_contraction(A, x, n=1)
Contracts a symmetric tensor of rank m with a given vector n times. This function is meant to be as fast as possible, no check is performed.
- Parameters:
A – the inmput symmetric tensor of rank m
x – the input vector to contract
n – the number of times to contract
- Returns:
the tensor contracted n times. This is a tensor of rank m-n.
- tensiometer.utilities.tensor_eigenvalues.tensor_contraction_brute_1(A, x, n=1)[source]
Contracts a symmetric tensor of rank m with a given vector n times. This function is meant to be as fast as possible, no check is performed.
- Parameters:
A – the inmput symmetric tensor of rank m
x – the input vector to contract
n – the number of times to contract
- Returns:
the tensor contracted n times. This is a tensor of rank m-n.
- tensiometer.utilities.tensor_eigenvalues.tensor_contraction_brute_2(A, x, n=1)[source]
Contracts a symmetric tensor of rank m with a given vector n times. This function is meant to be as fast as possible, no check is performed.
- Parameters:
A – the inmput symmetric tensor of rank m
x – the input vector to contract
n – the number of times to contract
- Returns:
the tensor contracted n times. This is a tensor of rank m-n.