This file contains 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 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 |
This file contains 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
(* Good morning everyone, I'm currently learning ocaml for one of my CS class and needed to implement | |
an avl tree using ocaml. I thought that it would be interesting to go a step further and try | |
to verify the balance property of the avl tree using the type system. Here's the resulting code | |
annotated for people new to the ideas of type level programming :) | |
*) | |
(* the property we are going to try to verify is that at each node of our tree, the height difference between | |
the left and the right sub-trees is at most of 1. *) |
This file contains 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
### 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)) |
This file contains 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 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)) |
This file contains 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 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); |
This file contains 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 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. |
This file contains 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
# Answer to: https://twitter.com/1HaskellADay/status/875063542784958465 | |
# | |
# So the Initial Value Problem (IVP) you want to solve seems to be the following | |
# | |
# dy/dx = 3*exp(-x) - 0.4*y | |
# y(x_0) = y_0 with x_0 = 0 and y_0 = 5 | |
# | |
# You then ask: what is the value of y when x = 3? | |
# | |
# This can be computed using the Runge Kutta method by feeding it |
This file contains 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
(* TODO: use Random.State *) | |
open Random;; | |
open List;; | |
(* =========================================== General Utils = *) | |
let sign x = if x < 0 then -1 else 1;; | |
let truncate x l = sign x * min (abs x) l;; |
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.
NewerOlder