Jutho / KrylovKit.jl

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

is fill! a required operation? #27

Closed rveltz closed 4 years ago

rveltz commented 4 years ago

Hi,

I am using your package and I get the following error message on this simple example. However the fill! method does not seem to be required in your docs. In essence, my "issue" is the same as https://github.com/Jutho/KrylovKit.jl/issues/25

using KrylovKit
using PseudoArcLengthContinuation

function f(dx::BorderedArray)
    out = copy(dx)
    out.u .*= 2
    out.p .*= 2
    return out
end

KrylovKit.eigsolve(f, BorderedArray(rand(100),rand(2)), 2, :LR; verbosity = 2, krylovdim = 50, maxiter = 20 )

returns

[ Info: Arnoldi schursolve in iter 1: 5 values converged, normres = (1.90e-35, 8.52e-21)
ERROR: MethodError: no method matching fill!(::BorderedArray{Array{Complex{Float64},1},Array{Complex{Float64},1}}, ::Complex{Float64})
Closest candidates are:
  fill!(::Array{T,N} where N, ::Any) where T at array.jl:308
  fill!(::BitArray, ::Any) at bitarray.jl:351
  fill!(::SubArray{Bool,#s627,#s626,Tuple{AbstractUnitRange{Int64}},L} where L where #s626<:BitArray where #s627, ::Any) at multidimensional.jl:1268
  ...
Stacktrace:
 [1] unproject!(::BorderedArray{Array{Complex{Float64},1},Array{Complex{Float64},1}}, ::KrylovKit.OrthonormalBasis{BorderedArray{Array{Float64,1},Array{Float64,1}}}, ::SubArray{Complex{Float64},1,Array{Complex{Float64},2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true}, ::Int64, ::Int64, ::Base.OneTo{Int64}) at /Users/rveltz/.julia/packages/KrylovKit/mHobB/src/orthonormal.jl:94
 [2] unproject! at /Users/rveltz/.julia/packages/KrylovKit/mHobB/src/orthonormal.jl:88 [inlined]
 [3] mul! at /Users/rveltz/.julia/packages/KrylovKit/mHobB/src/orthonormal.jl:58 [inlined]
 [4] * at /Users/rveltz/.julia/packages/KrylovKit/mHobB/src/orthonormal.jl:56 [inlined]
 [5] #56 at ./none:0 [inlined]
 [6] iterate at ./generator.jl:47 [inlined]
 [7] collect(::Base.Generator{KrylovKit.ColumnIterator{Array{Complex{Float64},2},Base.OneTo{Int64}},KrylovKit.var"#56#59"{KrylovKit.OrthonormalBasis{BorderedArray{Array{Float64,1},Array{Float64,1}}}}}) at ./array.jl:622
 [8] eigsolve(::Function, ::BorderedArray{Array{Float64,1},Array{Float64,1}}, ::Int64, ::Symbol, ::Arnoldi{ModifiedGramSchmidt2,Float64}) at /Users/rveltz/.julia/packages/KrylovKit/mHobB/src/eigsolve/arnoldi.jl:123
 [9] #eigsolve#41 at /Users/rveltz/.julia/packages/KrylovKit/mHobB/src/eigsolve/eigsolve.jl:163 [inlined]
 [10] (::KrylovKit.var"#kw##eigsolve")(::NamedTuple{(:verbosity, :krylovdim, :maxiter),Tuple{Int64,Int64,Int64}}, ::typeof(eigsolve), ::Function, ::BorderedArray{Array{Float64,1},Array{Float64,1}}, ::Int64, ::Symbol) at ./none:0
 [11] top-level scope at none:0
Jutho commented 4 years ago

Yes, it seems that fill! is indeed used in that piece of code. I assume I could replace this with just rmul!(y, 0), it is just used to zero-initialize the custom array object. I will try to fix this soon.

Jutho commented 4 years ago

This should now be fixed on version 0.4.2. Feel free to reopen if the problem persists.

rveltz commented 4 years ago

thank you