The R Project SVN R

Rev

Rev 76206 | Rev 79397 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 76206 Rev 76392
Line 544... Line 544...
544
}
544
}
545
 
545
 
546
 
546
 
547
SEXP attribute_hidden do_setseed (SEXP call, SEXP op, SEXP args, SEXP env)
547
SEXP attribute_hidden do_setseed (SEXP call, SEXP op, SEXP args, SEXP env)
548
{
548
{
549
    SEXP skind, nkind;
549
    SEXP skind, nkind, sampkind;
550
    int seed;
550
    int seed;
551
 
551
 
552
    checkArity(op, args);
552
    checkArity(op, args);
553
    if(!isNull(CAR(args))) {
553
    if(!isNull(CAR(args))) {
554
	seed = asInteger(CAR(args));
554
	seed = asInteger(CAR(args));
555
	if (seed == NA_INTEGER)
555
	if (seed == NA_INTEGER)
556
	    error(_("supplied seed is not a valid integer"));
556
	    error(_("supplied seed is not a valid integer"));
557
    } else seed = TimeToSeed();
557
    } else seed = TimeToSeed();
558
    skind = CADR(args);
558
    skind = CADR(args);
559
    nkind = CADDR(args);
559
    nkind = CADDR(args);
-
 
560
    sampkind = CADDDR(args);
560
    GetRNGkind(R_NilValue); /* pull RNG_kind, N01_kind from
561
    GetRNGkind(R_NilValue); /* pull RNG_kind, N01_kind from
561
			       .Random.seed if present */
562
			       .Random.seed if present */
562
    if (!isNull(skind)) RNGkind((RNGtype) asInteger(skind));
563
    if (!isNull(skind)) RNGkind((RNGtype) asInteger(skind));
563
    if (!isNull(nkind)) Norm_kind((N01type) asInteger(nkind));
564
    if (!isNull(nkind)) Norm_kind((N01type) asInteger(nkind));
-
 
565
    if(!isNull(sampkind)) Samp_kind((Sampletype) asInteger(sampkind));
564
    RNG_Init(RNG_kind, (Int32) seed); /* zaps BM history */
566
    RNG_Init(RNG_kind, (Int32) seed); /* zaps BM history */
565
    PutRNGstate();
567
    PutRNGstate();
566
    return R_NilValue;
568
    return R_NilValue;
567
}
569
}
568
 
570