You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IterativeSolvers.jl's LOBPCG methods for partial eigen-decomposition provide a keyword argument interface for constraint operators/matrices. The documentation for this argument currently says
C: constraint to deflate the residual and solution vectors orthogonal to a subspace; must overload mul!
The requirements for constraint maps in the current implementation are actually much more strict than this (and much more strict than for the target operator and preconditioner).
I ran into this issue while trying to use constraints of type LinearMaps.FunctionMap with IterativeSolvers.lobpcg. During construction of callable Constraint structs, constraint operators pass through various pre-processing steps that are incompatible with general LinearMaps types (similar and Hermitian). More broadly, the algorithm for constraints seems to require setindex! via view and slicing, as well as ldiv!, see update! and methods of Constraint:
function (constr!::Constraint{Nothing})(X, X_temp)
nothing
end
function (constr!::Constraint)(X, X_temp)
@viewsifsize(constr!.Y, 2) >0
sizeX =size(X, 2)
sizeY =size(constr!.Y, 2)
gramYBV_view = constr!.gramYBV[1:sizeY, 1:sizeX]
mul!(gramYBV_view, adjoint(constr!.BY), X)
tmp_view = constr!.tmp[1:sizeY, 1:sizeX]
ldiv!(tmp_view, constr!.gram_chol, gramYBV_view)
mul!(X_temp, constr!.Y, tmp_view)
@inbounds X .= X .- X_temp
end
nothing
end
Could somebody more knowledgeable explain the actual requirements and suggested types for constraint operators? I think the main appeal of IterativeSolvers.lobpcg is compatibility with "matrix-free"/implicit linear operator types, so the currently undocumented constraint interface requirements could lead to confusion.
It would be great to allow more general constraint functions & operators if it wouldn't be too much work. IIUC, these extra requirements for constraint operators arise because nev (# eigenvalues/vectors solved) extra columns are glued onto the constraint matrix and mutated during each iteration. Could the same processing be achieved without constraining the constraints (hehe), just by creating a separate array? I would be glad to take a crack at it if a PR is desired, although this solver seems to be stuck mid-overhaul at the moment (#247).
The text was updated successfully, but these errors were encountered:
apologies, I think I misunderstood the intended input style for constraints here. Comparing with the docs for scipy.sparse.linalg.lobpcg (here) it looks like constraints is expecting an N x n_constraints array (just a few concatenated column vectors), where the target operator is N x N and n_constraints is determined by the number of independent constraints you want to apply. Is that right?
It would be helpful to see an example of this being using correctly.
Comparing with the docs for scipy.sparse.linalg.lobpcg (here) it looks like constraints is expecting an N x n_constraints array (just a few concatenated column vectors), where the target operator is N x N and n_constraints is determined by the number of independent constraints you want to apply. Is that right?
IterativeSolvers.jl's LOBPCG methods for partial eigen-decomposition provide a keyword argument interface for constraint operators/matrices. The documentation for this argument currently says
The requirements for constraint maps in the current implementation are actually much more strict than this (and much more strict than for the target operator and preconditioner).
I ran into this issue while trying to use constraints of type
LinearMaps.FunctionMap
withIterativeSolvers.lobpcg
. During construction of callableConstraint
structs, constraint operators pass through various pre-processing steps that are incompatible with generalLinearMaps
types (similar
andHermitian
). More broadly, the algorithm for constraints seems to requiresetindex!
viaview
and slicing, as well asldiv!
, seeupdate!
and methods ofConstraint
:IterativeSolvers.jl/src/lobpcg.jl
Lines 144 to 224 in ae01dfe
Could somebody more knowledgeable explain the actual requirements and suggested types for constraint operators? I think the main appeal of
IterativeSolvers.lobpcg
is compatibility with "matrix-free"/implicit linear operator types, so the currently undocumented constraint interface requirements could lead to confusion.It would be great to allow more general constraint functions & operators if it wouldn't be too much work. IIUC, these extra requirements for constraint operators arise because
nev
(# eigenvalues/vectors solved) extra columns are glued onto the constraint matrix and mutated during each iteration. Could the same processing be achieved without constraining the constraints (hehe), just by creating a separate array? I would be glad to take a crack at it if a PR is desired, although this solver seems to be stuck mid-overhaul at the moment (#247).The text was updated successfully, but these errors were encountered: