Add an internal-representation no-op function.
[u/mdw/catacomb] / maurer.h
1 /* -*-c-*-
2 *
3 * $Id: maurer.h,v 1.2 2000/08/11 21:34:59 mdw Exp $
4 *
5 * Maurer's universal statistical test
6 *
7 * (c) 2000 Straylight/Edgeware
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Catacomb.
13 *
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
23 *
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
30 /*----- Revision history --------------------------------------------------*
31 *
32 * $Log: maurer.h,v $
33 * Revision 1.2 2000/08/11 21:34:59 mdw
34 * New restartable interface to Maurer testing.
35 *
36 * Revision 1.1 2000/06/17 11:29:49 mdw
37 * Maurer's universal statistical test.
38 *
39 */
40
41 #ifndef CATACOMB_MAURER_H
42 #define CATACOMB_MAURER_H
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /*----- Header files ------------------------------------------------------*/
49
50 #include <mLib/bits.h>
51
52 /*----- Data structures ---------------------------------------------------*/
53
54 typedef struct maurer_ctx {
55 unsigned l; /* Chunk size, in bits */
56 uint32 a; /* Bitscanner accumulator */
57 unsigned b; /* Number of bits in accumulator */
58 unsigned long n; /* Number of chunks read so far */
59 double x; /* Statistic value */
60 unsigned long *t; /* Offset table */
61 } maurer_ctx;
62
63 /*----- Functions provided ------------------------------------------------*/
64
65 /* --- @maurer_init@ --- *
66 *
67 * Arguments: @maurer_ctx *m@ = pointer to a context to initialize
68 * @unsigned l@ = number of bits to take at a time
69 *
70 * Returns: Minimum recommended amount of data to test.
71 *
72 * Use: Initializes a Maurer testing context. Note that @l@ values
73 * larger than 16 are not supported, and values less than 6 can
74 * give bizarre results.
75 */
76
77 extern unsigned long maurer_init(maurer_ctx */*m*/, unsigned /*l*/);
78
79 /* --- @maurer_test@ --- *
80 *
81 * Arguments: @maurer_ctx *m@ = pointer to a Maurer testing context
82 * @const void *buf@ = pointer to a buffer of data
83 * @size_t sz@ = size of the buffer
84 *
85 * Returns: ---
86 *
87 * Use: Scans a buffer of data and updates the testing context.
88 */
89
90 extern void maurer_test(maurer_ctx */*m*/,
91 const void */*buf*/, size_t /*sz*/);
92
93 /* --- @maurer_done@ --- *
94 *
95 * Arguments: @maurer_ctx *m@ = pointer to a Maurer testing context
96 *
97 * Returns: The statistic %$Z_u = (X_u - \mu)/\sigma$%, which should be
98 * normally distributed with a mean of 0 and variance of 1.
99 *
100 * Use: Returns the result of Maurer's universal statistical test.
101 * Also frees the memory allocated during initialization.
102 *
103 * If insufficient data was received, the value @HUGE_VAL@ is
104 * returned.
105 */
106
107 extern double maurer_done(maurer_ctx */*m*/);
108
109 /* --- @maurer@ --- *
110 *
111 * Arguments: @const octet *p@ = pointer to a buffer of data
112 * @size_t sz@ = size of the buffer
113 * @unsigned l@ = number of bits to take at a time
114 *
115 * Returns: The statistic %$Z_u$%.
116 *
117 * Use: Simple interface to Maurer's universal statistical test. For
118 * large %$l$% you should use the more complicated restartable
119 * interface.
120 */
121
122 extern double maurer(const octet */*p*/, size_t /*sz*/, unsigned /*l*/);
123
124 /*----- That's all, folks -------------------------------------------------*/
125
126 #ifdef __cplusplus
127 }
128 #endif
129
130 #endif