mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
C++ify RandTest.*
Specifically: - Move implementation details into *.cc. - Const correctness: do not require superfluous cast. - Style: asterisk "binds" to type, not name.
This commit is contained in:
parent
483cc6bd9e
commit
86faab1e06
2 changed files with 21 additions and 17 deletions
|
@ -12,7 +12,17 @@
|
||||||
Modified for Bro by Seth Hall - July 2010
|
Modified for Bro by Seth Hall - July 2010
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <RandTest.h>
|
#include "RandTest.h"
|
||||||
|
|
||||||
|
#define log2of10 3.32192809488736234787
|
||||||
|
/* RT_LOG2 -- Calculate log to the base 2 */
|
||||||
|
static double rt_log2(double x)
|
||||||
|
{
|
||||||
|
return log2of10 * log10(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
// RT_INCIRC = pow(pow(256.0, (double) (RT_MONTEN / 2)) - 1, 2.0);
|
||||||
|
#define RT_INCIRC 281474943156225.0
|
||||||
|
|
||||||
RandTest::RandTest()
|
RandTest::RandTest()
|
||||||
{
|
{
|
||||||
|
@ -28,9 +38,9 @@ RandTest::RandTest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandTest::add(void *buf, int bufl)
|
void RandTest::add(const void *buf, int bufl)
|
||||||
{
|
{
|
||||||
unsigned char *bp = (unsigned char*)buf;
|
const unsigned char *bp = static_cast<const unsigned char*>(buf);
|
||||||
int oc;
|
int oc;
|
||||||
|
|
||||||
while (bufl-- > 0)
|
while (bufl-- > 0)
|
||||||
|
|
|
@ -1,28 +1,22 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define log2of10 3.32192809488736234787
|
class EntropyVal;
|
||||||
/* RT_LOG2 -- Calculate log to the base 2 */
|
|
||||||
static double rt_log2(double x)
|
|
||||||
{
|
|
||||||
return log2of10 * log10(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define RT_MONTEN 6 /* Bytes used as Monte Carlo
|
#define RT_MONTEN 6 /* Bytes used as Monte Carlo
|
||||||
co-ordinates. This should be no more
|
co-ordinates. This should be no more
|
||||||
bits than the mantissa of your "double"
|
bits than the mantissa of your "double"
|
||||||
floating point type. */
|
floating point type. */
|
||||||
|
|
||||||
// RT_INCIRC = pow(pow(256.0, (double) (RT_MONTEN / 2)) - 1, 2.0);
|
|
||||||
#define RT_INCIRC 281474943156225.0
|
|
||||||
|
|
||||||
class RandTest {
|
class RandTest {
|
||||||
public:
|
public:
|
||||||
RandTest();
|
RandTest();
|
||||||
void add(void *buf, int bufl);
|
void add(const void* buf, int bufl);
|
||||||
void end(double* r_ent, double* r_chisq, double* r_mean,
|
void end(double* r_ent, double* r_chisq, double* r_mean,
|
||||||
double* r_montepicalc, double* r_scc);
|
double* r_montepicalc, double* r_scc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class EntropyVal;
|
||||||
|
|
||||||
long ccount[256]; /* Bins to count occurrences of values */
|
long ccount[256]; /* Bins to count occurrences of values */
|
||||||
long totalc; /* Total bytes counted */
|
long totalc; /* Total bytes counted */
|
||||||
int mp;
|
int mp;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue