Skip to content

Instantly share code, notes, and snippets.

/*
* this code is refered from Figure 1 of CUDA COMPILER DRIVER NVCC
* Reference Guide (TRM-06721-001_V5.5).
*
* CUDA COMPILER DRIVER NVCC Reference Guide
* http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html
*/
const int ACOS_TESTS = 5;
const int ACOS_THREAD_CNT = 128;
@U-MA
U-MA / near.java
Last active August 29, 2015 14:03
ArrayList<Sensor> nearest_neighbor(ArrayList<Sensor> field, User u)
{
double a = 28.29;
// 構築された経路
ArrayList<Sensor> route = new ArrayList<Sensor>();
// 次のノードの候補
ArrayList<Sensor> R = new ArrayList<Sensor>();
import java.awt.geom.Arc2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Random;
// 普通のセンサクラス
class SensorBase {
private Point2D.Double position;
private double battery;
#include <stdio.h>
#include <stdlib.h>
// read the array a of n elements from fp
void reada(FILE *fp, int *a, int *n);
// output the array a of n elements
void printa(int *a, int n);
// randomized quick sort
@U-MA
U-MA / hpc2014_answer.cpp
Created November 11, 2014 14:09
ハル研プロコンの回答プログラム
//------------------------------------------------------------------------------
/// @file
/// @brief HPCAnswer.hpp の実装 (解答記述用ファイル)
/// @author ハル研究所プログラミングコンテスト実行委員会
///
/// @copyright Copyright (c) 2014 HAL Laboratory, Inc.
/// @attention このファイルの利用は、同梱のREADMEにある
/// 利用条件に従ってください
//------------------------------------------------------------------------------
@U-MA
U-MA / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@U-MA
U-MA / now_loading.vim
Created May 17, 2015 08:47
文字列"Now loading..."がアニメーションする
" Now loadingというアニメーションする文字列を表示する
" Version: 0.8
" Author: U-MA
" License: VIM LICENSE
" USAGE:
" Command: :NowLoading
"
" Please press 'q' for stop to this program.
@U-MA
U-MA / accum_sum
Created June 26, 2015 11:48
行列の和
/* 行列の対応する要素をaccumulateする
*
* このプログラムはいたるところにバグが潜んでいる、もしくは
* バグを起こしやすいので注意
*/
#include <cstdio>
// 要素数がsize個の行列をmatrix_size個格納した配列matrixを
function! s:foo(second) abort
let l:start = reltime()
while str2float(reltimestr(reltime(l:start))) < float(a:second)
execute 'normal! r '
endwhile
endfunction
tabnew Sample
call setline(1, 'Please any keys for 2 seconds.')
@U-MA
U-MA / count_if.vim
Created September 5, 2015 12:31
条件に一致する要素の個数を返す関数
function! s:count_if(list, string) abort
let copy = deepcopy(a:list)
call filter(copy, a:string)
return len(copy)
endfunction