PhotosDebugRandom.cxx
1#include <iostream>
2#include "PhotosDebugRandom.h"
3#include "Log.h"
4using std::ios_base;
5
6namespace Photospp
7{
8
9int PhotosDebugRandom::i97_saved = 0;
10int PhotosDebugRandom::j97_saved = 0;
11double PhotosDebugRandom::uran_saved[97] = { 0 };
12double PhotosDebugRandom::cran_saved = 0;
13
14void PhotosDebugRandom::saveState()
15{
16 i97_saved=i97;
17 j97_saved=j97;
18 cran_saved=cran;
19
20 for(int i=0;i<97;i++) uran_saved[i]=uran[i];
21}
22
23void PhotosDebugRandom::restoreState()
24{
25 i97=i97_saved;
26 j97=j97_saved;
27 cran=cran_saved;
28
29 for(int i=0;i<97;i++) uran[i]=uran_saved[i];
30}
31
32void PhotosDebugRandom::setState(int i, int j, double c, double list[97])
33{
34 i97=i;
35 j97=j;
36 cran=c;
37 for(int i=0;i<97;i++) uran[i]=list[i];
38}
39
40void PhotosDebugRandom::setSaveState(int i, int j, double c, double list[97])
41{
42 i97_saved=i;
43 j97_saved=j;
44 cran_saved=c;
45 for(int i=0;i<97;i++) uran_saved[i]=list[i];
46}
47
48void PhotosDebugRandom::print()
49{
50 int coutPrec = cout.precision(18);
51 ios_base::fmtflags flags = cout.setf(ios_base::scientific, ios_base::floatfield);
52
53 Log::RedirectOutput(Log::Info());
54
55 cout<<"double uran_state[97] = { ";
56 for(int i=0;i<96;i++) cout<<uran[i]<<", ";
57 cout<<uran[96]<<" };"<<endl<<endl;
58 cout<<"PhotosDebugRandom::setState( "<<i97<<", "<<j97<<", "<<cran<<", uran_state );"<<endl;
59
61
62 // Revert output stream flags and precision
63 cout.precision(coutPrec);
64 cout.flags (flags);
65}
66
67} // namespace Photospp
static void RevertOutput()
static void RedirectOutput(void(*func)(), ostream &where=*out)
Definition Log.cxx:93