Skip to content

Instantly share code, notes, and snippets.

View adituv's full-sized avatar

Iris Ward adituv

View GitHub Profile
@adituv
adituv / conditions.txt
Last active December 28, 2015 06:49
More comparison data for pendulum.
Please enter the following parameters:
Timestep /s: 0.1
Simulation length /timesteps: 100
Pendulum length /m: 1
Pendulum mass /kg: 0.25
Gravitational acceleration /m s^-2: 9.81
Damping constant /?: 0
Initial pendulum angle /rad: 1
Initial pendulum angular velocity /rad s^-1: -0.8
@adituv
adituv / approx.dat
Created November 14, 2013 01:50
Pendulum results with and without sin(x) ~ x. Initial conditions: timestep = 0.1s pendulum length = 1m pendulum mass = 0.25kg gravitational acceleration = 9.81 damping = 0.5 initial angle = 1 initial angular velocity: -0.8
# Assumed that sin(x) ~ x
0.837900
0.626022
0.395107
0.171615
-0.024014
-0.178162
-0.284002
-0.340814
-0.352829
@adituv
adituv / point_of_no_return.sound
Last active December 26, 2015 15:38
Very simple converter from list of frequencies and durations to output sound wave on stdout. Pipe it through e.g. /dev/audio or aplay to actually create sound.
1.25@130.8127827
0.25@174.6141157
0.25@164.8137785
0.25@174.6141157
0.75@195.9977180
0.25@207.6523488
1.00@195.9977180
1.25@0
0.25@174.6141157
0.25@195.9977180
@adituv
adituv / dotprod.c
Last active December 20, 2015 04:58
OpenCL pseudocode to demonstrate the usual pattern of calling OpenCL
//The code that runs on the graphics card is included in the program here as a plaintext string
//It's also possible to include it as a binary, but I don't know how to do that.
const char* source=
"__kernel \n"
"void sum(__global float* source, __global float* dest, uint n) \n"
" int idx = get_global_id(0); \n"
" int iter = 2; \n"
" \n"
" while(iter < n && idx % iter == 0) { \n"
" dest[min(iter*idx,n)] = source[min(iter*idx,n)] + source[(iter-1)*idx]; \n"
@adituv
adituv / Khinchin.py
Last active December 20, 2015 03:49
A demonstration of Khinchin's constant for the continued fraction expansion of the number pi. Obviously as python has finite precision floating point, this is only an approximation, and is likely to approach an incorrect result as a grows larger.
#!/usr/bin/python3
from math import floor
from math import pi
def getExpansion(y):
x = y
while True:
z = floor(x)
yield z