From 218bb23dcdcf8a71b4e39b241b714de4ac95c452 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Sun, 15 Dec 2024 16:42:58 -0500 Subject: [PATCH 1/3] Type specifications for GradientGrassmann --- src/algorithms/groundstate/gradient_grassmann.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/groundstate/gradient_grassmann.jl b/src/algorithms/groundstate/gradient_grassmann.jl index 6e640af40..f8228da12 100644 --- a/src/algorithms/groundstate/gradient_grassmann.jl +++ b/src/algorithms/groundstate/gradient_grassmann.jl @@ -23,9 +23,9 @@ with a preconditioner to induce the metric from the Hilbert space inner product. - `maxiter::Int`: maximum amount of iterations - `verbosity::Int`: level of information display """ -struct GradientGrassmann <: Algorithm - method::OptimKit.OptimizationAlgorithm - finalize!::Function +struct GradientGrassmann{O<:OptimKit.OptimizationAlgorithm,F} <: Algorithm + method::O + finalize!::F function GradientGrassmann(; method=ConjugateGradient, (finalize!)=OptimKit._finalize!, tol=Defaults.tol, maxiter=Defaults.maxiter, verbosity=2) From 719b0c95dcc7afbbf54b2e512a0cf31aff3d5f2d Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 16 Dec 2024 13:54:40 +0100 Subject: [PATCH 2/3] fix `new` signature --- src/algorithms/groundstate/gradient_grassmann.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/groundstate/gradient_grassmann.jl b/src/algorithms/groundstate/gradient_grassmann.jl index f8228da12..dee4cc04b 100644 --- a/src/algorithms/groundstate/gradient_grassmann.jl +++ b/src/algorithms/groundstate/gradient_grassmann.jl @@ -39,7 +39,7 @@ struct GradientGrassmann{O<:OptimKit.OptimizationAlgorithm,F} <: Algorithm msg = "method should be either an instance or a subtype of `OptimKit.OptimizationAlgorithm`." throw(ArgumentError(msg)) end - return new(m, finalize!) + return new{typeof(m),typeof(finalize!)}(m, finalize!) end end From dc6f196c1182a88631028e9ab04753316a1546c1 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 16 Dec 2024 13:55:52 +0100 Subject: [PATCH 3/3] update docstring --- src/algorithms/groundstate/gradient_grassmann.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/groundstate/gradient_grassmann.jl b/src/algorithms/groundstate/gradient_grassmann.jl index dee4cc04b..3c028ba6f 100644 --- a/src/algorithms/groundstate/gradient_grassmann.jl +++ b/src/algorithms/groundstate/gradient_grassmann.jl @@ -7,7 +7,7 @@ with a preconditioner to induce the metric from the Hilbert space inner product. ## Fields - `method::OptimKit.OptimizationAlgorithm`: algorithm to perform the gradient search -- `finalize!::Function`: user-supplied function which is applied after each iteration, with +- `finalize!`: user-supplied callable which is applied after each iteration, with signature `finalize!(x::GrassmannMPS.ManifoldPoint, f, g, numiter) -> x, f, g` ---