From 1a304a6239324044718d17cd22a67bcc3331c3f5 Mon Sep 17 00:00:00 2001 From: Francesco Alemanno <50984334+francescoalemanno@users.noreply.github.com> Date: Wed, 23 Mar 2022 19:27:19 +0100 Subject: [PATCH] add inplace to README --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 03b8d88..feb1fac 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ returns a named tuple (x, error, iters) where: # Examples -Scalar function example +## Scalar function example ```julia using FixedPoint @@ -34,7 +34,7 @@ s = afps(x -> 2 - x^2 + x, 1.3) @show s.x, √2 ``` -Vector function example +## Vector function example ```julia using FixedPoint, LinearAlgebra Ts = LinRange(0.01, 2.0, 500) @@ -47,3 +47,21 @@ s = afps( ) @show norm(f(s.x).-s.x) ``` + +## Inplace version +for the inplace method use `afps!` as +```julia +Ts = LinRange(0.01, 2.0, 500) +βs = 1 ./ Ts +function f!(out,x) + @. out = tanh(βs * x) +end +x = zero(βs) .+ 1 +afps!( + f!, + x, + grad_norm = x -> maximum(abs, x), + iters = 5000, +) +@show maximum(abs, x .- tanh.(βs .* x)) +``` \ No newline at end of file