Пример #1
0
        public override ILCell GenerateTestArrays()
        {
            ILCell ret   = new ILCell();
            int    count = 0;
            // empty
            ILArray <ushort> tmp;

            ret[count++] = ILArray <ushort> .empty(0, 0);

            ret[count++] = ILArray <ushort> .empty(1, 0);

            ret[count++] = ILArray <ushort> .empty(0, 1, 0);

            // scalar
            ret[count++] = (ILArray <ushort>)(ushort) 1;
            ret[count++] = (ILArray <ushort>) ushort.MaxValue;
            ret[count++] = (ILArray <ushort>) ushort.MinValue;
            ret[count++] = (ILArray <ushort>)(ushort) 0;
            ret[count++] = (ILArray <ushort>)(ushort)(30);
            // vector
            ret[count++] = ILMath.touint16(ILMath.zeros(1, 10));
            ret[count++] = ILMath.touint16(ILMath.ones(1, 10));
            ret[count++] = ILMath.touint16(ILMath.zeros(10, 1));
            ret[count++] = ILMath.touint16(ILMath.ones(10, 1));
            ret[count++] = ILMath.touint16(ILMath.vector(0.0, 10.0));
            ret[count++] = ILMath.touint16(ILMath.vector(0.0, 14.0));

            tmp          = ILMath.touint16(ILMath.vector(1.0, 14.0));
            tmp[0]       = ushort.MinValue;
            tmp["end"]   = ushort.MaxValue;
            tmp[3]       = 0;
            ret[count++] = tmp;
            // matrix
            ret[count++] = ILMath.touint16(ILMath.zeros(3, 2));
            ret[count++] = ILMath.touint16(ILMath.rand(2, 4));
            ret[count++] = ILMath.touint16(ILMath.ones(2, 3) * double.NaN);
            ret[count++] = ILMath.touint16(ILMath.ones(3, 2) / 0.0); // inf
            // 3d array
            ret[count++] = ILMath.touint16(ILMath.zeros(4, 3, 2));
            ret[count++] = ILMath.touint16(ILMath.ones(4, 3, 2));
            ret[count++] = ILMath.touint16(0.0 / ILMath.zeros(4, 3, 2));
            ret[count++] = ILMath.touint16(ILMath.ones(4, 3, 2) * ushort.MinValue);
            ret[count++] = ILMath.touint16(ILMath.rand(4, 3, 2) * ushort.MaxValue - (ushort.MaxValue / 2.0));
            // 4d array
            ret[count++] = ILMath.touint16(ILMath.rand(30, 2, 3, 20) * ushort.MaxValue - (ushort.MaxValue / 2.0));
            return(ret);
        }
Пример #2
0
        /// <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();
        }