5 * Search for invertible matrices
7 * (c) 2000 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * Copyright (c) 2000 Mark Wooding
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
22 * 2, Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
26 * 3. The name of the authors may not be used to endorse or promote
27 * products derived from this software without specific prior written
30 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
31 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
33 * NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
34 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
38 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGE.
42 * Instead of accepting the above terms, you may redistribute and/or modify
43 * this software under the terms of either the GNU General Public License,
44 * or the GNU Library General Public License, published by the Free
45 * Software Foundation; either version 2 of the License, or (at your
46 * option) any later version.
49 /*----- Revision history --------------------------------------------------*
51 * $Log: storin-mktab.c,v $
52 * Revision 1.2 2000/07/02 15:21:20 mdw
55 * Revision 1.1 2000/05/21 11:28:30 mdw
60 /*----- Header files ------------------------------------------------------*/
73 /*----- Main code ---------------------------------------------------------*/
75 int main(int argc, char *argv[])
81 /* --- Make the seed string --- */
86 const char *p = "matrix-seed-string";
95 dsarand_init(&r, h, sizeof(h));
99 /* --- Make a matrix --- */
104 for (i = 0; i < 16; i++) {
106 dsarand_fill(&r, w, sizeof(w));
110 /* --- Ensure the LSBs have appropriate properties --- */
112 for (i = 0; i < 4; i++) {
114 for (j = 0; j < 4; j++) {
115 if ((a[i * 4 + j] & 1) == 0) {
124 for (j = 0; j < i; j++) {
131 /* --- Ensure the matrix is invertible (and invert it) --- */
133 if (matinv(d, a, 4, 4) == 0)
141 * Tables for Storin [generated]\n\
144 #ifndef STORIN_TAB_H\n\
145 #define STORIN_TAB_H\n\
147 #define STORIN_M { \\\n\
150 for (i = 0; i < 16; i++) {
151 printf("0x%06x", a[i]);
153 fputs(" \\\n}\n\n", stdout);
155 fputs(", \\\n ", stdout);
161 #define STORIN_MI { \\\n\
164 for (i = 0; i < 16; i++) {
165 printf("0x%06x", d[i]);
167 fputs(" \\\n}\n\n", stdout);
169 fputs(", \\\n ", stdout);
174 fputs("#endif\n", stdout);
176 if (fclose(stdout)) {
177 fputs("error writing data\n", stderr);
184 /*----- That's all, folks -------------------------------------------------*/