Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mskashi's full-sized avatar

Masahide Kashiwagi mskashi

View GitHub Profile
@mskashi
mskashi / gopositions.nim
Created February 22, 2022 23:51
count number of possible positions after three moves in the game of go
import std/sequtils
import std/strutils
import std/tables
type board = array[1..19, array[1..19, char]]
var table = initTable[string, int]()
var count:int = 0
proc print(a:board) =
# calculate coefficients of Newton-Cotes integral formula
# for \int_a^b f(x)dx
# using sampling points x0(=a), x1, ..., xn-1, xn(=b)
import sympy as sym
n = 7;
x = sym.Symbol('x');
a = sym.Symbol('a');
#include <stdio.h>
#include <float.h>
#include <stdint.h>
#include <inttypes.h>
int64_t d2i(double x)
{
union {
int64_t i;
double d;
@mskashi
mskashi / check-rounding.cc
Last active March 1, 2016 12:35
Visual C++でのfesetroundの動作チェック
#include <iostream>
#include <cfenv>
#include <cmath>
int check_rounding()
{
volatile double x, y, z;
x = 1;
y = pow(2., -55);
#include <kv/kraw-approx.hpp>
#include <kv/defint.hpp>
namespace ub = boost::numeric::ublas;
typedef kv::interval<double> itv;
struct Func {
template <class T> ub::vector<T> operator() (const ub::vector<T>& x) {
static T p = kv::constants<T>::pi();