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


C# ILArray.Equals方法代码示例

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


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

示例1: Test_Eye

		public void Test_Eye() {
			int errorCode = 0;
			try {
				ILArray<double> A = ILMath.eye(7, 4);
				double[] data = new double[28];
				for (int i = 0; i < data.Length; i += 8)
					data[i] = 1;
				ILArray<double> Res = new ILArray<double>(data, 7, 4);
				if (!Res.Equals(A))
					throw new Exception("Invalid value result: Eye should give diagonal matrix.");
				Success("Test_Eye successfull");
			}
			catch (Exception e) {
				Error("Test_Eye failed at errorCode: " + errorCode + " Reason: " + e.Message);
			}
		}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:16,代码来源:TESTILMath.cs

示例2: Test_linspace

 public void Test_linspace() {
     int errorCode = 0; 
     try {
         ILArray<double> A = ILMath.linspace(20.2,3.2,-1); 
         ILArray <double> Res = new ILArray<double>(3.2); 
         if (!Res.Equals(A))
             throw new Exception ("Test_linspace: invalid values detected!"); 
         if (!Res.Equals(ILMath.linspace(20.2,3.2,0)))
             throw new Exception ("Test_linspace: invalid values detected!"); 
         if (!Res.Equals(ILMath.linspace(20.2,3.2,1)))
             throw new Exception ("Test_linspace: invalid values detected!"); 
         errorCode = 1; 
         A = ILMath.linspace(20.2,3.2,6);  
         Res = new ILArray<double>(new double[]{20.20000,   16.80000,   13.40000,   10.00000,   6.60000,   3.20000}); 
         if (ILMath.norm(A - Res) > ILMath.MachineParameterDouble.eps * 10)
             throw new Exception ("Test_linspace: invalid values detected!"); 
         errorCode = 2; 
         A = ILMath.linspace(20.2,3.2);
         if (A.Length != 100)
             throw new ILArgumentException("linspace (start,end) should return 100 elements"); 
         Success();
     }catch(Exception e) {
         Error(errorCode,e.Message);
     }
 }
开发者ID:wdxa,项目名称:ILNumerics,代码行数:25,代码来源:TESTILMath.cs

示例3: 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

