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 v0.7's stack-allocation optimizations and escape analysis | |
https://github.com/JuliaLang/julia/pull/22684 | |
Watch it in action: stack-allocated mutable static sized arrays. Example thanks to Valentin Churavy. | |
julia> function f(x::Int64) | |
A = MArray{Tuple{3}}(1, 2, 3) | |
A[2] += x | |
return A[2]-A[1] |
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 Base.Test | |
using BoundaryValueDiffEq, DiffEqBase, DiffEqDevTools | |
# First order test | |
function func_1!(x, y, du) | |
du[1] = y[2] | |
du[2] = 0 | |
end | |
# Not able to change the initial condition. |
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
Variables: | |
#self#::OrdinaryDiffEq.#perform_step! | |
integrator::OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.Tsit5,Array{Float64,1},Float64,Float64,Float64,Array{Array{Float64,1},1},DiffEqBase.ODESolution{Float64,2,Array{Array{Float64,1},1},Void,Void,Array{Float64,1},Array{Array{Array{Float64,1},1},1},DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,#df,Void,UniformScaling{Int64}},OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.InterpolationData{#df,Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}}},Array{Float64,1},#df,Void,OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,DiffEqBase.#ODE_DEFAULT_NORM,DiffEqBase.CallbackSet{Tuple{},Tuple{}},DiffEqBase.#ODE_DEFAULT_ISOUTOFDOMAIN,DiffEqBase.#ODE_D |
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
SymEngine.Basic[x0 + 0.0833333333333333*(1.5*x0 - x0*y0 - (y0 + 0.5*((y0 + 0.25*((x0 + 0.25*(1.5*x0 - x0*y0))*(y0 + 0.25*(-3*y0 + x0*y0)) - 3*(y0 + 0.25*(-3*y0 + x0*y0))))*(x0 + 0.25*(-(x0 + 0.25*(1.5*x0 - x0*y0))*(y0 + 0.25*(-3*y0 + x0*y0)) + 1.5*(x0 + 0.25*(1.5*x0 - x0*y0)))) - 3*(y0 + 0.25*((x0 + 0.25*(1.5*x0 - x0*y0))*(y0 + 0.25*(-3*y0 + x0*y0)) - 3*(y0 + 0.25*(-3*y0 + x0*y0))))))*(x0 + 0.5*(-(y0 + 0.25*((x0 + 0.25*(1.5*x0 - x0*y0))*(y0 + 0.25*(-3*y0 + x0*y0)) - 3*(y0 + 0.25*(-3*y0 + x0*y0))))*(x0 + 0.25*(-(x0 + 0.25*(1.5*x0 - x0*y0))*(y0 + 0.25*(-3*y0 + x0*y0)) + 1.5*(x0 + 0.25*(1.5*x0 - x0*y0)))) + 1.5*(x0 + 0.25*(-(x0 + 0.25*(1.5*x0 - x0*y0))*(y0 + 0.25*(-3*y0 + x0*y0)) + 1.5*(x0 + 0.25*(1.5*x0 - x0*y0)))))) + 1.5*(x0 + 0.5*(-(y0 + 0.25*((x0 + 0.25*(1.5*x0 - x0*y0))*(y0 + 0.25*(-3*y0 + x0*y0)) - 3*(y0 + 0.25*(-3*y0 + x0*y0))))*(x0 + 0.25*(-(x0 + 0.25*(1.5*x0 - x0*y0))*(y0 + 0.25*(-3*y0 + x0*y0)) + 1.5*(x0 + 0.25*(1.5*x0 - x0*y0)))) + 1.5*(x0 + 0.25*(-(x0 + 0.25*(1.5*x0 - x0*y0))*(y0 + 0.25*(-3*y0 + x0* |
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
SymEngine.Basic[0. + 4.47215104103088*x - 1.36844154947903*x*y + 0.151438560380598*x*y^2 - 0.00923846952746669*x*y^3 + 5.23451694212525e-05*x*y^4 + 1.17843605321514e-05*x*y^5 - 2.92600484558672e-07*x*y^6 + 4.11218785990713e-09*x*y^7 + 7.48501594966537e-11*x*y^8 - 0.672247405107334*x^2*y + 0.370664426736858*x^2*y^2 - 0.0752239972222541*x^2*y^3 + 0.00931494973548523*x^2*y^4 - 0.000773652120635689*x^2*y^5 + 4.1304004934513e-05*x^2*y^6 - 8.80277168398071e-07*x^2*y^7 - 3.07285079704276e-08*x^2*y^8 + 2.48120225104779e-09*x^2*y^9 - 2.22365631233417e-11*x^2*y^10 - 5.3250992844628e-13*x^2*y^11 + 3.88477571287545e-14*x^2*y^12 - 9.64844546215222e-16*x^2*y^13 + 1.87911964770983e-17*x^2*y^14 - 0.192348763958449*x^3*y + 0.169162141060118*x^3*y^2 - 0.0829571943460876*x^3*y^3 + 0.021476513446275*x^3*y^4 - 0.00348656942438397*x^3*y^5 + 0.000403255555876659*x^3*y^6 - 3.48351926640532e-05*x^3*y^7 + 2.32018077215583e-06*x^3*y^8 - 1.16462622982937e-07*x^3*y^9 + 3.49737461145191e-09*x^3*y^10 + 2.02368983871224e-11*x^3*y^11 - 7.563 |
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
SymEngine.Basic[x + 0.0833333333333333*(1.5*x - x*y - (x + 0.5*(-(y + 0.25*((y + 0.25*(-3*y + x*y))*(x + 0.25*(1.5*x - x*y)) - 3*(y + 0.25*(-3*y + x*y))))*(x + 0.25*(-(y + 0.25*(-3*y + x*y))*(x + 0.25*(1.5*x - x*y)) + 1.5*(x + 0.25*(1.5*x - x*y)))) + 1.5*(x + 0.25*(-(y + 0.25*(-3*y + x*y))*(x + 0.25*(1.5*x - x*y)) + 1.5*(x + 0.25*(1.5*x - x*y))))))*(y + 0.5*((y + 0.25*((y + 0.25*(-3*y + x*y))*(x + 0.25*(1.5*x - x*y)) - 3*(y + 0.25*(-3*y + x*y))))*(x + 0.25*(-(y + 0.25*(-3*y + x*y))*(x + 0.25*(1.5*x - x*y)) + 1.5*(x + 0.25*(1.5*x - x*y)))) - 3*(y + 0.25*((y + 0.25*(-3*y + x*y))*(x + 0.25*(1.5*x - x*y)) - 3*(y + 0.25*(-3*y + x*y)))))) + 1.5*(x + 0.5*(-(y + 0.25*((y + 0.25*(-3*y + x*y))*(x + 0.25*(1.5*x - x*y)) - 3*(y + 0.25*(-3*y + x*y))))*(x + 0.25*(-(y + 0.25*(-3*y + x*y))*(x + 0.25*(1.5*x - x*y)) + 1.5*(x + 0.25*(1.5*x - x*y)))) + 1.5*(x + 0.25*(-(y + 0.25*(-3*y + x*y))*(x + 0.25*(1.5*x - x*y)) + 1.5*(x + 0.25*(1.5*x - x*y)))))) + 2*(-(y + 0.25*(-3*y + x*y))*(x + 0.25*(1.5*x - x*y)) - (y + 0.25*((y + 0.25*(- |
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
# Pkg.add("SpecialMatrices") # Only need to run the first time | |
using SpecialMatrices, DiffEqBase | |
A = Strang(11) | |
function g(t,u) | |
for i in eachindex(u) | |
2 - u[i] | |
end | |
u | |
end | |
u0 = zeros(11); u0[6] = 10 |
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> cache = init(prob,DP5()) | |
typeof(utilde) = Array{Float64,2} | |
typeof(cache) = OrdinaryDiffEq.DP5Cache{Array{Float64,2},Any,Array{Float64,2},Any,Any} | |
cache = OrdinaryDiffEq.DP5Cache{Array{Float64,2},Array{Float64,2},Array{Float64,2},Array{Float64,2},OrdinaryDiffEq.DP5ConstantCache{Float64,Float64}}([0.260125 0.9676; 0.190313 0.645691; 0.660911 0.545968; 0.0671932 0.526845], [0.260125 0.9676; 0.190313 0.645691; 0.660911 0.545968; 0.0671932 0.526845], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], [0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0], OrdinaryDiffEq.DP5ConstantCache{Flo |
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 DiffEqBase | |
using OrdinaryDiffEq | |
############################################################################### | |
# Variables | |
############################################################################### | |
# Global variable to store the acceleration. | |
# This solution was selected just for the sake of simplification. Don't use | |
# global variables! |
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
abstract DEDataArray{T} <: AbstractArray{T,1} | |
similar(A::DEDataArray) = deepcopy(A) | |
done(A::DEDataArray, i::Int64) = done(A.x,i) | |
eachindex(A::DEDataArray) = eachindex(A.x) | |
next(A::DEDataArray, i::Int64) = next(A.x,i) | |
start(A::DEDataArray) = start(A.x) | |
length(A::DEDataArray) = length(A.x) |