added restart capability to RanMars

This commit is contained in:
Axel Kohlmeyer
2020-08-09 14:56:00 -04:00
parent 897ae681d3
commit 383bb7f905
2 changed files with 30 additions and 0 deletions

View File

@ -287,3 +287,31 @@ void RanMars::select_subset(bigint ntarget, int nmine, int *mark, int *next)
// niter,nmark,nactiveall,thresh,nflipall);
}
}
/* ----------------------------------------------------------------------
store state in buffer
------------------------------------------------------------------------- */
void RanMars::get_state(double *state)
{
for (int i=0; i < 98; ++i) state[i] = u[i];
state[98] = i97;
state[99] = j97;
state[100]= c;
state[101]= cd;
state[102]= cm;
}
/* ----------------------------------------------------------------------
restore state from buffer
------------------------------------------------------------------------- */
void RanMars::set_state(double *state)
{
for (int i=0; i < 98; ++i) u[i] = state[i];
i97 = state[98];
j97 = state[99];
c = state[100];
cd = state[101];
cm = state[102];
}