Skip to content

Commit

Permalink
add inplace to README
Browse files Browse the repository at this point in the history
  • Loading branch information
francescoalemanno committed Mar 23, 2022
1 parent 70dcdf7 commit 1a304a6
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ returns a named tuple (x, error, iters) where:


# Examples
Scalar function example
## Scalar function example

```julia
using FixedPoint
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)
Expand All @@ -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))
```

0 comments on commit 1a304a6

Please sign in to comment.