Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# threading base code
# http://techno-st.net/2010/02/06/python-3.html
'''
スタープラチナ Vs. ザ・ワールド
Version 1.0.0
'''
import sys
@poochin
poochin / gist:1423262
Created December 2, 2011 13:35
sl コマンドに京急AAを追加するパッチです
diff -c sl/sl.c sl_kq/sl.c
*** sl/sl.c 1998-07-22 23:01:01.000000000 +0900
--- sl_kq/sl.c 2011-12-02 21:34:09.540165908 +0900
***************
*** 33,73 ****
#include "sl.h"
int ACCIDENT = 0;
int LOGO = 0;
int FLY = 0;
@poochin
poochin / nsinf.py
Created November 14, 2011 09:00
名前空間推測
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from inspect import currentframe
import re
class At:
'''Namespace inference class
#!/usr/bin/python
# -*- coding: utf-8 -*-
u'''
連立方程式の解法
テスト用の式
2*x1 + 3*x2 + x3 = 4
4*x1 + x2 - 3*x3 = -2
-x1 + 2*x2 + 2*x3 = 2
'''
#!/usr/bin/python
# -*- coding: utf-8 -*-
# マチンの公式
# π /4 = 4arctan(1/5) - arctan(1/239)
# π = (16/5 - 16/(3*5^3) + 16/(5*5^5) - ...) - (4/239 - 4/(3*239^3) + ...)
# = (16/5 - 4/239) - (16/(3*5^3) - 4/(3*239^3)) + ...
# w[0] = 16/5, w[1] = w0/(3*5^3), w[2] = w1/(5*5^5), ...
# v[0] = 4/239, v[1] = v0/(3*239^3), v[2] = v1/(5*239^5), ...
# m[n] = ± (w[n-1]/(2n-1)(5^2) - v[n-1]/(2n-1)(239^2))
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
任意精度整数
加減
演算子オーバーロードから受けた左辺と右辺の正負と大小
から、演算結果の正負を予測し addition や subtraction
に割り振る
乗算
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
補間(Interpolation)
・ラグランジュ補間
・ニュートン補間
通る点
(0, 0.8), (1, 3.1), (3, 4.5), (6, 3.9), (7, 2.8)
'''
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
非線形方程式の根を求める
再帰的に近似を求め関数の根を求める
根を求める関数
f(x) = x^3 - x + 1
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
e^x, e^-x, cos x をテイラー展開を用いて計算する。
'''
import math
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
・ 台形公式(Trapezoidal rule)
・ シンプソンの公式(Simpson's rule)
'''
import math