当前位置: 首页>>代码示例>>C#>>正文


C# ILArray.CreateReference方法代码示例

本文整理汇总了C#中ILArray.CreateReference方法的典型用法代码示例。如果您正苦于以下问题:C# ILArray.CreateReference方法的具体用法?C# ILArray.CreateReference怎么用?C# ILArray.CreateReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILArray的用法示例。


在下文中一共展示了ILArray.CreateReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test_singleElementAccess

        public void Test_singleElementAccess() {
            int errorCode = 0; 
            try {
                ILArray<int> A = new ILArray<int>(new int[]{1,2,3,4,5,6,7,8,9,10,11,12},3,4); 
                if (!A[0].Equals(1)) throw new Exception("A[0] failed");
                if (!A[1].Equals(2)) throw new Exception("A[1] failed");
                if (!A[2].Equals(3)) throw new Exception("A[2] failed");
                if (!A[3].Equals(4)) throw new Exception("A[3] failed");
                if (!A[4].Equals(5)) throw new Exception("A[4] failed");
                if (!A[5].Equals(6)) throw new Exception("A[5] failed");
                if (!A[6].Equals(7)) throw new Exception("A[6] failed");
                if (!A[7].Equals(8)) throw new Exception("A[7] failed");
                if (!A[8].Equals(9)) throw new Exception("A[8] failed");
                if (!A[9].Equals(10)) throw new Exception("A[9] failed");
                if (!A[10].Equals(11)) throw new Exception("A[10] failed");
                if (!A[11].Equals(12)) throw new Exception("A[11] failed");
                errorCode = 1; 
                try {
                    ILArray<int> B = A[12]; 
                } catch (Exception) {
                    Info ("Out of range signaled ok");
                } 
                errorCode = 2; 
                if (!A[0,0].Equals(1)) throw new Exception("A[0,0] failed");
                if (!A[0,1].Equals(4)) throw new Exception("A[0,1] failed");
                if (!A[0,2].Equals(7)) throw new Exception("A[0,2] failed");
                if (!A[0,3].Equals(10)) throw new Exception("A[0,3] failed");
                if (!A[1,0].Equals(2)) throw new Exception("A[1,0] failed");
                if (!A[1,1].Equals(5)) throw new Exception("A[1,1] failed");
                if (!A[1,2].Equals(8)) throw new Exception("A[1,2] failed");
                if (!A[1,3].Equals(11)) throw new Exception("A[1,3] failed");
                if (!A[2,0].Equals(3)) throw new Exception("A[2,0] failed");
                if (!A[2,1].Equals(6)) throw new Exception("A[2,1] failed");
                if (!A[2,2].Equals(9)) throw new Exception("A[2,2] failed");
                if (!A[2,3].Equals(12)) throw new Exception("A[2,3] failed");
                errorCode = 3; 
                try { 
                    ILArray<int> B = A[3,3]; 
                    throw new Exception("out of range should throw exception");
                } catch (Exception e) {
                    if (e.Message == "out of range should throw exception")
                        throw e; 
                }
                try { ILArray<int> B = A[2,4]; 
                    throw new Exception("out of range should throw exception");
                } catch (Exception e) {
                    if (e.Message == "out of range should throw exception")
                        throw e; 
                }
                try { ILArray<int> B = A[4,3];  
                    throw new Exception("out of range should throw exception");
                } catch (Exception e) {
                    if (e.Message == "out of range should throw exception")
                        throw e; 
                }
                // test reshaping index in last dimension
                errorCode = 4; 
                A = ILMath.toint32(ILMath.vector(1,24));
                A = ILMath.reshape(A,4,3,2); 
                if (!A[1,5].Equals(22)) throw new Exception("A[1,5] failed");
                if (!A[3,5].Equals(24)) throw new Exception("A[1,5] failed");
                errorCode = 5;
                ///////////////  REFERENCE ARRAY /////////////////////////////

                A = new ILArray<int>(new int[]{1,2,3,4,5,6,7,8,9,10,11,12},3,4);
                A.MinimumRefDimensions = 2; 
                A = (ILArray<int>)A.CreateReference(); 
                if (!A[0].Equals(1)) throw new Exception("A[0] failed");
                if (!A[1].Equals(2)) throw new Exception("A[1] failed");
                if (!A[2].Equals(3)) throw new Exception("A[2] failed");
                if (!A[3].Equals(4)) throw new Exception("A[3] failed");
                if (!A[4].Equals(5)) throw new Exception("A[4] failed");
                if (!A[5].Equals(6)) throw new Exception("A[5] failed");
                if (!A[6].Equals(7)) throw new Exception("A[6] failed");
                if (!A[7].Equals(8)) throw new Exception("A[7] failed");
                if (!A[8].Equals(9)) throw new Exception("A[8] failed");
                if (!A[9].Equals(10)) throw new Exception("A[9] failed");
                if (!A[10].Equals(11)) throw new Exception("A[10] failed");
                if (!A[11].Equals(12)) throw new Exception("A[11] failed");
                errorCode = 1; 
                try {
                    ILArray<int> B = A[12]; 
                } catch (Exception) {
                    Info ("Out of range signaled ok");
                } 
                errorCode = 2; 
                if (!A[0,0].Equals(1)) throw new Exception("A[0,0] failed");
                if (!A[0,1].Equals(4)) throw new Exception("A[0,1] failed");
                if (!A[0,2].Equals(7)) throw new Exception("A[0,2] failed");
                if (!A[0,3].Equals(10)) throw new Exception("A[0,3] failed");
                if (!A[1,0].Equals(2)) throw new Exception("A[1,0] failed");
                if (!A[1,1].Equals(5)) throw new Exception("A[1,1] failed");
                if (!A[1,2].Equals(8)) throw new Exception("A[1,2] failed");
                if (!A[1,3].Equals(11)) throw new Exception("A[1,3] failed");
                if (!A[2,0].Equals(3)) throw new Exception("A[2,0] failed");
                if (!A[2,1].Equals(6)) throw new Exception("A[2,1] failed");
                if (!A[2,2].Equals(9)) throw new Exception("A[2,2] failed");
                if (!A[2,3].Equals(12)) throw new Exception("A[2,3] failed");
                errorCode = 3; 
                try { 
//.........这里部分代码省略.........
开发者ID:wdxa,项目名称:ILNumerics,代码行数:101,代码来源:TESTILArray.cs


注:本文中的ILArray.CreateReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。