Skip to content

Instantly share code, notes, and snippets.

Jan Weidner jw3126

  • Freiburg, Germany
View GitHub Profile
View minimize_scaled_L1_diff.jl
using Test
using Convex1D
using BenchmarkTools
function minimize_scaled_L1_diff(xs, ys)
# find t::Number that minimizers f(t) = sum(abs, t*xs - ys)
# f is convex with piecewise constant derivative given by
# f'(t) = Σ xi * sign(t*xi - yi)
# One of the points ti := yi/xi must be a minimizer (for some xi !=0. If all xi==0 then f == const anyway)
# Based on remarks of Mathieu Tanneau in slack
jw3126 / conv1d.jl
Created Apr 27, 2020
Julia CUDA 1d nn style large batch convolution
View conv1d.jl
using CUDAnative, CuArrays
macro cushow(ex)
val = gensym("val")
s = string(ex)
$val = $(esc(ex))
CUDAnative.@cuprintln($(Expr(:string, s, " = ", val)))
View layered_array.jl
using Revise
using ArgCheck
struct LayeredArray{T, N, L} <: AbstractArray{T,N}
function LayeredArray(layers)
@argcheck !isempty(layers)
@argcheck first(layers) isa AbstractArray
l = first(layers)
L = typeof(layers)
View gist:e81cdf65c18610bc66066f06b9b72301
using Makie
using JuAFEM, SparseArrays
using LinearAlgebra
# Poisson example from JuAFEM docs
grid = generate_grid(Triangle, (20, 20));
dim = 2
jw3126 / advection.jl
Created Aug 5, 2019
advection problems
View advection.jl
# ]add AbstractPlotting
# ]add Makie
using Makie
function step!(u_new, u, o)
# u_new[i] = u[i] + dt*v*(u[i] - u[i-1])/dx
for i in reverse(eachindex(u))
s = o.v*o.dt/o.dx
u_new[i] = u[i] + s * (u[i] - get(u, i-1, zero(eltype(u))))
jw3126 / release.jl
Created Apr 28, 2019
Tag and release package to local registry.
View release.jl
using LibGit2
using ArgCheck
using Pkg: TOML
import Pkg
import Registrator
struct Release
View LibGit2.jl
using LibGit2
repo_path = "LibGit2TestRepo"
repo_url = ""
rm(repo_path, recursive=true, force=true)
# init
repo = try
@info "Cloning repo"
jw3126 / DirichletAnnulusApproxFun.jl
Last active Jan 23, 2019
View DirichletAnnulusApproxFun.jl
using ApproxFun
using LinearAlgebra
using Interact
using Plots
a = 1.; b=5.
Ω = a..b
# Ω = Chebyshev(a..b)
r = Fun(identity, Ω)
Δ_rad = 𝒟^2 + 1.0/r * 𝒟
View MakieSphericalHarmonics.jl
using GSL
using Makie
struct Y
function Y(l,m)
@assert -l <= m <= l
# install egs
# make tutor2pp
sudo apt install at
exb tutor2pp test1 tutor_data p=42
You can’t perform that action at this time.