Java Distance Calculate distanceMat(double[][] m1, double[][] m2)

Here you can find the source of distanceMat(double[][] m1, double[][] m2)

Description

distance Mat

License

Open Source License

Declaration

public static double distanceMat(double[][] m1, double[][] m2) 

Method Source Code

//package com.java2s;
/*//from w  w w.j a v a  2  s.  co  m
Copyright 2014, Xavier Hardy, Cl?ment Pique
    
This file is part of ecm-classifier.
    
ecm-classifier is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
ecm-classifier is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with ecm-classifier.  If not, see <http://www.gnu.org/licenses/>.
*/

public class Main {
    public static double distanceMat(double[][] m1, double[][] m2) {
        double res2 = 0;
        for (int i = 0; i < m1.length; i++) {
            for (int j = 0; j < m1[i].length; j++) {
                res2 += (m1[i][j] - m2[i][j]) * (m1[i][j] - m2[i][j]);
            }
        }
        return Math.sqrt(res2);
    }
}

Related

  1. distanceInMilesBetweenDouble(Float centerLat, Float centerLon, double lat, double lon)
  2. distanceInRadians(double latitude1, double longitude1, double latitude2, double longitude2)
  3. distanceKM(double lat1, double lng1, double lat2, double lng2)
  4. distanceLevenshtein(CharSequence s, CharSequence t)
  5. distanceLongitude(double latitude, double east, double west)
  6. distanceMeter(double prevLat, double prevLon, double currentLat, double currentLon)
  7. distanceNd(double[] p1, double[] p2, double[] scratchSpace)
  8. distancePointToLine(final double x0, final double y0, final double x1, final double y1, final double xp, final double yp)
  9. distancePointToPlane(final double x0, final double y0, final double z0, final double[] normal, final double xp, final double yp, final double zp)