-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmfreq_analysis.h
52 lines (31 loc) · 956 Bytes
/
mfreq_analysis.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef MFREQ_ANA_H__
#define MFREQ_ANA_H__
/*
* This module perform a multi frequency analysis on a given text.
*/
#include <sys/types.h>
#include "charset.h"
#include "freq.h"
/* The frequencies for letters A..Z for several pre-defined languages. */
extern float freq_en[];
extern float freq_fr[];
struct mfreq {
const char *str;
size_t klen;
const struct charset *charset;
const float *reffreq;
/* One table for every key letter. */
struct freq *freq;
/* Best shifts. */
size_t *shift;
};
/* Initialize a struct mfreq. */
void mfa_init(struct mfreq *mfa, const char *str, size_t klen,
const struct charset *charset, const float *reffreq);
/* Deinitialize a struct mfreq. */
void mfa_fini(struct mfreq *mfa);
/* Compute the frequencies and the best shifts. */
void mfa_analyze(struct mfreq *mfa);
/* TODO: Change the shift of the n-th element and return the new distance to
* language frequencies. */
#endif