2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
#ifndef igs_math_random_h
|
|
|
|
#define igs_math_random_h
|
|
|
|
|
|
|
|
/*
|
|
|
|
履歴
|
|
|
|
2001-04-25 update
|
|
|
|
2001-06-19 rename to 'calculator_random_plus_long.h'
|
|
|
|
2005-02-03 rename to 'ptbl_random.h'
|
Fix various typos + translate some comments to EN
Found via `codespell -q 3 -S *.ts,thirdparty,./toonz/sources/common/twain -L appy,ba,chunck,datas,forse,inbetween,inly,inout,pevent,possibile,strack,upto,vertexes`
Follow-up to PR #4156
Closes #4072
Revert hidden unicode commit made by git client
2022-01-12 03:42:33 +13:00
|
|
|
2005-02-10 separate to 'ptbl_random.h' and 'ptbl_random.cxx'
|
2016-03-19 06:57:51 +13:00
|
|
|
解説 (2005-02-03.thu wrote)
|
|
|
|
疑似乱数整数列発生関数rand()は処理系定義であるため、
|
|
|
|
たとえば、radhat9とWindowsとでは疑似乱数列が違う。
|
|
|
|
また、random()関数は、radhat9にはあるが、MS-Cにはない。
|
|
|
|
よって、ポータビリティを持たせるため独立した関数定義をする
|
|
|
|
参考:「ANSI C/C++辞典」 平林雅英 共立出版株式会社
|
|
|
|
*/
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
namespace igs {
|
|
|
|
namespace math {
|
|
|
|
class random {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
random();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/* 乱数種 seed(0〜std::numeric_limits<long>::max()) */
|
|
|
|
void seed(unsigned long seed);
|
|
|
|
unsigned long seed(void) const;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/* 乱数生成 0〜std::numeric_limits<long>::max() */
|
|
|
|
long next(void);
|
|
|
|
double next_d(void); /* 0 ... 1 */
|
2016-03-19 06:57:51 +13:00
|
|
|
private:
|
2016-06-15 18:43:10 +12:00
|
|
|
unsigned long seed_;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* !igs_math_random_h */
|