Here you can find the source of AreEqual(double[] vector1, double[] vector2)
Parameter | Description |
---|---|
vector1 | The first vector |
vector2 | The second vector |
public static boolean AreEqual(double[] vector1, double[] vector2)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w . jav a2 s . co m*/ * Use this method to check that two vectors have are the same, i.e. * that they contain the same items in the same order (equal from a maths * perspective). * @param vector1 The first vector * @param vector2 The second vector * @return If the two vectors are mathematically equal, returns true. False otherwise. */ public static boolean AreEqual(double[] vector1, double[] vector2) { try { CheckArrays(vector1, vector2); } catch (IllegalArgumentException ex) { return false; } for (int i = 0; i < vector2.length; i++) { if (vector1[i] != vector2[i]) return false; } return true; } /** * Ensures that the size of two arrays is equal. * @param vector1 The first vector * @param vector2 The second vector * @throws IllegalArgumentException if vectors have different dimensions. */ public static void CheckArrays(double[] vector1, double[] vector2) { if (vector1.length != vector2.length) { throw new IllegalArgumentException( "The vectors have to be of the same size."); } } }