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


C# ILArray.Concat方法代码示例

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


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

示例1: Success

		/*		public void Test_Eye() {
					int errorCode = 0;
					try {
						double[] data = new double[24];
						for (int i = 0; i < data.Length; i++)
							data[i] = i;
						ILArray<double> A = new ILArray<double>(data, 2, 3, 4);
						Success("Test_Apply successfull");
					}
					catch (Exception e) {
						Error("Test_Apply failed at errorCode: " + errorCode + " Reason: " + e.Message);
					}
				}
		*/
        public void Test_Cat() {
			int errorCode = 0;
			try {
				double[] data = new double[24];
				for (int i = 0; i < data.Length; i++)
					data[i] = i;
				ILArray<double> A = new ILArray<double>(data, 2, 3, 4);
				ILArray<double> B = A.GetShifted(3);
                ILArray<double> C = ILMath.horzcat(A, A);
                ILArray<double> CRef = ILMath.horzcat(B, B);
                double[] result = new double[48] { 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 18, 19, 20, 21, 22, 23 };
                ILArray<double> Result = new ILArray<double>(result, 2, 6, 4);
                if (!Result.Equals(C)) {
                    throw new Exception("Test Cat: Test result failed: invalid values detected."); 
                }
                errorCode = 2; 
                if (!Result.Equals(CRef)) {
                    throw new Exception("Test Cat: Test result failed: invalid values detected."); 
                }
                errorCode = 3; 
                // test vertcat 
                result = new double[72] { 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 8, 9, 8, 9, 8, 9, 10, 11, 10, 11, 10, 11, 12, 13, 12, 13, 12, 13, 14, 15, 14, 15, 14, 15, 16, 17, 16, 17, 16, 17, 18, 19, 18, 19, 18, 19, 20, 21, 20, 21, 20, 21, 22, 23, 22, 23, 22, 23 };
                Result = new ILArray<double>(result, 6, 3, 4); 
                C = ILMath.vertcat(A,A,A); 
                if (!Result.Equals(C)) {
                    throw new Exception("Test Cat: Test result failed: invalid values detected."); 
                }
                errorCode = 4; 
                CRef = ILMath.vertcat(B,B,B); 
                if (!Result.Equals(C)) {
                    throw new Exception("Test Cat: Test result failed: invalid values detected."); 
                }
                // test large 
                errorCode = 5; 
                A = (ILArray<double>)ILMath.ones(1000, 1000, 10);
                Result = A.Concat(A, 2); 
                if (Result.m_dimensions.NumberOfDimensions != 3 || Result.m_dimensions[0] != 1000 || Result.m_dimensions[1] != 1000
                    || Result.m_dimensions[2] != 20) {
                    throw new Exception("Test Cat: Result dimension mismatch!");
                }
                ILArray<double> dummy = ILMath.sum(Result); 
                if (ILMath.sumall(dummy)!= 20000000) 
                    throw new Exception("sum partially wrong!");
                
                dummy = ILMath.sum(dummy); 
                if (ILMath.sumall(dummy)!= 20000000) 
                    throw new Exception("sum partially wrong!");
                
                dummy = ILMath.sum(dummy); 
                if (ILMath.sumall(dummy)!= 20000000) 
                    throw new Exception("sum partially wrong!");

                if (ILMath.sum(ILMath.sum(ILMath.sum(Result))) != 20000000) {
                    throw new Exception ("Test Cat: Invalid values detected."); 
                }
                // test Reference Concatenation
                errorCode = 6;
                B = A.GetShifted(3); 
                Result = B.Concat(B,2);
                if (Result.m_dimensions.NumberOfDimensions != 3 || Result.m_dimensions[0] != 1000 || Result.m_dimensions[1] != 1000
                    || Result.m_dimensions[2] != 20) {
                    throw new Exception("Test Cat: Result dimension mismatch!");
                }
                dummy = ILMath.sum(Result); 
                if (ILMath.sumall(dummy)!= 20000000) 
                    throw new Exception("sum partially wrong!");
                
                dummy = ILMath.sum(dummy); 
                if (ILMath.sumall(dummy)!= 20000000) 
                    throw new Exception("sum partially wrong!");
                
                dummy = ILMath.sum(dummy); 
                if (ILMath.sumall(dummy)!= 20000000) 
                    throw new Exception("sum partially wrong!");
                
                if (ILMath.sum(ILMath.sum(ILMath.sum(Result))) != 20000000) {
                    throw new Exception ("Test Cat: Invalid values detected."); 
                }
                Success("Test_Cat successfull");
			} catch (Exception e) {
                Error("Test_Cat failed at errorCode: " + errorCode + " Reason: " + e.Message);
			}
		}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:97,代码来源:TESTILMath.cs


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