Here you can find the source of squareDistance(final double[] a, final double[] b)
Parameter | Description |
---|---|
a | a parameter |
b | a parameter |
public static double squareDistance(final double[] a, final double[] b)
//package com.java2s; public class Main { /**/*from w ww . j ava 2 s.co m*/ * get the squared length of (a - b). * * @param a * @param b */ public static double squareDistance(final double[] a, final double[] b) { assert rows(a) == rows(b); final int rows = rows(a); double squ_len = 0.0; for (int i = 0; i < rows; ++i) squ_len += (a[i] - b[i]) * (a[i] - b[i]); return squ_len; } public static int rows(final double[] a) { return a.length; } public static int rows(final double[][] A) { return A.length; } }