Initialize() public static method

public static Initialize ( ) : void
return void
コード例 #1
0
 public void BenchSetup()
 {
     bodyPtr    = (Body *)Marshal.AllocHGlobal(Marshal.SizeOf <Body>() * 6);
     rsPtr      = (RS *)Marshal.AllocHGlobal(3 * 1024 * sizeof(double));
     nBodyPP    = Marshal.AllocHGlobal(Marshal.SizeOf <BodyVector>() * 12);
     nBodyPtr   = (BodyVector *)((ulong)nBodyPP - ((ulong)nBodyPP + 16) % 16);
     rPtr       = (R *)Marshal.AllocHGlobal(Marshal.SizeOf <R>() * 1024);
     magPtr     = (double *)Marshal.AllocHGlobal(sizeof(double) * 1024);
     bodySystem = new NBodySystem(bodyPtr);
     NBodySystem.Initialize(nBodyPtr);
 }
コード例 #2
0
    public static void Test()
    {
        const int n = 10000;

        NBodySystem.Initialize();

        InitialEnergy = (long)Math.Floor(NBodySystem.Energy() * Scale);

        for (int i = 0; i < n; i++)
        {
            NBodySystem.Advance(0.01);
        }

        FinalEnergy = (long)Math.Floor(NBodySystem.Energy() * Scale);
    }
コード例 #3
0
        public unsafe void InitializeVerify()
        {
            double *bvPtr = stackalloc double[sizeof(BodyVector) / sizeof(double)];

            NBodySystem.Initialize((BodyVector *)bvPtr);

            Body *      bodies     = stackalloc Body[5];
            NBodySystem bodySystem = new NBodySystem(bodies);

            var result = NBodySystem.DumpBodyVector(5);

            Assert.NotNull(result);

            var expected = NBodySystem.DumpBodies(bodies, 5);

            Assert.NotNull(expected);

            Assert.Equal(expected, result);
        }
コード例 #4
0
        public unsafe void AdvanceByOne()
        {
            double *bvPtr = stackalloc double[sizeof(BodyVector) / sizeof(double)];

            NBodySystem.Initialize((BodyVector *)bvPtr);

            Body *      bodies     = stackalloc Body[5];
            NBodySystem bodySystem = new NBodySystem(bodies);

            // Other data structures
            RS *    rsaPtr  = stackalloc RS[1];
            R *     rPtr    = stackalloc R[1024];
            double *magPtr  = stackalloc double[1024];
            double *mag2Ptr = stackalloc double[1024];

            NBodySystem.AdvanceStaticIntrSoa(0.01, rsaPtr, magPtr);
            var result = NBodySystem.DumpBodyVector(5);

            NBodySystem.AdvanceStaticIntr2(0.01, rPtr, mag2Ptr, ref bodySystem);
            var expected = NBodySystem.DumpBodies(bodies, 5);

            Assert.Equal(expected, result);
        }
コード例 #5
0
        public unsafe void Initialize()
        {
            double *bvPtr = stackalloc double[sizeof(BodyVector) / sizeof(double)];

            NBodySystem.Initialize((BodyVector *)bvPtr);
        }