Skip to content

Instantly share code, notes, and snippets.

🥑

Yingbo Ma YingboMa

🥑
  • Massachusetts
Block or report user

Report or block YingboMa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fd_typed.jl
│ ─ %-1 = invoke perform_step!(::OrdinaryDiffEq.ODEIntegrator{Tsit5,true,Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#25#26",Float64},Float64,4},1},Float64,DiffEqBase.NullParameters,Float
64,Float64,Float64,Array{Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#25#26",Float64},Float64,4},1},1},ODESolution{ForwardDiff.Dual{ForwardDiff.Tag{var"#25#26",Float64},Float64,4},2,Array{
Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#25#26",Float64},Float64,4},1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#25#26",Float64},Float
64,4},1},1},1},ODEProblem{Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#25#26",Float64},Float64,4},1},Tuple{Float64,Float64},true,DiffEqBase.NullParameters,ODEFunction{true,typeof(lorenz),L
inearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple
{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFuncti
View fd_llvm.ll
define void @"julia_perform_step!_19254"(%jl_value_t addrspace(10)* nonnull align 8 dereferenceable(304), %jl_value_t addrspace(10)* nonnull align 8 dereferenceable(544), i8) {
top:
%3 = addrspacecast %jl_value_t addrspace(10)* %0 to %jl_value_t addrspace(11)*
%4 = bitcast %jl_value_t addrspace(11)* %3 to i8 addrspace(11)*
%5 = getelementptr inbounds i8, i8 addrspace(11)* %4, i64 32
%6 = bitcast i8 addrspace(11)* %5 to double addrspace(11)*
%7 = load double, double addrspace(11)* %6, align 8
%8 = getelementptr inbounds i8, i8 addrspace(11)* %4, i64 48
%9 = bitcast i8 addrspace(11)* %8 to %jl_value_t addrspace(10)* addrspace(11)*
%10 = load %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)* addrspace(11)* %9, align 8
@YingboMa
YingboMa / specialize_vararg.jl
Created Jan 12, 2020
Got from Mason Protter
View specialize_vararg.jl
# by Mason Protter
using MacroTools: MacroTools, splitdef, combinedef, @capture
macro specialize_vararg(n::Int, fdef)
d = splitdef(fdef)
args = d[:args][end]
@assert d[:args][end] isa Expr && d[:args][end].head == Symbol("...")
args_symbol = d[:args][end].args[]
fdefs = Expr(:block)
for i in 1:n-1
di = deepcopy(d)
View D_sicm.jl
using ModelingToolkit
using ModelingToolkit: Differential, expand_derivatives, Expression, Operation, simplify_constants
function D(f)
(args...) -> begin
syms = map(_->Variable(gensym())(), args)
ex = f(syms...)
ds = map(s->Differential(s), syms)
ops = [expand_derivatives(ds[i](ex)) for i in eachindex(syms)]
rules = Dict( collect(zip(syms, args)) )
View .tmux.conf
set-option -g history-limit 65536
set -g -a terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
set -g mouse on
#bind -n C-k clear-history
# default shell
set-option -g default-shell /usr/bin/fish
# clipboard settings
View heating_equation.jl
using OrdinaryDiffEq, LabelledArrays
N = 40 # Number of heated units
Cu = N == 1 ? [2e7] : (ones(N) .+ range(0,1.348,length=N))*1e7 # "Heat capacity of heated units";
Cd = 2e6*N # "Heat capacity of distribution circuit";
Gh = 200 # "Thermal conductance of heating elements";
Gu = 150 # "Thermal conductance of heated units to the atmosphere";
Qmax = N*3000 # "Maximum power output of heat generation unit";
Teps = 0.5 # "Threshold of heated unit temperature controllers";
View diffeqfastbc.jl
import Base.Broadcast: _broadcast_getindex, preprocess, preprocess_args, Broadcasted, broadcast_unalias, combine_axes, broadcast_shape, check_broadcast_axes, check_broadcast_shape
import Base: copyto!, tail, axes
struct DiffEqBC{T}
x::T
end
@inline axes(b::DiffEqBC) = axes(b.x)
Base.@propagate_inbounds _broadcast_getindex(b::DiffEqBC, i) = _broadcast_getindex(b.x, i)
Base.@propagate_inbounds _broadcast_getindex(b::DiffEqBC{<:AbstractArray{<:Any,0}}, i) = b.x[]
Base.@propagate_inbounds _broadcast_getindex(b::DiffEqBC{<:AbstractVector}, i) = b.x[i[1]]
Base.@propagate_inbounds _broadcast_getindex(b::DiffEqBC{<:AbstractArray}, i) = b.x[i]
View bench_ODEs.jl
using OrdinaryDiffEq, DiffEqDevTools, Plots, ParameterizedFunctions, Sundials, ODEInterfaceDiffEq
using LinearAlgebra
BLAS.set_num_threads(1)
postfix = "PR"
setups = [
Dict(:alg=>Kvaerno5()),
Dict(:alg=>KenCarp4()),
Dict(:alg=>radau5()),
Dict(:alg=>Rodas4()),
Dict(:alg=>Rodas5()),
@YingboMa
YingboMa / lurec.jl
Last active Feb 17, 2019
Sivan Toledo's recursive LU algorithm
View lurec.jl
using LinearAlgebra
lurec(A, blocksize=16) = lurec!(copy(A), Vector{LinearAlgebra.BlasInt}(undef, min(size(A)...)), blocksize)
function lurec!(A::AbstractMatrix{T}, ipiv, blocksize) where T
info = Ref(zero(LinearAlgebra.BlasInt))
m, n = size(A)
mnmin = min(m, n)
reckernel!(A, m, mnmin, ipiv, info, blocksize)
LU{T, typeof(A)}(A, ipiv, info[])
end
View JacVec_VecJac.jl
using ReverseDiff, ForwardDiff
using Test
"""
vecjac(f, x, v) -> u
``v'J(f(x))``
"""
function vecjac(f, x, v)
tp = ReverseDiff.InstructionTape()
You can’t perform that action at this time.