Example #1
0
        //private static void TestKMeans()
        //{
        //    SharpPhysicsEngine.K_Means.KMeans engine = new SharpPhysicsEngine.K_Means.KMeans();

        //    //var points = new Vector3[] {
        //    //    new Vector3(1.0,1.0,0.0),
        //    //    new Vector3(1.5,2.0,0.0),
        //    //    new Vector3(3.0,4.0,0.0),
        //    //    new Vector3(5.0,7.0,0.0),
        //    //    new Vector3(3.5,5.0,0.0),
        //    //    new Vector3(4.5,5.0,0.0),
        //    //    new Vector3(3.5,4.5,0.0),
        //    //};

        //    var points = new Vector3[] {
        //        new Vector3(5.0,5.0,0.0),
        //        new Vector3(9,8.0,0.0),
        //        new Vector3(13.0,7.0,0.0),
        //        new Vector3(5.0,12.0,0.0),
        //        new Vector3(10,16.0,0.0),
        //        new Vector3(15,11.0,0.0),
        //        new Vector3(34,22,0.0),
        //        new Vector3(39,21,0.0),
        //        new Vector3(31,27,0.0),
        //        new Vector3(36,26,0.0),
        //        new Vector3(42,27,0.0),
        //        new Vector3(32,30,0.0),
        //        new Vector3(37,30,0.0),
        //        new Vector3(16,30,0.0),
        //        new Vector3(17,28,0.0),
        //        new Vector3(15,31,0.0),
        //        new Vector3(18,32,0.0),
        //        new Vector3(14,25,0.0),
        //    };

        //    var output = engine.Execute(points, 3);

        //}

        private static void Test()
        {
            Stopwatch stopwatch = new Stopwatch();

            int nvalue = 38000000;

            Random rnd = new Random();

            SharpEngineMathUtility.Vector3d[] testVector1 = new SharpEngineMathUtility.Vector3d[nvalue];

            for (int i = 0; i < nvalue; i++)
            {
                testVector1[i] = new SharpEngineMathUtility.Vector3d(rnd.NextDouble(), rnd.NextDouble(), rnd.NextDouble());
            }

            stopwatch.Reset();
            stopwatch.Start();

            double test1 = 0.0;

            for (int i = 0; i < nvalue; i++)
            {
                test1 = SharpEngineMathUtility.Vector3d.Dot(testVector1[i], testVector1[i]);
            }

            stopwatch.Stop();
            Console.WriteLine("Engine Elapsed={0}", stopwatch.ElapsedMilliseconds);

            //stopwatch.Reset();
            //stopwatch.Start();

            //for (int i = 0; i < nvalue; i++)
            //    test1 = SharpEngineMathUtility.Vector3.SimdDot(testVector1[i], testVector1[i]);

            //stopwatch.Stop();
            //Console.WriteLine("Engine Elapsed={0}", stopwatch.ElapsedMilliseconds);

            Console.ReadLine();
        }