SourceForge.jp

ネームスペース dkutil::oldmath


構成

class  dKingyoRandom_ANSI
class  dKingyoRandom_ANSI_NO_SETUP
 C言語のrandと同じ乱数を発生されるクラス. [詳細]

class  dKingyoRandom_Float
class  dKingyoRandom_Float_NO_SETUP
 浮動小数点(float)で乱数を発生させるクラス [詳細]

class  dKingyoRandom_MT
class  dKingyoRandom_MT_NO_SETUP
 MT法乱数で乱数を発生させるクラス. [詳細]

class  dKingyoRandom_MT_SSE2
class  INL_dKingyoRandom_MT
 インライン化しているので早いMT法乱数 [詳細]

class  INL_dKingyoRandom_MT_SSE2

型定義

typedef dKingyoRandom_MT_SSE2<
ULONG, ULONG_MAX > 
dKingyoRandom_MT_SSE2_NO_SETUP

関数

template<typename SEED> int arg_rand (SEED *seed)
int arg_random (ULONG *seed, ULONG Max)
void srandMT (unsigned long seed)
unsigned long CheckMMX (void)
void MMX_generateMT (void)
void generateMT (void)
unsigned long randMT (void)
int CreateArthimeticProgression (int *array, DWORD num, int a, int d)
int CreateGeometricProgression (int *array, DWORD num, int a, int r)
int CreateRandomNumberProgression (int *array, DWORD num, int min, int max, int(*rand_func_callback)(int min_, int max_))
DINLINE short GetAngle (int mx, int my, int sx, int sy)
 二つの2次元座標から角度を求める。 ちなみに256度とかUSHORT_MAX度とかは算出できないと思います。

double kai2 (double o1, double o2, double e1, double e2)
 カイ二乗検定らしい

float kai2 (float o1, float o2, float e1, float e2)
ULONGLONG GetRDTSC ()
DINLINE float sin (float f)
DINLINE float cos (float f)
DINLINE float asin (float f)
DINLINE float acos (float f)
DINLINE float sqrtf (float f)


型定義

typedef dKingyoRandom_MT_SSE2<ULONG,ULONG_MAX> dkutil::oldmath::dKingyoRandom_MT_SSE2_NO_SETUP
 


関数

DINLINE float acos float  f  ) 
 

覚え書き:
出典:二反田 雅彦 氏のKittyエンジンより
acos - テイラー展開した近似式によるアークコサイン値を返す ※誤差が大きいので、使用をお勧めできない

引数: float f コサイン値

戻り値: float 角度(ラジアン)

引数:
f cosine number
戻り値:
angle of radian
覚え書き:
テイラー展開した、cos-1級数
cos-1(x) ≒ (1 / 2)π - x - (1 / 6) * x^3
  • ( 3 / 40) * x^5 - (5 / 112) * x^7
  • (35 / 1152) * x^9

template<typename SEED>
int arg_rand SEED *  seed  )  [inline]
 

int arg_random ULONG *  seed,
ULONG  Max
[inline]
 

DINLINE float asin float  f  ) 
 

覚え書き:
出典:二反田 雅彦 氏のKittyエンジンより
asin - テイラー展開した近似式によるアークサイン値を返す ※誤差が大きいので、使用をお勧めできない

引数: float f サイン値

戻り値: float 角度(ラジアン)

引数:
f sine number
戻り値:
angle of radian
覚え書き:
テイラー展開した、sin-1級数
sin-1(x) ≒ x + (1 / 6) * x^3 + ( 3 / 40) * x^5
+ (5 / 112) * x^7 + (35 / 1152) * x^9

unsigned long dkutil::oldmath::CheckMMX void   ) 
 

DINLINE float cos float  f  ) 
 

覚え書き:
出典:二反田 雅彦 氏のKittyエンジンより
cos - テイラー展開した近似式によるコサイン値を返す

引数: float f 角度(ラジアン)

戻り値: float コサイン値

引数:
f angle of radian
戻り値:
cosine number

int dkutil::oldmath::CreateArthimeticProgression int *  array,
DWORD  num,
int  a,
int  d
 

