コード例 #1
0
        public virtual int sceSfmt19937InitGenRand(TPointer sfmtctx, int seed)
        {
            // Assign and store the current context.
            sfmt19937Ctx ctx = new sfmt19937Ctx(sfmtctx, seed);

            ctxMap[sfmtctx] = ctx;
            return(0);
        }
コード例 #2
0
        public virtual long sceSfmt19937GenRand64(TPointer sfmtctx)
        {
            long result = 0;

            // Check if the context has been initialized.
            if (ctxMap.ContainsKey(sfmtctx))
            {
                sfmt19937Ctx ctx = ctxMap[sfmtctx];
                ctx.generate();
                result = ctx.NextRand64;
            }
            return(result);
        }
コード例 #3
0
        public virtual int sceSfmt19937InitByArray(TPointer sfmtctx, TPointer seeds, int seedsLength)
        {
            // Read and store the seeds.
            int[] s = new int[seedsLength];
            for (int i = 0; i < seedsLength; i++)
            {
                s[i] = seeds.getValue32();
            }
            // Assign and store the current context.
            sfmt19937Ctx ctx = new sfmt19937Ctx(sfmtctx, s);

            ctxMap[sfmtctx] = ctx;
            return(0);
        }
コード例 #4
0
 public virtual int sceSfmt19937FillArray64(TPointer sfmtctx, TPointer array, int arrayLength)
 {
     // Check if the context has been initialized.
     if (ctxMap.ContainsKey(sfmtctx))
     {
         sfmt19937Ctx ctx = ctxMap[sfmtctx];
         ctx.generate();
         // Fill the array with the random values.
         for (int i = 0; i < arrayLength; i++)
         {
             array.setValue64(i, ctx.NextRand64);
         }
     }
     return(0);
 }