Jutho / KrylovKit.jl

Krylov methods for linear problems, eigenvalues, singular values and matrix functions
Other
284 stars 37 forks source link

geneigsolve not correctly identifying positive definite and hermitian matrices #67

Open JoeyT1994 opened 1 year ago

JoeyT1994 commented 1 year ago

I am trying to get geneigsolve working but having no luck.

For instance, the trivial example

using KrylovKit
using LinearAlgebra

A = Matrix(1I, 5,5)
B = Matrix(1I, 5,5)

@show KrylovKit.geneigsolve((A,B))

generates the following error:

image

And more complicated versions seem to generate similar errors (it complains the operators are not Hermitian or Positive Definite even when they are).

Am I missing something? I see the tests for geneigsolve don't seem to have such an issue?

JoeyT1994 commented 1 year ago

Following up. It seems to me there is a strange interdependence between A, B and v (the initial guess) when the code is performing the Hermiticity check.

For instance the following runs fine

A = [1.0 0.0; 0.0 1.0]
B = [1.2 0.0; 0.0 0.4]
v = [1.0, 1.0]

@show KrylovKit.geneigsolve((A,B), v; isposdef = true, issymmetric = true)

but the following raises an error

A = [1.0 0.0; 0.0 1.0]
B = [1.2 0.0; 0.0 0.4]
v = [0.0, -1.0]

@show KrylovKit.geneigsolve((A,B), v; isposdef = true, issymmetric = true)

I suppose the check must be happening on some projection of the operators in the Krylov basis but it seems too 'delicate' to make sense?