Skip to content

Commit

Permalink
Merge pull request #12 from jlperla/patch-2
Browse files Browse the repository at this point in the history
Inplace example did not work without modification
  • Loading branch information
matthieugomez authored Nov 7, 2018
2 parents 7e7cbeb + db08f61 commit 77519a7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ This package is written with large scale problems in mind. In particular, memory
```julia
using LeastSquaresOptim
function rosenbrock_f!(out, x)
out[1] = 1 - x[1]
out[2] = 100 * (x[2]-x[1]^2)
out[1] = 1 - x[1]
out[2] = 100 * (x[2]-x[1]^2)
end
optimize!(LeastSquaresProblem(x = x, f! = rosenbrock_f!, output_length = 2))
optimize!(LeastSquaresProblem(x = zeros(2), f! = rosenbrock_f!, output_length = 2))

# if you want to use gradient
function rosenbrock_g!(J, x)
J[1, 1] = -1
J[1, 2] = 0
J[2, 1] = -200 * x[1]
J[2, 2] = 109
J[1, 1] = -1
J[1, 2] = 0
J[2, 1] = -200 * x[1]
J[2, 2] = 100
end
optimize!(LeastSquaresProblem(x = x, f = rosenbrock_f, g! = rosenbrock_g!))
optimize!(LeastSquaresProblem(x = zeros(2), f! = rosenbrock_f!, g! = rosenbrock_g!, output_length = 2))
```

2. You can also specify a particular least square solver (a least square optimization method proceeds by solving successively linear least squares problems `min||Ax - b||^2`).
Expand Down

0 comments on commit 77519a7

Please sign in to comment.