class EuclideanDistance extends FastDistance {

    @Override
    public void updateLabel(FastDistanceData data) {
        if (data instanceof FastDistanceVectorData) {
            FastDistanceVectorData vectorData = (FastDistanceVectorData)data;
            double d = MatVecOp.dot(vectorData.vector, vectorData.vector);
            if (vectorData.label == null || vectorData.label.size() != LABEL_SIZE) {
                vectorData.label = new DenseVector(LABEL_SIZE);
            }
            vectorData.label.set(0, d);
        } else {
            FastDistanceMatrixData matrix = (FastDistanceMatrixData)data;
            int vectorSize = matrix.vectors.numRows();
            int numVectors = matrix.vectors.numCols();
            if (matrix.label == null || matrix.label.numCols() != numVectors || matrix.label.numRows() != LABEL_SIZE) {
                matrix.label = new DenseMatrix(LABEL_SIZE, numVectors);
            }
            double[] label = matrix.label.getData();
            double[] matrixData = matrix.vectors.getData();
            Arrays.fill(label, 0.0);
            int labelCnt = 0;
            int cnt = 0;
            while(cnt < matrixData.length){
                int endIndex = cnt + vectorSize;
                while(cnt < endIndex){
                    label[labelCnt] += matrixData[cnt] * matrixData[cnt];
                    cnt++;
                }
                labelCnt++;
            }
        }
    }

}