示例4: Test_Sum

        public void Test_Sum() {
            int errorCode = 0;
            try {
                double[] data = new double[120];
				for (int i = 0; i < data.Length; i++)
					data[i] = i+1;
				ILArray<double> A = new ILArray<double>(data, 6, 5, 4);
				ILArray<double> Res = new ILArray<double>(new double[20] {
					21,57,93,129,165,201,237,273,309,345,381,417,453,489,525,561,597,633,669,705}, 1, 5, 4);
				ILArray<double> S = ILMath.sum(A);
                ILPerformer p = new ILPerformer();
                if (S.Dimensions.NonSingletonDimensions != 2)
					throw new Exception("Wrong size of Sum result! ");
				if (S.Dimensions.NumberOfDimensions != 3)
					throw new Exception("Wrong size of Sum result! ");
				if (S.Dimensions[0] != 1)
					throw new Exception("Wrong size of leading Dimension of Sum result! ");
				if (S.Dimensions[1] != 5)
					throw new Exception("Wrong size of 2. Dimension of Sum result! ");
				if (S.Dimensions[2] != 4)
					throw new Exception("Wrong size of 3. Dimension of Sum result! ");
				if (S.Dimensions.NumberOfElements != 20)
					throw new Exception("Wrong number of elements of Sum result! ");
				if (! Res.Equals(S))
					throw new Exception("Wrong values of Sum result! ");

				ILArray<double> B = (ILArray<double>)A[1,"1:end;1:end;2"];
				double [] data2 = new double[4] { 350,380,410,440 };
				Res = new ILArray<double>(data2, 4, 1); 
				if (!Res.Equals(ILMath.sum(B,1)))
					throw new Exception("Wrong values of Sum result! ");
				
				errorCode = 1;
                // test non-matrix, reference case 
                A = (ILArray<double>)ILMath.counter(4,3,2).CreateReference();
                if (!A.IsReference) 
                    throw new Exception("sum: test data creation failed: A should be reference array!"); 
                Res = new double[,]{{15,18,21,24},{51,54,57,60}};  
                Res = ILMath.reshape(Res ,4,1,2);
                B = ILMath.sum(A,1); 
                if (!Res.Equals(B)) 
                    throw new Exception("sum: invalid result (n-d, reference)"); 

				
                ILArray<double> C = new ILArray<double>(data, 1, 1, 4, 5, 6);
				Res = new ILArray<double>(new double[30] {
					10,26,42,58,74,90,106,122,138,154,170,186,202,218,234,250,266
					,282,298,314,330,346,362,378,394,410,426,442,458,474},1,1,1,5,6);
                p.Tic(); 
                S = ILMath.sum(C,2);
                p.Toc();
                if (!Res.Equals(S)) 
					throw new Exception("Wrong values of Sum result! ");
                Info("Sum(1x1x4x5x6)[phy] needed: " + p.ToString());
                p.Tic();
                ILMath.sum(C);
                p.Toc();
                Info("Sum(1x1x4x5x6)[phy ohne Zuweisung] needed: " + p.ToString());
				
                errorCode = 2;
                C = (ILArray<double>)A.T;
                p.Tic();
                B = ILMath.sum(C);
                p.Toc();
                Info("Sum(5x4x6)[Ref] needed: " + p.ToString());
                p.Tic();
                ILMath.sum(C);
                p.Toc();
                Info("Sum(5x4x6)[Ref ohne Zuweisung] needed: " + p.ToString());
				
				data = new double[8]{15,51,18,54,21,57,24,60};
				Res = new ILArray<double>(data,1,2,4);
				if (!Res.Equals(B))
					throw new Exception("Wrong values of Sum result! ");
				
				errorCode = 3; 
				// big array: 
				data = new double[1000 * 1000 * 10]; 
				A = new ILArray<double>(data,1000,1000,10);
                p.Tic();
                C = ILMath.sum(A);
                p.Toc();
                Info("Sum(1000x1000x10) [phy] needed: " + p.ToString());
                p.Tic();
                ILMath.sum(A);
                p.Toc();
                Info("Sum(1000x1000x10) [phy ohne Zuweisung] needed: " + p.ToString());

				errorCode = 4;
				data = new double[1000 * 1000 * 10];
				A = new ILArray<double>(data, 1000000, 10);
                p.Tic();
                C = ILMath.sum(A);
                p.Toc();
                Info("Sum(1000000x10) [phy] needed: " + p.ToString());
                p.Tic();
                ILMath.sum(A);
                p.Toc();
                Info("Sum(1000000x10) [phy ohne Zuweisung] needed: " + p.ToString());

//.........这里部分代码省略.........
开发者ID:wdxa,项目名称:ILNumerics,代码行数:101,代码来源:TESTILMath.cs

示例5: Test_Apply

		public void Test_Apply() {
			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 = (ILArray<double>)A[1,"1,1;2,1,0;2:end"]; 
				ILArray<double> Res = new ILArray<double>(new double[24] {
				0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
				}, 2, 3, 4);
				// apply on physical storage
				ILArray<double> C = ILMath.ceil(ILMath.tanh(A) - 0.5); 
				if (!Res.Equals(C))
					throw new Exception("Wrong values of Apply result! ");

				// apply on reference arbitrary storage
				errorCode = 1; 
				Res = new ILArray<double>(new double[12] {
				 -1,0,0,-1,0,0,-1,0,0,-1,0,0
				}, 3, 2, 2);
				C = ILMath.floor(ILMath.sin(B));
				if (!Res.Equals(C))
					throw new Exception("Wrong values of Apply result! ");

				// apply on row reference vector 
				errorCode = 2;
				B.MinimumRefDimensions = 2; 
				C = (ILArray<double>) B["1,1;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"+
				"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0"];
				C = ILMath.pow(C, 2.3); 
				Res = ILMath.ones(2, 36) * 507.00226068959716;
				if (!Res.Equals(C))
					throw new Exception("Wrong values of Apply result! ");

				// apply on column reference vector 
				errorCode = 3; 
				C = (ILArray<double>)B[1,"1,1;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"+
				"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;0"];
				C = ILMath.sqrt(C) + 2.4432112354;       
				Res = ILMath.ones(36, 2) * 6.3161945816074176;
				if (!Res.Equals(C))
					throw new Exception("Wrong values of Apply result! ");

				// apply large array -> performance test
				errorCode = 4; 
				ILPerformer p = new ILPerformer();
				A = ILMath.ones(1000, 1000, 10);
				long durationsMath = 0;
				ILPerformer p2 = new ILPerformer(); 
				long durationsGC = 0;
				int cycles = 20; p2.Tic();
				for (int i = 0; i < cycles; i++) {
					durationsGC += p.Duration;
                    p.Tic();
						A = A + 3.4;
					p.Toc();
					durationsMath += p.Duration;

					p.Tic();
						System.GC.Collect();
					p.Toc(); 
				}
				p2.Toc(); 
				durationsMath /= cycles;
				durationsGC /= cycles;
				Info("Apply(1000x1000x10)[Phy] needed: " + durationsMath.ToString() +"/GC: "+ durationsGC.ToString() + "/All: " +p2.Duration.ToString());

				errorCode = 5;
				durationsMath = 0;
				durationsGC = 0;
				cycles = 20;
				A = (ILArray<double>)A.T;
				p2.Tic();
				for (int i = 0; i < cycles; i++) {
					p.Tic();
					B = A + 3.4;
					p.Toc();
					durationsMath += p.Duration;

					p.Tic();
					System.GC.Collect();
					p.Toc();
					durationsGC += p.Duration;
				}
				p2.Toc();
				durationsMath /= cycles;
				durationsGC /= cycles;
				Info("Apply(1000x1000x10)[Ref] needed: " + durationsMath.ToString() + "/GC: " + durationsGC.ToString() + "/All: " +p2.Duration.ToString());
				 
				Success();
            } catch (Exception e) {
				Error(errorCode, e.Message);
            }
		}
开发者ID:wdxa,项目名称:ILNumerics,代码行数:95,代码来源:TESTILMath.cs

示例6: Test_CopyFromArray

        public void Test_CopyFromArray() {
            int errorCode = 0;
            int oldRefMin = ILNumerics.Settings.ILSettings.MinimumRefDimensions;
            try {
				ILNumerics.Settings.ILSettings.MinimumRefDimensions = 4; 
                // B = A[idx,0]
				ILArray<double> A = ILMath.reshape(ILMath.vector(1.0,1.0,24.0),2,3,4);
				ILArray<double> B = A["0,1;0,1,2;0,1,2,3"];  
				if (!B.Equals(A))
					throw new Exception("Invalid value of result!"); 
				errorCode = 1;
                B = A[1,"0,1;0,1,2;0,1,2,3"]; 
                ILArray<double> Res = new ILArray<double>(new double[24]{1,3,5,7,9,11,13,15,17,19,21,23,2,4,6,8,10,12,14,16,18,20,22,24},3,4,2);
                if (!Res.Equals(B))
                    throw new Exception("Copy physical shifted: Invald result detected!");
                ILNumerics.Settings.ILSettings.MinimumRefDimensions = oldRefMin;
				Success("Test_CopyFromArray successfull.");
            } catch (Exception e) {
				Error("Test_CopyFromArray failed on ErrorCode: " + errorCode + "due: " + e.Message);
            } finally {
                ILNumerics.Settings.ILSettings.MinimumRefDimensions = oldRefMin;
            }
        }
开发者ID:wdxa,项目名称:ILNumerics,代码行数:23,代码来源:TESTILArray.cs

示例7: Test_ReferenceFromArray

        public void Test_ReferenceFromArray() {
            int errorCode = 0;
            try {
				// B = A[idx,0]
				string[] data = new string[20];
                for (int i = 0; i < data.Length; i++)
                    data[i] = "Value: " + i;
                ILArray<string> A = new ILArray<string>(data, 4,5);
				double[] ddata = new double[20] { 
					4,2,5,1,8,9,0,0,1,1,2,3,19,18,17,16,15,14,13,12 }; 
				ILArray<double> B = new ILArray<double>(ddata, 5, 2, 2); 
				// create unshifted subarray, addressed by matrix -> physical storage
				ILArray<string> C = A[B];
				string[] results = new string[20];
				for (int i = 0; i < results.Length; i++) {
					results[i] = data[(int)ddata[i]];
				}
				ILBaseArray<string> res = new ILArray<string>(results, 5, 2 ,2);
				if (!res.Equals(C))
					throw new Exception("Invalid value of result!"); 
				
				errorCode = 1;
				// elements out of bound error 
				try {
					B[4, 1, 1] = 333.0;
					C = A[10,B]; // ( <= Quatsch!)
					Error("Expected \"Out of bound\" Exception: 333.0"); 
				} catch (Exception) {
					// nothing 
				}

				errorCode = 2;
				// elements out of bound error 
				try {
					B[4, 1, 1] = -1.0;
					C = A[1000,B];
					Error("Expected \"Out of bound\" Exception: -1.0");
				} catch (Exception) {
					Info("Out of bounds signaled correctly.");
				}
				// B = A[idx,2]

				// A[idx] = B
				Success("Test_ReferenceFromArray successfull.");
            } catch (Exception e) {
				Error("Test_ReferenceFromArray failed on ErrorCode: " + errorCode + "due: " + e.Message);
            }
        }
开发者ID:wdxa,项目名称:ILNumerics,代码行数:48,代码来源:TESTILArray.cs


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