Skip to content

Instantly share code, notes, and snippets.

View jg-you's full-sized avatar
🐢

Jean-Gabriel Young jg-you

🐢
View GitHub Profile
@jg-you
jg-you / stateless_derivation_and_template.cpp
Last active January 12, 2018 22:17
How to use stateless class derived from a virtual base class in a templated class. A strategy I use in many code
#include <iostream>
class master_virtual
{
public:
virtual void msg() {return;}
};
class derived_hi : public master_virtual
{
@jg-you
jg-you / orbits.py
Last active January 23, 2023 15:23
Computing the number of orbits in a graph, with dreadnaut (nauty), in python
# -*- coding: utf-8 -*-
"""
Wrapper around dreadnaut that computes the orbits of a graph.
NOTE: Must have installed `dreandaut`. The location of the binary can be passed
as an argument to `compute_automorphisms`.
Author: Jean-Gabriel Young <info@jgyoung.ca>
"""
import subprocess
@jg-you
jg-you / bernstein.stan
Last active October 30, 2018 00:19
Evaluate a Bézier curve in Bernstein form at a point, using De Casteljau's algorithm, in the STAN language
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.