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
View TeX.inputplugin
#
METHOD: TABLE
ENCODE: Unicode
PROMPT: TeX 1.1
VERSION: 1.1
DELIMITER: ,
MAXCODE: 6
VALIDINPUTKEY: ^,.?!:;"'/\()[]{}<>$%&@*01234567890123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
TERMINPUTKEY:
BEGINCHARACTER
@dpiponi
dpiponi / example.cu
Created December 20, 2011 17:36
Minimal CUDA example (with helpful comments).
View example.cu
#include <stdio.h>
//
// Nearly minimal CUDA example.
// Compile with:
//
// nvcc -o example example.cu
//
#define N 1000
@dpiponi
dpiponi / main.cpp
Last active November 5, 2023 21:41
Min phase filter computation using QR decomposition
View main.cpp
#include <cmath>
#include <iostream>
#include <numeric>
#include <valarray>
#include <vector>
// Motivated by
// Computing the Minimum-Phase filter using the QL-Factorization
// Hansen, Morten; Christensen, Lars P.b.; Winther, Ole
// https://backend.orbit.dtu.dk/ws/portalfiles/portal/5161145/Hansen.pdf
@dpiponi
dpiponi / infill.glsl
Created May 18, 2022 03:39
Walk-on-spheres
View infill.glsl
// See https://www.cs.cmu.edu/~kmcrane/Projects/MonteCarloGeometryProcessing/
// Random numbers using code at
// https://stackoverflow.com/a/17479300
// A single iteration of Bob Jenkins' One-At-A-Time hashing algorithm.
uint hash( uint x ) {
x += ( x << 10u );
x ^= ( x >> 6u );
x += ( x << 3u );
@dpiponi
dpiponi / pearcey.py
Created September 12, 2016 00:30
Pearcey integral
View pearcey.py
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import scipy.integrate as integrate
# Dimension of image in pixels
N = 256
# Number of samples to use for integration
M = 33
@dpiponi
dpiponi / runner.py
Created August 27, 2020 15:34
Are these runners?
View runner.py
# Python 3
import collections
Write = collections.namedtuple("Write", ["written"])
def hello_world():
yield Write("Hello, world!")
yield Write("Hello, world!")
return 1
def identity(gen):
@dpiponi
dpiponi / branch.py
Created March 27, 2021 23:58
Branched flow with taichi
View branch.py
import math
import numpy as np
import random
import matplotlib.pyplot as plt
medium_size = 1024
x = np.linspace(-1., 1., medium_size)
y = np.linspace(-1., 1., medium_size)
x, y = np.meshgrid(x, y, indexing='ij')
View init.m
(** User Mathematica initialization file **)
(** See https://reference.wolfram.com/language/tutorial/ConfigurationFiles.html for info on instaling this file **)
(** Display graphics inline in iTerm2. I don't know an easy way to test if we're running in iTerm2 without looking at the process table. **)
imgcat[image_Graphics]:=(
WriteString[$Output, "\033]1337;File=inline=1:"<>ExportString[ExportString[image,"PNG"],"Base64"]<>"\007"];
Null
)
View coupling.c
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
int bernoulli(float p, float r)
{
return r > 1 - p;
}
@dpiponi
dpiponi / example.cpp
Last active March 15, 2021 00:31
Near minimal example of replacing explicit state machine with coroutine. (Compare Example1 class with Example2, not the supporting "library" code.)
View example.cpp
// Some platforms import from experimental/coroutine
// rather than coroutine.
#define REQUIRES_EXPERIMENTAL 1
// Controls whether the coroutine starts in a suspended state
// or runs to the first suspension point on construction.
// The two implementations should match.
#ifndef INITIAL_RUN
#define INITIAL_RUN 1
#endif