private static void Advance(NBody *bodies, Delta *r, double *mag, double dt)
    {
        unchecked {
            //NBody* i = null, j = null;
            //Delta* k = null;
            //for (i = ptrSun, k = r; i < ptrEnd; ++i) {
            //  NBody iBody = *i;
            //  for (j = i + 1; j <= ptrEnd; ++j, ++k) {
            //    k->dx = iBody.x - j->x;
            //    k->dy = iBody.y - j->y;
            //    k->dz = iBody.z - j->z;
            //  }
            //}
            //var arr = ToArray(r, 1000);
            //var a2 = ToArray(mag, 1000);

            for (int i = 0, k = 0; i < SIZE - 1; ++i)
            {
                NBody iBody = bodies[i];
                for (int j = i + 1; j < SIZE; ++j, ++k)
                {
                    r[k].dx = iBody.x - bodies[j].x;
                    r[k].dy = iBody.y - bodies[j].y;
                    r[k].dz = iBody.z - bodies[j].z;
                }
            }
            for (int i = 0; i < N; i += 2)
            {
                Vector128 <double> dx = default, dy = default, dz = default;
    private static void Advance(NBody *bodies, Delta *r, double dt)
    {
        unchecked {
            double *mag = stackalloc double[1000];

            for (int i = 0, k = 0; i < SIZE - 1; ++i)
            {
                NBody iBody = bodies[i];
                for (int j = i + 1; j < SIZE; ++j, ++k)
                {
                    r[k].dx = iBody.x - bodies[j].x;
                    r[k].dy = iBody.y - bodies[j].y;
                    r[k].dz = iBody.z - bodies[j].z;
                }
            }
            for (int i = 0; i < N; i += 2)
            {
                Vector128 <double> dx = default, dy = default, dz = default;
    public static void Main(string[] args)
    {
        unchecked {
            NBody *ptrSun = stackalloc NBody[SIZE];
            Delta *r      = stackalloc Delta[N];

            InitBodies(ptrSun);

            Console.Out.WriteLine(Energy(ptrSun).ToString("F9"));

            int advancements = args.Length > 0 ? Int32.Parse(args[0]) : 1000;
            while (advancements-- > 0)
            {
                Advance(ptrSun, r, 0.01d);
            }

            Console.Out.WriteLine(Energy(ptrSun).ToString("F9"));
        }
    }
    //fixed double mag[1000];

    public static void Main(string[] args)
    {
        unchecked {
            NBody * ptrSun = stackalloc NBody[SIZE];
            Delta * r      = stackalloc Delta[N];
            double *mag    = stackalloc double[N];

            InitBodies(ptrSun);      // stackalloc uses fewer lines though.

            string result = Energy(ptrSun).ToString("F9");
            //Debug.Assert(result == "-0.169075164", "Incorrect result of: " + result);
            Console.Out.WriteLine(result);

            int advancements = args.Length > 0 ? Int32.Parse(args[0]) : 1000;
            while (advancements-- > 0)
            {
                Advance(ptrSun, r, mag, 0.01d);
            }

            result = Energy(ptrSun).ToString("F9");
            //Debug.Assert(result == "-0.169059907", "Incorrect result of: " + result);
            Console.Out.WriteLine(result);
        }
    }