M4RI 20250128
debug_dump.h
1/*
2 * To enable dumping of output per function, configure the library with --enable-debug-dump.
3 */
4
5/******************************************************************************
6 *
7 * M4RI: Linear Algebra over GF(2)
8 *
9 * Copyright (C) 2011 Carlo Wood <carlo@alinoe.com>
10 *
11 * Distributed under the terms of the GNU General Public License (GPL)
12 * version 2 or higher.
13 *
14 * This code is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * The full text of the GPL is available at:
20 *
21 * http://www.gnu.org/licenses/
22 ******************************************************************************/
23
24#ifndef M4RI_DEBUG_DUMP
25#define M4RI_DEBUG_DUMP
26
27#include <m4ri/misc.h>
28
29static inline word calculate_hash(word const *rowptr, wi_t wide) {
30 word hash = 0;
31 for (word const *ptr = rowptr; ptr < rowptr + wide; ++ptr) { hash ^= *ptr; }
32 return hash;
33}
34
35static inline word rotate_word(word w, int shift) { return (w << shift) | (w >> (m4ri_radix - w)); }
36
37#if __M4RI_DEBUG_DUMP
38
39struct mzd_t;
40struct mzp_t;
41
42extern void m4ri_dd_int(char const *function, char const *file, int line, int i);
43extern void m4ri_dd_rci(char const *function, char const *file, int line, rci_t rci);
44extern void m4ri_dd_rci_array(char const *function, char const *file, int line, rci_t *rciptr,
45 int len);
46extern void m4ri_dd_rawrow(char const *function, char const *file, int line, word const *rowptr,
47 wi_t wide);
48extern void m4ri_dd_row(char const *function, char const *file, int line, struct mzd_t const *M,
49 rci_t row);
50extern void m4ri_dd_mzd(char const *function, char const *file, int line, struct mzd_t const *M);
51extern void m4ri_dd_mzp(char const *function, char const *file, int line, struct mzp_t const *P);
52
53#define __M4RI_DD_INT(i) m4ri_dd_int(__FUNCTION__, __FILE__, __LINE__, i)
54#define __M4RI_DD_RCI(rci) m4ri_dd_rci(__FUNCTION__, __FILE__, __LINE__, rci)
55#define __M4RI_DD_RCI_ARRAY(rciptr, len) \
56 m4ri_dd_rci_array(__FUNCTION__, __FILE__, __LINE__, rciptr, len)
57#define __M4RI_DD_RAWROW(rowptr, wide) \
58 m4ri_dd_rawrow(__FUNCTION__, __FILE__, __LINE__, rowptr, wide)
59#define __M4RI_DD_ROW(M, row) m4ri_dd_row(__FUNCTION__, __FILE__, __LINE__, M, row)
60#define __M4RI_DD_MZD(M) m4ri_dd_mzd(__FUNCTION__, __FILE__, __LINE__, M)
61#define __M4RI_DD_MZP(P) m4ri_dd_mzp(__FUNCTION__, __FILE__, __LINE__, P)
62
63#else // __M4RI_DEBUG_DUMP
64
65#define __M4RI_DD_INT(i)
66#define __M4RI_DD_RCI(rci)
67#define __M4RI_DD_RCI_ARRAY(rciptr, len)
68#define __M4RI_DD_RAWROW(rowptr, wide)
69#define __M4RI_DD_ROW(M, row)
70#define __M4RI_DD_MZD(M)
71#define __M4RI_DD_MZP(P)
72
73#endif // __M4RI_DEBUG_DUMP
74
75#endif // M4RI_DEBUG_DUMP
Helper functions.
int rci_t
Type of row and column indexes.
Definition misc.h:72
int64_t wi_t
Type of word indexes.
Definition misc.h:81
uint64_t word
A word is the typical packed data structure to represent packed bits.
Definition misc.h:87
static int const m4ri_radix
The number of bits in a word.
Definition misc.h:141
Dense matrices over GF(2).
Definition mzd.h:68
Permutations.
Definition mzp.h:37