等差数列
A Arithimetic Series

引数:
array [out] = 配列のポインタを代入
num [in] = 配列の数
a [in] = 初項
d [in] = 公差
戻り値:
最後の配列の中身

int dkutil::oldmath::CreateGeometricProgression int *  array,
DWORD  num,
int  a,
int  r
 

等比数列
A Geometric Series
実装してから思った…テンプレートにすれば良かった(爆)
調和数列も似たようなものだから削除。どうせ使わない。数列関連ってお遊び関数だし…

引数:
array [out] = 配列のポインタを代入
num [in] = 配列の数
a [in] = 初項
r [in] = 公比
戻り値:
最後の配列の中身

int dkutil::oldmath::CreateRandomNumberProgression int *  array,
DWORD  num,
int  min,
int  max,
int(*  rand_func_callback)(int min_, int max_)
 

乱数列 A Random Number Series
どうせ誰も使わないと思うが乱数列を作成補助するやつ
引数の左はmin右がmax…ってかmin<=x<=maxまでを返す関数のポインタをぶち込む。

引数:
array [out] = 配列のポインタを代入
num [in] = 配列の数
min [in] = 乱数の最小値
max [in] = 乱数の最大値
rand_func_callback[in] = ランダム変域を返す関数。
戻り値:
最後の配列の中身

void dkutil::oldmath::generateMT void   ) 
 

short dkutil::oldmath::GetAngle int  mx,
int  my,
int  sx,
int  sy
 

二つの2次元座標から角度を求める。 ちなみに256度とかUSHORT_MAX度とかは算出できないと思います。

ULONGLONG dkutil::oldmath::GetRDTSC  ) 
 

float dkutil::oldmath::kai2 float  o1,
float  o2,
float  e1,
float  e2
[inline]
 

double dkutil::oldmath::kai2 double  o1,
double  o2,
double  e1,
double  e2
[inline]
 

カイ二乗検定らしい

参考文章

カイ二乗分布のパーセント点を求める。 χ2 =  (Oy−Ey)2/Ey+(Og−Eg)2/Eg. χ2 =  Σ(Oi−Ei)2/Ei 危険率を1%に下げるにはカイ二乗の値が6.63以上かを調べればよい。

d金魚曰、 まだ、実験段階中なので使わないでください〜〜〜

void MMX_generateMT void   ) 
 

unsigned long dkutil::oldmath::randMT void   ) 
 

DINLINE float sin float  f  ) 
 

覚え書き:
出典:二反田 雅彦 氏のKittyエンジンより
sin - テイラー展開した近似式によるサイン値を返す

引数: float f 角度(ラジアン)

戻り値: float サイン値

引数:
angle of radian
戻り値:
sine number
覚え書き:
テイラー展開した、sin級数 sin(x) ≒ x - (1 / 6) * x^3 + (1 / 120) * x^5
  • (1 / 5040) * x^7 + (1 / 362880) * x^9
この近似式の有効な範囲は、-π <= r <= πであるため、 値の調整を行う

DINLINE float sqrtf float  f  ) 
 

覚え書き:
出典:二反田 雅彦 氏のKittyエンジンより
sqrtf - float型の平方根を求める ※sqrtのfloatバージョン ボーランドのコンパイラには、ないようなので自分で作成

 引数:   f 平方根を求める値、負の値はダメよん

 戻り値:   平方根、fが負だった場合は-1を返す

引数:
f 平方根を求める値、負の値はNG
戻り値:
平方根 fが負だった場合は-1を返す
覚え書き:
実数の平方根s = √xは、f(s) = s^2 - x = 0をNewton法で解い て求める。
f(s) = s^2 - x f'(s) = 2s を

xn+1 = xn - f(xn) / f'(xn)

に代入して、 xn+1 = (x / s + s) / 2

Newton法について、詳しくは数学の本でも読んでね♪

void dkutil::oldmath::srandMT unsigned long  seed  ) 
 


dkutil 1.02リリース前 d金魚専用マニュアルバージョンに対してSun Dec 28 21:23:15 2003に生成されました。 doxygen 1.3.5