Skip to content

Commit 2a6e460

Browse files
Fix #101
1 parent 25162e1 commit 2a6e460

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ It's always fun to start out with a tutorial before jumping into the details!
4242
Suppose we had the functions:
4343

4444
```julia
45+
using FiniteDiff, StaticArrays
46+
4547
fcalls = 0
4648
function f(dx,x) # in-place
4749
global fcalls += 1
@@ -53,11 +55,12 @@ function f(dx,x) # in-place
5355
nothing
5456
end
5557

58+
const N = 10
5659
handleleft(x,i) = i==1 ? zero(eltype(x)) : x[i-1]
5760
handleright(x,i) = i==length(x) ? zero(eltype(x)) : x[i+1]
5861
function g(x) # out-of-place
5962
global fcalls += 1
60-
@SVector [handleleft(x,i) - 2x[i] + handleright(x,i) for i in 1:length(x)]
63+
@SVector [handleleft(x,i) - 2x[i] + handleright(x,i) for i in 1:N]
6164
end
6265
```
6366

@@ -66,8 +69,7 @@ do is ask for the Jacobian. If we want to allocate the result, we'd use the
6669
allocating function `finite_difference_jacobian` on a 1-argument function `g`:
6770

6871
```julia
69-
using StaticArrays
70-
x = @SVector rand(10)
72+
x = @SVector rand(N)
7173
FiniteDiff.finite_difference_jacobian(g,x)
7274

7375
#=

0 commit comments

Comments
 (0)