Android examples for java.lang:array calculation
get Euclidean Distance No Sqrt between two float array
//package com.java2s; public class Main { public static float getEuclideanDistanceNoSqrt(float[] v1, float[] v2) { if (v1.length != v2.length) throw new IllegalArgumentException( "vectors have different lengths! v1=" + v1.length + " and v2=" + v2.length); float sum = 0.0f; for (int i = 0; i < v1.length; i++) { sum += (v1[i] - v2[i]) * (v1[i] - v2[i]); }//from ww w . ja v a 2 s . co m return sum; } }