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.1 | |
import sys; | |
import functools; | |
import operator; | |
import fractions; | |
def readAdjlist(file): | |
adjlist = [] | |
with open(file) as f: |
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 Data.List | |
import System | |
-- Encode a character range as regex. | |
bs :: Char -> Char -> String | |
bs '0' '9' = "\\d" | |
bs 'A' y = bs '1' y | |
bs x y | y == x = [x] | |
| y == succ x = ['[', x, y, ']'] | |
| True = ['[', x, '-', y, ']'] |
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 <cmath> | |
// Get gsl.hpp from http://code.google.com/p/igraphhpp/source/browse/trunk/gsl. | |
#include <gsl/gsl.hpp> | |
#include <ctime> | |
#include <algorithm> | |
#include <cstdio> | |
#include <tr1/unordered_map> | |
static const int N = 50; | |
static const int T = 150; |
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
/* | |
ising.cpp ... Ising Model | |
Copyright (C) 2010 KennyTM~ <[email protected]> | |
This program is free software: you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation, either version 3 of the License, or | |
(at your option) any later version. |
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
/* | |
vmc.cpp ... Variational Monte Carlo. | |
Copyright (C) 2010 KennyTM~ <[email protected]> | |
This program is free software: you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation, either version 3 of the License, or | |
(at your option) any later version. |
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.1 | |
# | |
# multicoin.py ... Quantum walk with multiple biased coins | |
# | |
# Copyright (C) 2010 KennyTM~ | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. |
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.1 | |
import timeit | |
from itertools import chain | |
def magic(f): return f | |
def more_magic(f): return f | |
@magic | |
def double_digits_holger8(x): |
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 python2.7 | |
# | |
# parrondo_optimizer.py ... Parrondo's paradox which optimizes the sequence. | |
# Copyright (C) 2010 KennyTM~ <[email protected]> | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# |
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.1 | |
# | |
# x.py ... Classical Parrondo paradox. | |
# | |
# Copyright (C) 2010 KennyTM~ | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. |
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 std.traits, std.typetuple; | |
template GeneralizeType(T) { | |
static if (is(T == class)) | |
alias Object GeneralizeType; | |
//@@@BUG@@@ Should preserve qualifier of T. | |
else | |
alias T GeneralizeType; | |
} | |
mixin template ImplementMultipleDispatch(alias method, alias Parent = __traits(parent, method)) { | |
private enum methodName = __traits(identifier, method); |
OlderNewer