CSharp examples for System:Array Compare
Compare two double arrays using a given tolerance.
/*/*w w w. java 2s.com*/ * Copyright: Thomas McGlynn 1997-2007. * * The CSharpFITS package is a C# port of Tom McGlynn's * nom.tam.fits Java package, initially ported by Samuel Carliles * * Copyright: 2007 Virtual Observatory - India. * * Use is subject to license terms */ using System.Collections; using System; public class Main{ // suggested in .99.2 version: /// <summary> Compare two double arrays using a given tolerance.</summary> static bool DoubleArrayEquals(double[] x, double[] y, double tol) { for (int i = 0; i < x.Length; i += 1) { if (x[i] == 0) { return y[i] == 0; } if (Math.Abs((y[i] - x[i]) / x[i]) > tol) { return false; } } return true; } }