/usr/include/m4ri/parity.h is in libm4ri-dev 20140914-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | #ifndef M4RI_PARITY_H
#define M4RI_PARITY_H
/*******************************************************************
*
* M4RI: Linear Algebra over GF(2)
*
* Copyright (C) 2008 David Harvey <dmharvey@cims.nyu.edu>
*
* Distributed under the terms of the GNU General Public License (GPL)
* version 2 or higher.
*
* This code 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.
*
* The full text of the GPL is available at:
*
* http://www.gnu.org/licenses/
*
********************************************************************/
/**
* \file parity.h
*
* \brief Compute the parity of 64 words in parallel.
*
* \author David Harvey
*/
#include <m4ri/misc.h>
/**
* \brief Step for mixing two 64-bit words to compute their parity.
*/
#define __M4RI_MIX32(a, b) (((((a) >> 32) ^ (a)) << 32) | \
((((b) << 32) ^ (b)) >> 32))
/**
* \brief Step for mixing two 64-bit words to compute their parity.
*/
#define __M4RI_MIX16(a, b) (((((a) << 16) ^ (a)) & __M4RI_CONVERT_TO_WORD(0xFFFF0000FFFF0000ull)) | \
((((b) >> 16) ^ (b)) & __M4RI_CONVERT_TO_WORD(0x0000FFFF0000FFFFull)));
/**
* \brief Step for mixing two 64-bit words to compute their parity.
*/
#define __M4RI_MIX8(a, b) (((((a) << 8) ^ (a)) & __M4RI_CONVERT_TO_WORD(0xFF00FF00FF00FF00ull)) | \
((((b) >> 8) ^ (b)) & __M4RI_CONVERT_TO_WORD(0x00FF00FF00FF00FFull)));
/**
* \brief Step for mixing two 64-bit words to compute their parity.
*/
#define __M4RI_MIX4(a, b) (((((a) << 4) ^ (a)) & __M4RI_CONVERT_TO_WORD(0xF0F0F0F0F0F0F0F0ull)) | \
((((b) >> 4) ^ (b)) & __M4RI_CONVERT_TO_WORD(0x0F0F0F0F0F0F0F0Full)));
/**
* \brief Step for mixing two 64-bit words to compute their parity.
*/
#define __M4RI_MIX2(a, b) (((((a) << 2) ^ (a)) & __M4RI_CONVERT_TO_WORD(0xCCCCCCCCCCCCCCCCull)) | \
((((b) >> 2) ^ (b)) & __M4RI_CONVERT_TO_WORD(0x3333333333333333ull)));
/**
* \brief Step for mixing two 64-bit words to compute their parity.
*/
#define __M4RI_MIX1(a, b) (((((a) << 1) ^ (a)) & __M4RI_CONVERT_TO_WORD(0xAAAAAAAAAAAAAAAAull)) | \
((((b) >> 1) ^ (b)) & __M4RI_CONVERT_TO_WORD(0x5555555555555555ull)));
/**
* \brief See parity64.
*/
static inline word m4ri_parity64_helper(word *buf)
{
word a0, a1, b0, b1, c0, c1;
a0 = __M4RI_MIX32(buf[0x20], buf[0x00]);
a1 = __M4RI_MIX32(buf[0x30], buf[0x10]);
b0 = __M4RI_MIX16(a1, a0);
a0 = __M4RI_MIX32(buf[0x28], buf[0x08]);
a1 = __M4RI_MIX32(buf[0x38], buf[0x18]);
b1 = __M4RI_MIX16(a1, a0);
c0 = __M4RI_MIX8(b1, b0);
a0 = __M4RI_MIX32(buf[0x24], buf[0x04]);
a1 = __M4RI_MIX32(buf[0x34], buf[0x14]);
b0 = __M4RI_MIX16(a1, a0);
a0 = __M4RI_MIX32(buf[0x2C], buf[0x0C]);
a1 = __M4RI_MIX32(buf[0x3C], buf[0x1C]);
b1 = __M4RI_MIX16(a1, a0);
c1 = __M4RI_MIX8(b1, b0);
return __M4RI_MIX4(c1, c0);
}
/**
* \brief Computes parity of each of buf[0], buf[1], ..., buf[63].
* Returns single word whose bits are the parities of buf[0], ...,
* buf[63].
*
* \param buf buffer of words of length 64
*/
static inline word m4ri_parity64(word *buf)
{
word d0, d1, e0, e1;
d0 = m4ri_parity64_helper(buf);
d1 = m4ri_parity64_helper(buf + 2);
e0 = __M4RI_MIX2(d1, d0);
d0 = m4ri_parity64_helper(buf + 1);
d1 = m4ri_parity64_helper(buf + 3);
e1 = __M4RI_MIX2(d1, d0);
return __M4RI_MIX1(e1, e0);
}
#endif // M4RI_PARITY_H
|