private void TestBucketSortArrayMatrixRow() { try { ILArray <string> A = new ILArray <string>(3, 4); A[0, 0] = "abc"; A[0, 1] = "rtu"; A[0, 2] = "sfkw"; A[0, 3] = "lsdkfi"; A[1, 0] = "iowejkc"; A[1, 1] = "cjks"; A[1, 2] = "wokys"; A[1, 3] = "suem,"; A[2, 0] = "fgj"; A[2, 1] = "JKSF"; A[2, 2] = "SEs"; A[2, 3] = "SEFsr"; ILArray <double> ind; ILArray <string> res = ILMath.sort(A, out ind, 0, false); if (!res.Equals(A[ind])) { throw new Exception("invalid indices/values detected"); } ILArray <Int16> indI = ILMath.toint16(ILMath.counter(0.0, 1.0, A.Dimensions.ToIntArray())); res = ILMath.sort(A, ref indI, 0, true, new ILASCIIKeyMapper()); if (!res.Equals(A[indI])) { throw new Exception("invalid indices/values detected"); } Success(" elapsed: " + m_stopwatch.ElapsedMilliseconds + " ms"); } catch (Exception e) { Error(0, e.Message); } }
public override ILCell GenerateTestArrays() { ILCell ret = new ILCell(); int count = 0; // empty ILArray <short> tmp; ret[count++] = ILArray <short> .empty(0, 0); ret[count++] = ILArray <short> .empty(1, 0); ret[count++] = ILArray <short> .empty(0, 1, 0); // scalar ret[count++] = (ILArray <short>)(short) 1; ret[count++] = (ILArray <short>) short.MaxValue; ret[count++] = (ILArray <short>) short.MinValue; ret[count++] = (ILArray <short>)(short) 0; ret[count++] = (ILArray <short>)(short)(-30); // vector ret[count++] = ILMath.toint16(ILMath.zeros(1, 10)); ret[count++] = ILMath.toint16(ILMath.ones(1, 10)); ret[count++] = ILMath.toint16(ILMath.zeros(10, 1)); ret[count++] = ILMath.toint16(ILMath.ones(10, 1)); ret[count++] = ILMath.toint16(ILMath.vector(0.0, 10.0)); ret[count++] = ILMath.toint16(ILMath.vector(-5.0, 4.0)); tmp = ILMath.toint16(ILMath.vector(-5.0, 4.0)); tmp[0] = short.MinValue; tmp["end"] = short.MaxValue; tmp[3] = 0; ret[count++] = tmp; // matrix ret[count++] = ILMath.toint16(ILMath.zeros(3, 2)); ret[count++] = ILMath.toint16(ILMath.rand(2, 4)); ret[count++] = ILMath.toint16(ILMath.ones(2, 3) * double.NaN); ret[count++] = ILMath.toint16(ILMath.ones(3, 2) / 0.0); // inf // 3d array ret[count++] = ILMath.toint16(ILMath.zeros(4, 3, 2)); ret[count++] = ILMath.toint16(ILMath.ones(4, 3, 2)); ret[count++] = ILMath.toint16(0.0 / ILMath.zeros(4, 3, 2)); ret[count++] = ILMath.toint16(ILMath.ones(4, 3, 2) * short.MinValue); ret[count++] = ILMath.toint16(ILMath.rand(4, 3, 2) * short.MaxValue - (short.MaxValue / 2.0)); // 4d array ret[count++] = ILMath.toint16(ILMath.rand(30, 2, 3, 20) * short.MaxValue - (short.MaxValue / 2.0)); return(ret); }
/// <summary> /// run all tests for ILMatFile /// </summary> public override void Run() { // tests: creation // ================= Header(); Test_TestMatlab(); Test_StreamMatlab("testarray1.mat", ILMath.empty()); Test_StreamMatlab("testarray1.mat", ILMath.ones(1, 1)); Test_StreamMatlab("testarray1.mat", ILMath.rand(10, 1)); Test_StreamMatlab("testarray1.mat", ILMath.rand(1, 10)); Test_StreamMatlab("testarray1.mat", ILMath.rand(0, 1)); Test_StreamMatlab("testarray1.mat", ILMath.rand(10, 100, 4)); Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.ones(1, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.empty())); Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.rand(10, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.rand(1, 10))); Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.rand(0, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tosingle(ILMath.rand(10, 100, 4))); Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.ones(1, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.empty())); Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.rand(10, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.rand(1, 10))); Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.rand(0, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tological(ILMath.rand(10, 100, 4))); Test_StreamMatlab("testarray1.mat", new ILArray <complex>(new complex[] { new complex(1.0, 2.0) })); Test_StreamMatlab("testarray1.mat", ILMath.tocomplex(ILMath.empty())); Test_StreamMatlab("testarray1.mat", ILMath.tocomplex(ILMath.rand(10, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tocomplex(ILMath.rand(1, 10))); Test_StreamMatlab("testarray1.mat", ILMath.tocomplex(ILMath.rand(0, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tocomplex(ILMath.rand(10, 100, 4))); Test_StreamMatlab("testarray1.mat", new ILArray <fcomplex>(new fcomplex[] { new fcomplex(1.0f, 2.0f) })); Test_StreamMatlab("testarray1.mat", ILMath.tofcomplex(ILMath.empty())); Test_StreamMatlab("testarray1.mat", ILMath.tofcomplex(ILMath.rand(10, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tofcomplex(ILMath.rand(1, 10))); Test_StreamMatlab("testarray1.mat", ILMath.tofcomplex(ILMath.rand(0, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tofcomplex(ILMath.rand(10, 100, 4))); Test_StreamMatlab("testarray1.mat", new ILArray <char>(new char[] { 'A', 'B', 'F' })); Test_StreamMatlab("testarray1.mat", new ILArray <char>(new char[] { 'A', 'B', 'F' }).T); Test_StreamMatlab("testarray1.mat", ILMath.tochar(ILMath.empty())); Test_StreamMatlab("testarray1.mat", ILMath.tochar(ILMath.rand(10, 1) * 250)); Test_StreamMatlab("testarray1.mat", ILMath.tochar(ILMath.rand(1, 10) * 250)); Test_StreamMatlab("testarray1.mat", ILMath.tochar(ILMath.rand(0, 1) * 250)); Test_StreamMatlab("testarray1.mat", ILMath.tochar(ILMath.rand(10, 100, 4) * 250)); Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.ones(1, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.empty())); Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.rand(10, 1))); Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.rand(1, 10) * 255)); Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.rand(0, 1) * 255)); Test_StreamMatlab("testarray1.mat", ILMath.tobyte(ILMath.rand(10, 100, 4) * 255)); Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.ones(1, 1) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.empty()) * 16000); Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.rand(10, 1) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.rand(1, 10) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.rand(0, 1) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.toint16(ILMath.rand(10, 100, 4) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.ones(1, 1) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.empty() * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.rand(10, 1) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.rand(1, 10) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.rand(0, 1) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.toint32(ILMath.rand(10, 100, 4) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.ones(1, 1) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.empty() * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.rand(10, 1) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.rand(1, 10) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.rand(0, 1) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.touint16(ILMath.rand(10, 100, 4) * 16000)); Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.ones(1, 1))); Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.empty())); Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.rand(10, 1))); Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.rand(1, 10))); Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.rand(0, 1))); Test_StreamMatlab("testarray1.mat", ILMath.touint32(ILMath.rand(10, 100, 4))); Test_ImportMatlab2(); Test_ImportMatlab(); Test_NameRestrictions(); // summary Footer(); }