Skip to content

Instantly share code, notes, and snippets.

@nightuser
nightuser / main.py
Created February 22, 2015 19:12
Simple Lehmer random number generator and Pi calculus. No NumPy, pure Python only.
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
from functools import reduce
from math import sqrt
from random import random
class MyRandomizer:
@nightuser
nightuser / toroidal.R
Last active August 29, 2015 14:12
Toroidal (R)
toroidal <- function(points, values) {
d <- ncol(points)
shifts <- sapply(
1:d,
function(x) { max(points[, x]) - min(points[, x]) }
)
directions <- c(0, 1, -1)
all_shifts <- expand.grid(
lapply(
/*
Dependencies: LAPACK
Ubuntu: sudo apt-get install liblapack3 liblapack-dev
Compile: g++ -o barycentric barycentric.cpp -O3 -Wall -Wextra -pedantic -std=gnu++11 -llapack
*/
#include <iostream>
#include <cassert>
@nightuser
nightuser / torus_interpolation.py
Last active August 29, 2015 14:11
Torus topology interconnection interpolation
import itertools
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Delaunay
points = np.array([
[0, 0],
[0, 2],
[2, 0],
[0.5, 0.5]