-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwalshf32.h
189 lines (172 loc) · 5.58 KB
/
walshf32.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#ifndef WALSH_SYSTEM_W32_WALSHF32_H
#define WALSH_SYSTEM_W32_WALSHF32_H
#ifdef WALSH_EXPORTS
#define W_API extern "C" __declspec(dllexport)
#else
#define W_API extern "C" __declspec(dllimport)
#endif
#include <radf.h>
namespace walshf {
// default rad function implementation
W_API int32_t (__stdcall *RAD_DEFAULT_PTR) (int32_t, double);
/**
* @brief Walsh functions
*
* @param n - function number (using Paley nums, starting from 0)
* @param x - value
*
* @return {1, -1}
*
* */
W_API int32_t __stdcall walp(uint32_t n, double x, int32_t (__stdcall *pRad)(int32_t, double) = RAD_DEFAULT_PTR);
/**
* @brief Walsh functions (sorted)
*
* @param n - function number (using Walsh nums, starting from 0)
* @param x - value
*
* @return {1, -1}
*
* */
W_API int32_t __stdcall wal(uint32_t n, double x, int32_t (__stdcall *pRad)(int32_t, double) = RAD_DEFAULT_PTR);
/**
* @brief Gets Walsh function result (using nums multiplication)
*
* @param k - function number (starting from 0)
* @parma m - another function number (starting from 0)
* @param x - value
* @param pWal - pointer on Walsh functions set implementation (wal or walp)
*
* @return {1, -1} or 0 on n < 0
*
* */
W_API int32_t __stdcall walmul(
uint32_t k,
uint32_t m,
double x,
int32_t (__stdcall *pWal)(uint32_t, double, int32_t (__stdcall *)(int32_t, double)) = wal,
int32_t (__stdcall *pRad)(int32_t, double) = RAD_DEFAULT_PTR);
/**
* @brief Gets sequence of Walsh function results (must be freed via free)
*
* @param k - function number (starting from 0)
* @param n - seq size
* @param x - value
* @param dx - value step
* @param pWal - pointer on Walsh functions set implementation (wal or walp)
*
* @return seq of {1, -1} vals on success,
* nullptr on k >= n or pWal = null
*
* */
W_API int32_t* __stdcall walseq(
uint32_t k,
uint32_t n,
double x,
double dx,
int32_t (__stdcall *pWal)(uint32_t, double, int32_t (__stdcall *)(int32_t, double)) = wal,
int32_t (__stdcall *pRad)(int32_t, double) = RAD_DEFAULT_PTR);
/**
* @brief Gets binary sequence of Walsh function results (must be freed via free)
*
* @param k - function number (starting from 0)
* @param n - seq size
* @param x - value
* @param dx - value step
* @param pWal - pointer on Walsh functions set implementation (wal or walp)
*
* @return seq of {1, -1} vals on success,
* nullptr on k >= n or pWal = null
*
* */
W_API uint32_t* __stdcall walbseq(
uint32_t k,
uint32_t n,
double x,
double dx,
int32_t (__stdcall *pWal)(uint32_t, double, int32_t (__stdcall *)(int32_t, double)) = wal,
int32_t (__stdcall *pRad)(int32_t, double) = RAD_DEFAULT_PTR);
/**
* @brief Gets sequence of Walsh function results (must be freed via free)
*
* @param k - function number (starting from 0)
* @param n - seq size (n = 2^m, m = 0,1,2,3 ....)
* @param pWal - pointer on Walsh functions set implementation (wal or walp)
*
* @return seq of {1, -1} vals on success,
* nullptr on k >= n
* or pWal = null
* or n is not pure log2 val
*
* */
W_API int32_t* __stdcall walseq_log2(
uint32_t k,
uint32_t n,
int32_t (__stdcall *pWal)(uint32_t, double, int32_t (__stdcall *)(int32_t, double)) = wal,
int32_t (__stdcall *pRad)(int32_t, double) = RAD_DEFAULT_PTR);
/**
* @brief Gets binary sequence of Walsh function results (must be freed via free)
*
* @param k - function number (starting from 0)
* @param n - seq size (n = 2^m, m = 0,1,2,3 ....)
* @param pWal - pointer on Walsh functions set implementation (wal or walp)
*
* @return seq of {1, -1} vals on success,
* nullptr on k >= n
* or pWal = null
* or n is not pure log2 val
*
* */
W_API uint32_t* __stdcall walbseq_log2(
uint32_t k,
uint32_t n,
int32_t (__stdcall *pWal)(uint32_t, double, int32_t (__stdcall *)(int32_t, double)) = wal,
int32_t (__stdcall *pRad)(int32_t, double) = RAD_DEFAULT_PTR);
/**
* @brief Walsh to Paley nums conversation
*
* (normal values to Gray codes conversion)
*
* @param n - source num
*
* @return Paley num
*
* */
W_API uint32_t __stdcall wal2pal(uint32_t n);
/**
* @brief Paley to Walsh nums conversation
*
* (Gray codes to normal values conversion)
*
* @param n - source num
*
* @return Walsh num
*
* */
W_API uint32_t __stdcall pal2wal(uint32_t n);
/**
* @brief Walsh to binary conversion
*
* (func results {1, -1} to binary {1, 0} conversion)
*
* @param n - value {1, -1}
*
* @return 1 on -1
* 0 on 1
*
* */
W_API uint32_t __stdcall wal2bin(uint32_t n);
/**
* @brief Binary to Walsh conversion
*
* (binary {1, 0} to func results {1, -1} conversion)
*
* @param n - value {1, -1}
*
* @return 1 on -1
* 0 on 1
*
* */
W_API int32_t __stdcall bin2wal(uint32_t n);
}
#endif //WALSH_SYSTEM_W32_WALSHF32_H