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 pyopencl as cl | |
from pyopencl import array as clarray | |
from pyopencl import clmath | |
from pyopencl import clrandom | |
import numpy | |
from time import time | |
def timeit(f, args): | |
n = 100 | |
t = 0 |
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
# coding: utf-8 | |
# vim: filetype=pyopencl.python | |
from __future__ import print_function | |
import numpy as np | |
import pyopencl as cl | |
from pyopencl import array as clarray | |
from pyopencl.scan import ExclusiveScanKernel | |
src = '''//CL// |
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 | |
# -*- coding: utf-8 -*- | |
# vim: filetype=pyopencl.python | |
import sys | |
import time | |
from PyQt4 import QtCore | |
from PyQt4 import QtGui | |
import pyopencl as cl | |
import numpy |
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 | |
# coding: utf-8 | |
from __future__ import print_function | |
from __future__ import division | |
class Board(object): | |
def __init__(self, W, H): | |
assert W * H % 4 == 0 |
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
type item = {w:int; p:int} | |
(* 2004, Kellerer et al., Knapsack Problems, p.23 *) | |
let dp2 items c = | |
let n = Array.length items in | |
let z = Array.make (c + 1) 0 in | |
for j = 0 to n - 1 do | |
let {w=wj; p=pj} = items.(j) in | |
for d = c downto wj do | |
let o = z.(d - wj) + pj in |
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
# vim: filetype=pyopencl.python | |
import numpy as np | |
from PIL import Image | |
import pyopencl as cl | |
from pyopencl import array as clarray | |
SRC = '''//CL// | |
__constant const int CHECKER_SIZE = 10; | |
float2 polar(const int2); |
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 | |
# -*- coding: utf-8 -*- | |
# vim: filetype=pyopencl.python | |
from __future__ import division | |
import sys | |
import math | |
import random | |
import itertools |
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
# coding: utf-8 | |
def dfs(i, w, c, x): | |
if i == len(w): | |
return True | |
wi = w[i] | |
for j in range(len(c)): | |
if wi > c[j]: | |
continue |
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
fn dp (p : &[int], w : &[int], c : int) -> int { | |
let mut z = std::vec::from_elem((c + 1) as uint, 0); | |
for p.iter().zip(w.iter()).advance |(pj, wj)| { | |
for std::uint::range_rev(c as uint, (*wj - 1) as uint) |k| { | |
z[k] = match z[k - *wj as uint] + *pj { | |
v if v > z[k] => v, | |
_ => z[k] | |
} | |
} | |
} |
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
<html> | |
<link rel="stylesheet" href="bgstretcher.css" /> | |
<script type="text/javascript" src="jquery-1.6.1.js"></script> | |
<script type="text/javascript" src="bgstretcher.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
var iter = 0; | |
var images = ['images/白い画像.jpg', 'images/sample-2.jpg']; |
OlderNewer