This file contains hidden or 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 <string.h> | |
#include <cstdlib> | |
bool get_memavailable_from_meminfo(size_t &memavailable) | |
{ | |
const int LINE_LEN = 512; | |
char str[LINE_LEN]; | |
FILE *fp = fopen("/proc/meminfo","rt"); | |
if (fp == NULL) { |
This file contains hidden or 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
# http://codeforces.com/contest/769/problem/D | |
import time | |
import numpy as np | |
import pyopencl as cl | |
runs_number = 50 | |
n, k = [int(x) for x in input("n k: ").split()] | |
values = input("Values (or empty line for random values): ") | |
if len(values) == 0: | |
np.random.seed(239) |
This file contains hidden or 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
__device__ float atomicCAS_f32(float *p, float cmp, float val) { | |
return __int_as_float(atomicCAS((int *) p, __float_as_int(cmp), __float_as_int(val))); | |
} |
This file contains hidden or 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
# Example: | |
# depth_blur.py im3.png im4.png -16 32 | |
# where im3.png and im4.png: | |
# http://vision.middlebury.edu/stereo/eval/newEval/tsukuba/im3.png | |
# http://vision.middlebury.edu/stereo/eval/newEval/tsukuba/im4.png | |
# Usage: | |
# move mouse over image to change depth of focus | |
# | |
# Requires pyopencl and OpenCV builded with Python support |
This file contains hidden or 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
#pragma once | |
#include <cstddef> | |
#include <stdexcept> | |
#include <emmintrin.h> | |
#ifndef _MSC_VER | |
#include <mm_malloc.h> | |
#endif |
This file contains hidden or 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
// See https://streamhpc.com/blog/2016-02-09/atomic-operations-for-floats-in-opencl-improved/ | |
static float atomic_cmpxchg_f32(volatile __global float *p, float cmp, float val) { | |
union { | |
unsigned int u32; | |
float f32; | |
} cmp_union, val_union, old_union; | |
cmp_union.f32 = cmp; | |
val_union.f32 = val; |
This file contains hidden or 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 collections | |
import numpy as np | |
from matplotlib import pyplot as plt | |
from matplotlib import cm | |
from mpl_toolkits.mplot3d import Axes3D | |
def makeGaussian(size, sigma=None): | |
if not isinstance(size, collections.Iterable): | |
size = (size, size) | |
w, h = size |
This file contains hidden or 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> | |
#include <boost/multiprecision/cpp_int.hpp> | |
typedef boost::multiprecision::cpp_int bigint; | |
typedef boost::rational<bigint> rational; | |
/* | |
Online running: https://ideone.com/zTH8pK | |
This is example of absolutely accurate rational arithmetics with boost. |
This file contains hidden or 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
# | |
# Copyright (c) 2016, Nikolay Polyarnyi | |
# All rights reserved. | |
# | |
# Requirements: | |
# | |
# beautifulsoup4>=4.4.1 | |
# requests>=2.9.1 | |
import json |
This file contains hidden or 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 Control.Monad.Free | |
import Control.Monad | |
import System.Exit | |
import Data.Traversable (traverse) | |
data TeletypeF next | |
= Say String next | |
| Ask (String -> next) | |
| Stop |