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