Ejemplo n.º 1
0
        void Init(int initialHashSize, int initialIndexSize)
        {
            Debug.Assert(MathX.IsPowerOfTwo(initialHashSize));

            hashSize    = initialHashSize;
            hash        = INVALID_INDEX;
            indexSize   = initialIndexSize;
            indexChain  = INVALID_INDEX;
            granularity = DEFAULT_HASH_GRANULARITY;
            hashMask    = hashSize - 1;
            lookupMask  = 0;
        }
Ejemplo n.º 2
0
        static void Main()
        {
            // initialize math
            MathX.Init();

            // test idMatX
            //MatrixTest.Test();

            // test idPolynomial
            //Polynomial.Test();

            SimdTest.Test_f(new CmdArgs("test", false));
        }
Ejemplo n.º 3
0
        unsafe void Allocate(int newHashSize, int newIndexSize)
        {
            Debug.Assert(MathX.IsPowerOfTwo(newHashSize));

            Free();
            hashSize = newHashSize;
            hash     = new int[hashSize];

            fixed(void *hash_ = hash) Unsafe.InitBlock(hash_, 0xff, (uint)(hashSize * sizeof(int)));

            indexSize  = newIndexSize;
            indexChain = new int[indexSize];

            fixed(void *indexChain_ = indexChain) Unsafe.InitBlock(indexChain_, 0xff, (uint)(indexSize * sizeof(int)));

            hashMask   = hashSize - 1;
            lookupMask = -1;
        }
Ejemplo n.º 4
0
        static unsafe void Init()
        {
            Debug.Assert(sizeof(bool) == 1);
            Debug.Assert(sizeof(float) == sizeof(int));
            Debug.Assert(sizeof(Vector3) == 3 * sizeof(float));

            // initialize generic SIMD implementation
            //SIMD.Init();

            // initialize math
            MathX.Init();

            // test idMatX
            //MatrixX.Test();

            // test idPolynomial
            //Polynomial.Test();
        }
Ejemplo n.º 5
0
        public static void Test()
        {
            int i, num; float value; Complex complexValue; Polynomial p;
            var roots        = stackalloc float[4];
            var complexRoots = stackalloc Complex[4];

            p   = new(-5f, 4f);
            num = p.GetRoots(roots);
            for (i = 0; i < num; i++)
            {
                value = p.GetValue(roots[i]);
                Debug.Assert(MathX.Fabs(value) < 1e-4f);
            }

            p   = new(-5f, 4f, 3f);
            num = p.GetRoots(roots);
            for (i = 0; i < num; i++)
            {
                value = p.GetValue(roots[i]);
                Debug.Assert(MathX.Fabs(value) < 1e-4f);
            }

            p   = new(1f, 4f, 3f, -2f);
            num = p.GetRoots(roots);
            for (i = 0; i < num; i++)
            {
                value = p.GetValue(roots[i]);
                Debug.Assert(MathX.Fabs(value) < 1e-4f);
            }

            p   = new(5f, 4f, 3f, -2f);
            num = p.GetRoots(roots);
            for (i = 0; i < num; i++)
            {
                value = p.GetValue(roots[i]);
                Debug.Assert(MathX.Fabs(value) < 1e-4f);
            }

            p   = new(-5f, 4f, 3f, 2f, 1f);
            num = p.GetRoots(roots);
            for (i = 0; i < num; i++)
            {
                value = p.GetValue(roots[i]);
                Debug.Assert(MathX.Fabs(value) < 1e-4f);
            }

            p   = new(1f, 4f, 3f, -2f);
            num = p.GetRoots(complexRoots);
            for (i = 0; i < num; i++)
            {
                complexValue = p.GetValue(complexRoots[i]);
                Debug.Assert(MathX.Fabs(complexValue.r) < 1e-4f && MathX.Fabs(complexValue.i) < 1e-4f);
            }

            p   = new(5f, 4f, 3f, -2f);
            num = p.GetRoots(complexRoots);
            for (i = 0; i < num; i++)
            {
                complexValue = p.GetValue(complexRoots[i]);
                Debug.Assert(MathX.Fabs(complexValue.r) < 1e-4f && MathX.Fabs(complexValue.i) < 1e-4f);
            }
        }