This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test data | |
std::vector< std::vector<int> > jagged_array(3); | |
jagged_array[0] = {0}; | |
jagged_array[1] = {0, 1, 2, 3}; | |
jagged_array[2] = {0, 1, 2}; | |
hvl_t * X = (hvl_t *)malloc(jagged_array.size() * sizeof(hvl_t)) | |
for (unsigned int i = 0; i < jagged_array.size(); ++i) { | |
X[i].len = jagged_array[i].size(); | |
int * ptr = (int *) malloc (X[i].len * sizeof(int)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
# Mean function (no statistics module in python2) | |
mean = lambda l: sum(l)/len(l) | |
# Declare some graph | |
G = nx.erdos_renyi_graph(200,0.1) | |
# Prepare raw results container | |
result = dict() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diri <- function(alpha) { | |
# Sample from the Dirichlet distribution with parameter (vector) alpha | |
k <- length (alpha) | |
Z <- rep(0,k) | |
for(i in 1:k) { | |
Z[i] <- rgamma(n=1,shape=alpha[i], rate =1) | |
S <- sum(Z) | |
P <- Z/S | |
} | |
return(P) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collection = [{1, 2, 3, 4, 5}, | |
{1, 2}, | |
{1, 2, 3, 4, 5, 6}, | |
{3, 4, 8}, | |
{3, 4, 11}, | |
{3}, | |
{3}, | |
{12}, | |
{1, 2, 3, 4, 5, 6}, | |
{1, 2, 3, 4, 7, 9}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Author: Jean-Gabriel Young | |
# Email: jean.gabriel.young@gmail.com | |
# -*- coding: utf-8 -*- | |
import argparse | |
import subprocess | |
import os | |
from PIL import Image | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlibt.pyplot as plt | |
import numpy as np | |
plt.figure(figsize=(5,4)) | |
X, Y = np.meshgrid(np.linspace(0,1), np.linspace(0,1)) | |
plt.pcolormesh(X,Y,graphon_val(X,Y,p,n)) | |
plt.colorbar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The newest version of graph-tool plots directly in a gtk window, by default. | |
# The following allow you to add inline plots in a jupyter-notebook (this was previously trivial). | |
# [The following code must appear in a notebook, obviously] | |
import graph_tool as gt | |
import graph_tool.draw | |
import graph_tool.collection | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class master_virtual | |
{ | |
public: | |
virtual void msg() {return;} | |
}; | |
class derived_hi : public master_virtual | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
functions { | |
/** | |
* Computes the value of a Bernstein polynomial of degree N at point t, | |
* using De Casteljau's algorithm. | |
* | |
* @param t Point in [0, 1] where the the polynomial will be evaluated. | |
* @param beta Vector of the real N + 1 coefficients of the polynomial. | |
* @param N Degree of the polynomial. | |
* | |
* @return Value of the polynomial at point t. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
# @author: Jean-Gabriel Young <jean.gabriel.young@gmail.com> | |
"""Generate TOC for a markdown file.""" | |
import re | |
# Match between 1 and 4 # | |
section = re.compile('^\s*(#){1,4}\s?') | |
strip_url = re.compile('[\W_]+', re.UNICODE) |
OlderNewer