⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 random.cpp

📁 A C++ class library for scientific computing
💻 CPP
字号:
/***************************************************************************** * random.cpp        Blitz++ random numbers example */#include <random/uniform.h>#include <blitz/numinquire.h>#include <time.h>#include <iostream>#include <iomanip>using namespace ranlib;using namespace blitz;// workaround for broken streams in Compaq cxx, can't handle long double#if defined(__DECCXX)#define LD_HACK(x) static_cast<double>(x)#else#define LD_HACK(x) x#endiftemplate<typename T>void printRandoms(){  Uniform<T> x;  //x.seed((unsigned int)time(0));  x.seed(5);  int N=5;  for (int i = 0; i < N; ++i)     cout << setprecision(digits10(T())) << LD_HACK(x.random()) << endl;  cout << endl;}int main(){// test get/set state interface  Uniform<double> x;  Uniform<double>::T_state S = x.getState();  x.setState(S);  std::string str = x.getStateString();  x.setState(str);  cout << "Some random float: " << endl;  printRandoms<float>();  cout << "Some random doubles: " << endl;  printRandoms<double>();  cout << "Some random long doubles: " << endl;  printRandoms<long double>();  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -