Skip to content

Instantly share code, notes, and snippets.

View dpiponi's full-sized avatar
🧱
In material form

Dan Piponi dpiponi

🧱
In material form
View GitHub Profile
@dpiponi
dpiponi / Circle packing
Created May 12, 2015 19:41
Julia code using Divide and Concur algorithm to pack circles in a circle
function dm(Pa, Pb, y, β, n)
for i in 1:n
if i%100 == 0
print("Iteration $i/$n\n")
end
fay = (1-1/β)*Pa(y)+(1/β)*y
fby = (1+1/β)*Pb(y)-(1/β)*y
y = y+β*(Pa(fby)-Pb(fay))
# @show(y)
end
> {-# LANGUAGE ExplicitForAll, RankNTypes #-}
> import Control.Monad.Cont
An Eilenberg-Moore algebra for a monad t (a t-algebra) is one of these:
> type Algebra t x = t x -> x
satisfying these laws (page 3):
//
// On MacOSX compile with:
// g++ -framework OpenGL -framework GLUT -o example example.cpp
//
#include <stdlib.h>
#include <GLUT/glut.h>
GLuint program;
@dpiponi
dpiponi / example.cu
Created December 20, 2011 17:36
Minimal CUDA example (with helpful comments).
#include <stdio.h>
//
// Nearly minimal CUDA example.
// Compile with:
//
// nvcc -o example example.cu
//
#define N 1000
@dpiponi
dpiponi / example.cu
Created December 19, 2011 22:42
Minimal CUDA example
#include <stdio.h>
#define N 1000
__global__
void add(int *a, int *b) {
int i = blockIdx.x;
if (i<N) {
b[i] = 2*a[i];
}