Created
November 7, 2017 18:33
-
-
Save jrevels/fff056ea318923e0cf96bbb91e1a5e7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Cassette | |
function rosenbrock(x) | |
a = one(eltype(x)) | |
b = 100.0 | |
result = zero(a) | |
for i in 1:length(x)-1 | |
result += (a - x[i])^2 + b*(x[i+1] - x[i]^2)^2 | |
end | |
return result | |
end | |
Cassette.@context Ctx | |
f(x) = Cassette.@execute Ctx rosenbrock(x) | |
x = rand(1000) | |
# ideally, f(x) should have nearly the same performance as rosenbrock(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment