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; }
static void Main() { // initialize math MathX.Init(); // test idMatX //MatrixTest.Test(); // test idPolynomial //Polynomial.Test(); SimdTest.Test_f(new CmdArgs("test", false)); }
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; }
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(); }
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); } }