Exemplo n.º 1
0
        private string[] generateStringsRandom(int count, int maxLen)
        {
            string []     ret  = new string[count];
            ILArray <int> r    = ILMath.toint32(ILMath.rand(maxLen, count) * 26) + (int)'a';
            ILArray <int> lens = ILMath.toint32(ILMath.rand(1, count) * (maxLen - 1));

            for (int i = 0; i < count; i++)
            {
                ILArray <double> rang  = ILMath.vector(0, lens.GetValue(i));
                ILArray <char>   chars = ILMath.tochar(r[rang, i]);
                ret[i] = new String(chars.Detach().m_data);
            }
            return(ret);
        }
Exemplo n.º 2
0
        public override ILCell GenerateTestArrays()
        {
            ILCell byteCell = new ILTestProviderByte().GenerateTestArrays();
            ILCell ret      = new ILCell(byteCell.Dimensions[0], byteCell.Dimensions[1]);
            int    counter  = 0;

            foreach (ILBaseArray arr in byteCell.Values)
            {
                if (arr is ILArray <byte> )
                {
                    ILArray <byte> arrB = arr as ILArray <byte>;
                    ret[counter++, 0] = ILMath.tochar(arrB);
                }
            }
            return(ret);
        }
Exemplo n.º 3
0
        public override ILCell GenerateTestArrays()
        {
            ILCell ret   = new ILCell();
            int    count = 0;
            // empty
            ILArray <char> tmp;

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

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

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

            // scalar
            ret[count++] = (ILArray <char>)(char) 1;
            ret[count++] = (ILArray <char>) char.MaxValue;
            ret[count++] = (ILArray <char>) char.MinValue;
            ret[count++] = (ILArray <char>)(char) 0.0;
            ret[count++] = (ILArray <char>)((char)30.0);
            // vector
            ret[count++] = ILMath.tochar(ILMath.zeros(1, 10));
            ret[count++] = ILMath.tochar(ILMath.ones(1, 10));
            ret[count++] = ILMath.tochar(ILMath.zeros(10, 1));
            ret[count++] = ILMath.tochar(ILMath.ones(10, 1));
            ret[count++] = ILMath.tochar(ILMath.vector(0.0, 10.0));
            ret[count++] = ILMath.tochar(ILMath.vector(-5.0, 4.0));

            tmp          = ILMath.tochar(ILMath.vector(-5.0, 4.0));
            tmp[0]       = char.MinValue;
            tmp["end"]   = char.MaxValue;
            tmp[3]       = (char)0;
            ret[count++] = tmp;
            // matrix
            ret[count++] = ILMath.tochar(ILMath.zeros(3, 2));
            ret[count++] = ILMath.tochar(ILMath.rand(2, 4));
            ret[count++] = ILMath.tochar(ILMath.ones(2, 3) * double.NaN);
            ret[count++] = ILMath.tochar(ILMath.ones(3, 2) / 0.0); // inf
            // 3d array
            ret[count++] = ILMath.tochar(ILMath.zeros(4, 3, 2));
            ret[count++] = ILMath.tochar(ILMath.ones(4, 3, 2));
            ret[count++] = ILMath.tochar(0.0 / ILMath.zeros(4, 3, 2));
            ret[count++] = ILMath.tochar(ILMath.ones(4, 3, 2) * char.MinValue);
            ret[count++] = ILMath.tochar(ILMath.rand(4, 3, 2) * char.MaxValue - (char.MaxValue / 2.0));
            // 4d array
            ret[count++] = ILMath.tochar(ILMath.rand(30, 2, 3, 20) * char.MaxValue - (char.MaxValue / 2.0));
            return(ret);
        }
Exemplo n.º 4
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();
        }