Skip to content

Instantly share code, notes, and snippets.

@krackers
krackers / plot-gp.py
Created February 9, 2018 02:22 — forked from neubig/plot-gp.py
A simple program to sample functions from a Gaussian process and plot them
#!/usr/bin/python
from math import exp
import numpy as np
import matplotlib.pyplot as plt
def rbf_kernel(x1, x2, variance = 1):
return exp(-1 * ((x1-x2) ** 2) / (2*variance))
def gram_matrix(xs):
@krackers
krackers / splay.cpp
Created September 14, 2017 06:41 — forked from msg555/splay.cpp
Optimized splay tree implementation
template<class T> struct splnode {
typedef splnode<T> node_t;
splnode() : P(NULL) {
C[0] = C[1] = NULL;
pull();
}
/* Add extra state here. */
@krackers
krackers / geo.cpp
Created September 14, 2017 06:41 — forked from msg555/geo.cpp
Mark's geometry routines
#include <algorithm>
#include <vector>
#include <complex>
#include <cmath>
using namespace std;
/* A flag used by some geometry routines to indicate exceptional circumstances.
*/
static bool geoerror;
@krackers
krackers / suffix.cpp
Created September 14, 2017 06:39 — forked from msg555/suffix.cpp
Suffix Array Implementation
struct suffix_array {
suffix_array(const char* S) : N(strlen(S)) {
vector<int> V;
for(int i = 0; i < N; i++) V.push_back(S[i]);
init(V);
}
suffix_array(const vector<int>& VV) : N(VV.size()) {
vector<int> V(VV);
init(V);
@krackers
krackers / range2D.cpp
Created September 14, 2017 06:39 — forked from msg555/range2D.cpp
2D Range Tree Query Example
/*
LANG: C++
*/
#include <iostream>
#include <cstdio>
using namespace std;
#define MAXN 512
@krackers
krackers / 3dhull.cpp
Created September 14, 2017 06:39 — forked from msg555/3dhull.cpp
3D Convex Hull
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cassert>
using namespace std;