/****************************************************************************** * * M4RI: Linear Algebra over GF(2) * * Copyright (C) 2007 Gregory Bard * Copyright (C) 2011 Carlo Wood * * 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/ ******************************************************************************/ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef _MSC_VER #include #endif #include #include #include #include "graycode.h" #include "misc.h" #include "mmc.h" void m4ri_die(const char *errormessage, ...) { va_list lst; va_start(lst, errormessage); vfprintf(stderr, errormessage, lst); va_end(lst); abort(); } /* Warning: If colon, destination must have m4ri_radix + (m4ri_radix - 1) / 4 + 1 bytes available. */ void m4ri_word_to_str(char *destination, word data, int colon) { int j = 0; for (int i = 0; i < m4ri_radix; ++i) { if (colon && (i % 4) == 0 && i != 0) destination[j++] = ':'; if (__M4RI_GET_BIT(data, i)) destination[j++] = '1'; else destination[j++] = ' '; } destination[j] = '\0'; } word m4ri_random_word() { #ifdef _MSC_VER word a = 0; int i; for(i=0; i< m4ri_radix; i+=8) { a ^= (((word)rand())<