This file contains hidden or 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
| f(t) = +(t...,) | |
| @code_typed f(ntuple(identity, 5)) # what you expect | |
| @code_typed f(ntuple(identity, 18)) # something is going on | |
| @code_typed f(ntuple(identity, 33)) # _apply |
This file contains hidden or 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
| const PSOS_ERROR = | |
| "the Poincaré surface of section did not have any points!" | |
| function poincaresos2(ds::CDS{IIP, S, D}, plane, tfinal = 1000.0; | |
| direction = +1, Ttr::Real = 0.0, warning = true, | |
| diffeq...) where {IIP, S, D} | |
| integ = integrator(ds; diffeq...) | |
| planecrossing = PlaneCrossing{D}(plane, direction > 0 ) |
This file contains hidden or 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
| import TreeViews | |
| struct DiffEqMock end | |
| typecolor(x) = "<span class=\"syntax--support syntax--type syntax--julia\">$(x)</span>" | |
| TreeViews.hastreeview(::DiffEqMock) = true |
This file contains hidden or 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
| function dist(ds::CDS, d0, Ttr, T; diff_eq_kwargs=Dict(:abstol=>1e-14, | |
| :reltol=>1e-14, :solver=>Vern9(), :maxiters=>1e9), | |
| inittest=ChaosTools.inittest_default(dimension(ds))) | |
| pinteg = parallel_integrator(ds, |
This file contains hidden or 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
| Julia 0.7: | |
| julia> @code_native A*B | |
| .text | |
| ; Function * { | |
| ; Location: matrix_multiply.jl:9 | |
| pushq %rbp | |
| movq %rsp, %rbp | |
| ; Function _mul; { | |
| ; Location: matrix_multiply.jl:75 |
This file contains hidden or 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
| cd(Pkg.dir("DynamicalBilliards")) | |
| function rn(filename) | |
| str = read(filename, String) | |
| str = replace(str, "\r\n" => "\n") | |
| write(filename, str) | |
| end | |
| function totalrn(path = pwd()) | |
| for f in readdir(path) |
This file contains hidden or 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
| # && Exporting to movie: | |
| framerate = 5 | |
| anim = `ffmpeg -y -framerate $(framerate) -start_number 1 -i $(savename)_%d.png | |
| -c:v libx264 -pix_fmt yuv420p -preset veryslow -profile:v baseline -level 3.0 $(savename).mp4` | |
| run(anim) | |
| # To reduce movie size, you can add the option: | |
| `-b:v 2048k` | |
| # lower number = lower size = lower quality |
This file contains hidden or 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 DynamicalSystems, Luxor | |
| function double_pendulum(u0=rand(4); | |
| G=10.0, L1 = 1.0, L2 = 1.0, M1 = 1.0, M2 = 1.0) | |
| @inline @inbounds function eom_dp!(du, state) | |
| du[1] = state[2] | |
| gm = 0.01 | |
| del_ = state[3] - state[1] | |
| den1 = (M1 + M2)*L1 - M2*L1*cos(del_)*cos(del_) | |
| du[2] = (M2*L1*state[2]*state[2]*sin(del_)*cos(del_) + |
This file contains hidden or 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
| function f1(N::Int) | |
| s = 0 | |
| for n = 1:N | |
| n % 2 == 0 && (s += 2; continue) | |
| s += 1 | |
| end | |
| s | |
| end | |
| function f2(N::Int) |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| """ | |
| =========================== | |
| The double pendulum problem | |
| =========================== | |
| This animation illustrates the double pendulum problem. | |
| """ |