1 1.1 mrg /* Cray mpn_hamdist -- hamming distance count. 2 1.1 mrg 3 1.1 mrg Copyright 2000 Free Software Foundation, Inc. 4 1.1 mrg 5 1.1 mrg This file is part of the GNU MP Library. 6 1.1 mrg 7 1.1 mrg The GNU MP Library is free software; you can redistribute it and/or modify 8 1.1 mrg it under the terms of the GNU Lesser General Public License as published by 9 1.1 mrg the Free Software Foundation; either version 3 of the License, or (at your 10 1.1 mrg option) any later version. 11 1.1 mrg 12 1.1 mrg The GNU MP Library is distributed in the hope that it will be useful, but 13 1.1 mrg WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 1.1 mrg or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 1.1 mrg License for more details. 16 1.1 mrg 17 1.1 mrg You should have received a copy of the GNU Lesser General Public License 18 1.1 mrg along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 1.1 mrg 20 1.1 mrg #include <intrinsics.h> 21 1.1 mrg #include "gmp.h" 22 1.1 mrg #include "gmp-impl.h" 23 1.1 mrg 24 1.1 mrg unsigned long int 25 1.1 mrg mpn_hamdist (mp_srcptr p1, mp_srcptr p2, mp_size_t n) 26 1.1 mrg { 27 1.1 mrg unsigned long int result = 0; 28 1.1 mrg mp_size_t i; 29 1.1 mrg for (i = 0; i < n; i++) 30 1.1 mrg result += _popcnt (p1[i] ^ p2[i]); 31 1.1 mrg return result; 32 1.1 mrg } 33