Skip to content

Instantly share code, notes, and snippets.

@matthieubulte
matthieubulte / gadfly_animate.jl
Last active January 21, 2022 08:43
Animations in Gadfly
using Gadfly
import Cairo, Fontconfig
using Printf
using FFMPEG
#################################### This is pretty much the same code as in https://github.com/JuliaPlots/Plots.jl/blob/master/src/animation.jl
struct Animation
dir::String
frames::Vector{String}
kwargs::Iterators.Pairs
### A Pluto.jl notebook ###
# v0.12.21
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local el = $(esc(element))
@matthieubulte
matthieubulte / main.jl
Created April 24, 2021 17:31
Symbolic expression from a string
using MacroTools
using Symbolics
function parse(strexpr)
expr = Meta.parse(strexpr)
freevars = Set()
expr = MacroTools.postwalk(x -> begin
if isa(x, Symbol) && !isdefined(Base, x)
push!(freevars, Variable(x))
Expr(:call, Variable, QuoteNode(x))
@matthieubulte
matthieubulte / main.jl
Created April 2, 2021 22:56
Using Symbolics.jl to compile sparse matrix operations
using LinearAlgebra, BenchmarkTools, SparseArrays, SymbolicUtils, Symbolics
## Problem setup
const z = zeros;
wx = Float64[ 0 -1 0;
1 0 0;
0 0 0;];
Ak_1 = [ wx -I zeros(3,12);
@matthieubulte
matthieubulte / main.jl
Created March 26, 2021 22:03
Compiling sparse matrix multiplication
using LinearAlgebra
using BenchmarkTools
using SparseArrays
# To exploit the sparsity of the matrix as much as possible, pre-compile the multiplication operation
# to skip the matrix entries look-up. Since the matrix is sparse this might generate only a few operations
# which are all inlined.
# Note that this only works with small matrices since otherwise the size of the function will just be to
# large.
# Note that this could also be avoided, but this is another topic.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matthieubulte
matthieubulte / Estimating a covariance.ipynb
Last active June 4, 2019 21:29
Automatic MLE of a covariance matrix via Cholesky factorization
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matthieubulte
matthieubulte / RandomRDD with custom PRNG.ipynb
Last active June 1, 2019 18:08
RandomRDD with custom PRNG.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.