JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetNextSubstream(JNIEnv *env, jobject jrngstream) {
  RngStream rngstream = jrngstream_to_native(env, jrngstream);
  if (!rngstream)
    return;

  RngStream_ResetNextSubstream(rngstream);
}
Beispiel #2
0
SEXP r_reset_next_substream (SEXP sexp_streamCg,SEXP sexp_streamBg,
                             SEXP sexp_streamIg,
                             SEXP sexp_streamAnti,SEXP sexp_streamIncPrec,
                             SEXP sexp_streamName)
{
    SEXP sexp_stream;
    RngStream stream;
    int i;
    const char *name;
    size_t len;

    stream = (RngStream) malloc (sizeof (struct RngStream_InfoState));
    if (stream == NULL) {
        error("r_reset_next_substream: No more memory\n\n");
    }

    for (i=0; i<6; i++) {
        stream->Cg[i] = REAL(sexp_streamCg)[i];
        stream->Bg[i] = REAL(sexp_streamBg)[i];
        stream->Ig[i] = REAL(sexp_streamIg)[i];
    }
    stream->Anti = INTEGER(sexp_streamAnti)[0];
    stream->IncPrec = INTEGER(sexp_streamIncPrec)[0];
    name = CHAR(STRING_ELT(sexp_streamName,0));
    len = strlen(name);
    stream->name = malloc(len+1);
    if (stream->name == NULL) {
        free(stream);
        error("r_set_stream_seed: No more memory\n\n");
    }
    strncpy(stream->name, name, len+1);

    RngStream_ResetNextSubstream (stream);

    PROTECT(sexp_stream = allocVector(REALSXP, 20));

    for (i = 0; i < 6; ++i) {
        REAL(sexp_stream)[i] = (double) stream->Cg[i];
        REAL(sexp_stream)[i+6] = (double) stream->Bg[i];
        REAL(sexp_stream)[i+12] = (double) stream->Ig[i];
    }
    REAL(sexp_stream)[18] = (int) stream->Anti;
    REAL(sexp_stream)[19] = (int) stream->IncPrec;
    UNPROTECT(1);

    free(stream);
    return sexp_stream;
}
Beispiel #3
0
SEXP R_RngStreams_ResetNextSubstream (SEXP R_stream)
     /*----------------------------------------------------------------------*/
     /* Go to begining of next substream.                                    */
     /*                                                                      */
     /* parameters:                                                          */
     /*   R_stream ... (pointer) ... pointer the Stream object               */
     /*----------------------------------------------------------------------*/
{
  RngStream stream;

  /* check pointer */
  CHECK_STREAM_PTR(R_stream);

  /* Extract pointer to generator */
  stream = R_ExternalPtrAddr(R_stream);
  CHECK_NULL(stream);

  /* reset */
  RngStream_ResetNextSubstream(stream);

  return R_NilValue;
} /* end of R_RngStreams_ResetNextSubstream() */