Get a value from the (upper triangular) distance matrix.

Note: in many cases, linear iteration over the matrix will be fastet than
repeated calls to this method!

@param x First object
@param y Second object
@return Distance
13174
public double get(int x, int y) {
    return (x == y) ? 0 : (x < y) //
        ? matrix[MatrixParadigm.triangleSize(y) + x] //
        : matrix[MatrixParadigm.triangleSize(x) + y];
  }
847948
public double getDistance(Coordinate coordinate) {
		double minDistance = Double.MAX_VALUE;

		if (!isEmpty()) {
			for (int i = 0; i < this.coordinates.length - 1; i++) {
				double dist = Mathlib.distance(this.coordinates[i], this.coordinates[i + 1], coordinate);
				if (dist < minDistance) {
					minDistance = dist;
				}
			}
		}
		return minDistance;
	}
739408
public double distance(Vector3d v) {
        double dx = x - v.x;
        double dy = y - v.y;
        double dz = z - v.z;

        return Math.sqrt(dx * dx + dy * dy + dz * dz);
    }
166538
public static double getDistance(Localizable a, Localizable b)
    {
        Check.notNull(a);
        Check.notNull(b);

        final double x = b.getX() - a.getX();
        final double y = b.getY() - a.getY();

        return StrictMath.sqrt(x * x + y * y);
    }
789480
protected static double distanceSq(double[] a, double[] b) {
		double sum = 0;
		for (int i = 0; i < a.length; i++) {
			double d = a[i]-b[i];
			sum += d*d;
		}
		return sum;
	}
342394
public double distance(int[] point1, int[] point2) throws Exception {
    return Math.sqrt(Long.valueOf(distance2(point1, point2)).doubleValue());
  }
1156608
public double distance(Instance first, Instance second) {
    return distance(first, second, Double.POSITIVE_INFINITY);
  }
1334001
@Pure
	public static Point2d L1_L3(double x, double y) {
		final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
				LAMBERT_1_N,
				LAMBERT_1_C,
				LAMBERT_1_XS,
				LAMBERT_1_YS);
		return NTFLambdaPhi_NTFLambert(
				ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
				LAMBERT_3_N,
				LAMBERT_3_C,
				LAMBERT_3_XS,
				LAMBERT_3_YS);
	}
6967
@Pure
	public double distanceSquaredSegment(Point3D point) {
		return distanceSquaredSegmentPoint(
				getX1(), getY1(), getZ1(),
				getX2(), getY2(), getZ2(),
				point.getX(), point.getY(), point.getZ());
	}
135098
@Pure
	public static Point2d L1_L4(double x, double y) {
		final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
				LAMBERT_1_N,
				LAMBERT_1_C,
				LAMBERT_1_XS,
				LAMBERT_1_YS);
		return NTFLambdaPhi_NTFLambert(
				ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
				LAMBERT_4_N,
				LAMBERT_4_C,
				LAMBERT_4_XS,
				LAMBERT_4_YS);
	}
1121410
static double squaredDistance(double[] x, double[] y) {
        int n = x.length;
        int m = 0;
        double dist = 0.0;

        for (int i = 0; i < n; i++) {
            if (!Double.isNaN(x[i]) && !Double.isNaN(y[i])) {
                m++;
                double d = x[i] - y[i];
                dist += d * d;
            }
        }

        if (m == 0) {
            dist = Double.MAX_VALUE;
        } else {
            dist = n * dist / m;
        }

        return dist;
    }
15206
public static double squaredDistance(int[] x, int[] y) {
        if (x.length != y.length) {
            throw new IllegalArgumentException("Input vector sizes are different.");
        }

        double sum = 0.0;
        for (int i = 0; i < x.length; i++) {
            sum += sqr(x[i] - y[i]);
        }

        return sum;
    }
848519
public long getIdx(int x,int y){
		long idx=-1;
		if(x>=0&&x<dim1&&y>=0&&y<dim2)
			idx = dim1*x+y;
		return idx;
	}
1342073
public Double distance3d(Position other) {
		if (other == null || latitude == null || longitude == null || altitude == null)
			return null;

		double[] xyz1 = this.toECEF();
		double[] xyz2 = other.toECEF();

		return Math.sqrt(
				Math.pow(xyz2[0] - xyz1[0], 2) +
						Math.pow(xyz2[1] - xyz1[1], 2) +
						Math.pow(xyz2[2] - xyz1[2], 2)
		);
	}
306788
@Pure
	public double distance(double x, double y) {
		double dist = Double.POSITIVE_INFINITY;
		if (isValidPrimitive()) {
			for (final BusStop stop : this.busStops) {
				final double d = stop.distance(x, y);
				if (!Double.isNaN(d) && d < dist) {
					dist = d;
				}
			}
		}
		return Double.isInfinite(dist) ? Double.NaN : dist;
	}
480735
public float distance(float x, float y, float z) {
        float dx = this.x - x;
        float dy = this.y - y;
        float dz = this.z - z;
        return (float) Math.sqrt(dx * dx + dy * dy + dz * dz);
    }
990907
public static double squaredDistance(SparseArray x, SparseArray y) {
        Iterator<SparseArray.Entry> it1 = x.iterator();
        Iterator<SparseArray.Entry> it2 = y.iterator();
        SparseArray.Entry e1 = it1.hasNext() ? it1.next() : null;
        SparseArray.Entry e2 = it2.hasNext() ? it2.next() : null;

        double sum = 0.0;
        while (e1 != null && e2 != null) {
            if (e1.i == e2.i) {
                sum += Math.sqr(e1.x - e2.x);
                e1 = it1.hasNext() ? it1.next() : null;
                e2 = it2.hasNext() ? it2.next() : null;
            } else if (e1.i > e2.i) {
                sum += Math.sqr(e2.x);
                e2 = it2.hasNext() ? it2.next() : null;
            } else {
                sum += Math.sqr(e1.x);
                e1 = it1.hasNext() ? it1.next() : null;
            }
        }
        
        while (it1.hasNext()) {
            sum += Math.sqr(it1.next().x);
        }

        while (it2.hasNext()) {
            sum += Math.sqr(it2.next().x);
        }
        
        return sum;
    }