001    /*
002     * Copyright (c) 1998-2014 ChemAxon Ltd. All Rights Reserved.
003     *
004     * This software is the confidential and proprietary information of
005     * ChemAxon. You shall not disclose such Confidential Information
006     * and shall use it only in accordance with the terms of the agreements
007     * you entered into with ChemAxon.
008     *
009     */
010    
011    package com.chemaxon.overlap.unguarded;
012    
013    import java.io.Serializable;
014    
015    /**
016     * Unguarded maximum diff dissimilarity for <code>float[]</code> vectors.
017     *
018     * <p><b>Use with extreme care!</b> This implementation wont check vector length equality.</p>
019     *
020     * @author Gabor Imre
021     */
022    public class UnguardedFloatVectorMaxDiff implements UnguardedDissimilarityCalculator<float[]>, Serializable {
023    
024        /**
025         * Serial version.
026         */
027        private static final long serialVersionUID = 0;
028    
029        @Override
030        public double dissimilarity(float[] target, float[] query) {
031            double r = 0;
032            for (int i = 0; i < target.length; i++) {
033                final double d = Math.abs(target[i] - query[i]);
034                r = Math.max(r, d);
035            }
036            return r;
037        }
038    
039        @Override
040        public String toString() {
041            return "Maximum coordinate diff dissimilarity of float[] vectors.";
042        }
043    
044    }