PhotosDebugRandom.cxx
00001 #include <iostream>
00002 #include "PhotosDebugRandom.h"
00003 #include "Log.h"
00004 using std::ios_base;
00005
00006 namespace Photospp
00007 {
00008
00009 int PhotosDebugRandom::i97_saved = 0;
00010 int PhotosDebugRandom::j97_saved = 0;
00011 double PhotosDebugRandom::uran_saved[97] = { 0 };
00012 double PhotosDebugRandom::cran_saved = 0;
00013
00014 void PhotosDebugRandom::saveState()
00015 {
00016 i97_saved=i97;
00017 j97_saved=j97;
00018 cran_saved=cran;
00019
00020 for(int i=0;i<97;i++) uran_saved[i]=uran[i];
00021 }
00022
00023 void PhotosDebugRandom::restoreState()
00024 {
00025 i97=i97_saved;
00026 j97=j97_saved;
00027 cran=cran_saved;
00028
00029 for(int i=0;i<97;i++) uran[i]=uran_saved[i];
00030 }
00031
00032 void PhotosDebugRandom::setState(int i, int j, double c, double list[97])
00033 {
00034 i97=i;
00035 j97=j;
00036 cran=c;
00037 for(int i=0;i<97;i++) uran[i]=list[i];
00038 }
00039
00040 void PhotosDebugRandom::setSaveState(int i, int j, double c, double list[97])
00041 {
00042 i97_saved=i;
00043 j97_saved=j;
00044 cran_saved=c;
00045 for(int i=0;i<97;i++) uran_saved[i]=list[i];
00046 }
00047
00048 void PhotosDebugRandom::print()
00049 {
00050 int coutPrec = cout.precision(18);
00051 ios_base::fmtflags flags = cout.setf(ios_base::floatfield);
00052
00053 Log::RedirectOutput(Log::Info());
00054
00055 cout<<"double uran_state[97] = { ";
00056 for(int i=0;i<96;i++) cout<<uran[i]<<", ";
00057 cout<<uran[96]<<" };"<<endl<<endl;
00058 cout<<"PhotosDebugRandom::setState( "<<i97<<", "<<j97<<", "<<cran<<", uran_state );"<<endl;
00059
00060 Log::RevertOutput();
00061
00062
00063 cout.precision(coutPrec);
00064 cout.flags (flags);
00065 }
00066
00067 }