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 <stdio.h> | |
#include <cblas.h> | |
double m[] = { | |
3, 1, 3, | |
1, 5, 9, | |
2, 6, 5 | |
}; | |
double 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
/* | |
* y += A*x | |
* | |
* Matrix-Vector multiplication optimization experiment | |
* TODO: Benchmark against the following: | |
* eigen2: ourselves, with the default options (SSE2 vectorization enabled). | |
* eigen2_novec: ourselves but with Eigen's explicit vectorization disabled. However, gcc's auto-vectorization was enabled. | |
* INTEL_MKL: The Intel Math Kernel Library, which includes a BLAS/LAPACK (11.0). Closed-source. | |
* ACML: The AMD's core math library, which includes a BLAS/LAPACK (4.2.0). Closed-source. |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <malloc.h> | |
#include <time.h> | |
#include <gmp.h> | |
long int NAIVE = 30; | |
typedef unsigned long int ulong; |
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
.section .data | |
output: | |
.ascii "The processor Vendor ID is: " | |
vendor_id: | |
.ascii "xxxxYYYYzzzz\n" | |
.section .bss | |
.section .text |
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
def permute(l) : | |
if len(l) == 1 : | |
yield l | |
else : | |
for i in range(len(l)) : | |
for j in permute(l[:i] + l[i + 1:]) : | |
yield [l[i]] + j | |
def combinations(l, r) : | |
if r == 1 : |
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 python | |
import timeit | |
graph = {'A': ['B', 'C'], | |
'B': ['C', 'D'], | |
'C': ['D'], | |
'D': ['C'], | |
'E': ['F'], | |
'F': ['C']} |
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 python | |
def partitions(n, curtot = 0, cur = []) : | |
if curtot == n : | |
yield cur | |
t = cur[-1] if cur else 1 | |
for i in xrange(t, n - curtot + 1) : |
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
#1. The input is a list of rings. Each ring is a list of letters. | |
#2. Once you choose a letter from ring k then you can only choose letters from | |
# ring k, k + 1, ... Outermost ring is ring 0. And ring depth increases inwards. | |
#3. points[k] is the points for getting the letter chr(k + ord('A')) | |
from bisect import bisect, bisect_left | |
from time import time | |
try: | |
import psyco |
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
#Quine1 | |
e=r'''print "e=r''"+"'"+e+"''"+"'\n"+e''' | |
print "e=r''"+"'"+e+"''"+"'\n"+e | |
#Quine2 | |
x='%s=%s;print x%%("x",chr(39)+x+chr(39))';print x%("x",chr(39)+x+chr(39)) | |
#Quine3 | |
y="%" | |
z='y="%s"\nz=%s\nprint z%s(y,repr(z),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
import bisect | |
import timeit | |
#Finds the Nth golumb number from the | |
#sequence x(n) using a binary search | |
def findNthGolumb(n, x, upto) : | |
pos = bisect.bisect(x, n, 1, upto) | |
return pos - 1 | |
#Creates the sequence x(n) where x(n) is k |