lfsr 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Emmanuel Oga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,96 @@
1
+ # Linear Feedback Shift Register
2
+
3
+ The generation of random numbers is too important to be left to chance.
4
+ Robert R. Coveyou
5
+
6
+ ## What is this?
7
+
8
+ [Wikipedia extract](http://en.wikipedia.org/wiki/Linear_feedback_shift_registers):
9
+
10
+ A linear feedback shift register (LFSR) is a shift register whose input bit is a linear function of its previous state. The initial value of the LFSR is called the seed.
11
+ Because the operation of the register is deterministic, the stream of values produced by the register is completely determined by its current (or previous) state.
12
+ Likewise, because the register has a finite number of possible states, it must eventually enter a repeating cycle.
13
+ However, an LFSR with a well-chosen feedback function can produce a sequence of bits which appears random and which has a very long cycle.
14
+ Applications of LFSRs include generating pseudo-random numbers, pseudo-noise sequences, fast digital counters, and whitening sequences.
15
+
16
+ ## How to use it
17
+
18
+ ```ruby
19
+ require 'lfsr/fast'
20
+
21
+ # The LFSR is 4 bits long, which means can iterate from 0 to 15. (15 == (2**4 - 1))
22
+ # A maximum value of 10 is set though, which means the values returned will be in the range [0, 10]
23
+ # The seed is 1. As long as you use the same seed, the pseudo-random psequence will be the same.
24
+ gen = LFSR::Size4.new 10, 1
25
+
26
+ 10.times do
27
+ print "#{gen.next_i} "
28
+ end
29
+
30
+ puts "once the sequence is complete, it starts again"
31
+
32
+ 10.times do
33
+ print "#{gen.next_i} "
34
+ end
35
+
36
+ puts
37
+
38
+ ```
39
+
40
+ ## Notes
41
+
42
+ ### Randomness
43
+
44
+ The main reason you would use a LFSR is because you need a long, non-repeating sequence of numbers.
45
+ A shuffled array of numbers can be used for this, but using a LFSR is nice because you don't need to allocate memory for each of the numbers in the sequence.
46
+ The disadvantage is that a LFSR doesn't generate numbers that are hard to distinguish from a truly random source. The sequence of numbers a LFSR generates is kind of... well... predictable.
47
+ Depending on your use case this may or may not be a problem for you.
48
+
49
+ ### Seed
50
+
51
+ The seed gets truncated to the number of bits of the LFSR.
52
+
53
+ The seed must be a non 0 value, in relation to the size of the register you are using.
54
+
55
+ For instance, if I try to use a seed of 8 for a LFSR::Size3, it will fail, because the seed is truncated to the bits of the register, and 0b1000 truncated to 3 bits is 0.
56
+
57
+ ### Fast / Pure-ruby versions
58
+
59
+ There are **two ways to require the library**:
60
+
61
+ ```ruby
62
+ require 'lfsr/fast' # C extesion
63
+
64
+ gen = LFSR::Fast::Size3.new
65
+ gen = LFSR::Size3.new # defaults to the last required generators, in this case Fast
66
+ ```
67
+
68
+ or:
69
+
70
+ ```ruby
71
+ require 'lfsr/pure' # C extesion
72
+
73
+ gen = LFSR::Pure::Size3.new
74
+ gen = LFSR::Size3.new # defaults to the last required generators, in this case Pure
75
+ ```
76
+
77
+ On my system, the performance of LFSR C extension is more than 10X that of the pure ruby version and more than 2X faster than calling rand():
78
+
79
+ Output of scripts/bench:
80
+
81
+ Bits | Pure | C ext | rand | Vs P. | Vs rand
82
+ -----------------------------------------------
83
+ 2 | 0.22s | 0.05s | 0.12s | 4.9X | 2.5X
84
+ 3 | 0.26s | 0.05s | 0.12s | 5.4X | 2.5X
85
+ 4 | 0.32s | 0.05s | 0.12s | 6.5X | 2.4X
86
+ 5 | 0.50s | 0.05s | 0.12s | 9.8X | 2.4X
87
+ 6 | 0.54s | 0.05s | 0.12s | 10.2X | 2.3X
88
+ 7 | 0.55s | 0.05s | 0.12s | 10.4X | 2.3X
89
+ 8 | 0.56s | 0.05s | 0.12s | 10.3X | 2.2X
90
+ 9 | 0.57s | 0.05s | 0.12s | 10.5X | 2.3X
91
+ ... and so on...
92
+
93
+ # Acknowledgements
94
+
95
+ The main shift loop is loosely based on [capricious'](https://raw.github.com/willb/capricious/master/lib/capricious/lfsr.rb).
96
+ The taps table comes from [here](http://home1.gte.net/res0658s/electronics/LFSRtaps.html).
@@ -0,0 +1,67 @@
1
+ require 'date'
2
+ require 'rake/clean'
3
+ require 'rake/extensiontask'
4
+
5
+ task :default => :test
6
+
7
+ # ==========================================================
8
+ # Generate files
9
+ # ==========================================================
10
+
11
+ file "lib/lfsr.rb" => "scripts/genruby.rb" do
12
+ sh "ruby -Iscripts/ scripts/genruby.rb base > lib/lfsr.rb"
13
+ end
14
+
15
+ file "lib/lfsr/pure.rb" => "scripts/genruby.rb" do
16
+ sh "ruby -Iscripts/ scripts/genruby.rb > lib/lfsr/pure.rb"
17
+ end
18
+
19
+ file "ext/lfsr/lfsr.c" => "scripts/genc.rb" do
20
+ sh "ruby -Iscripts/ scripts/genc.rb > ext/lfsr/lfsr.c"
21
+ end
22
+
23
+ desc "Generate files"
24
+ task :generate => ["lib/lfsr.rb", "lib/lfsr/pure.rb", "ext/lfsr/lfsr.c"]
25
+
26
+ # ==========================================================
27
+ # Ruby Extension
28
+ # ==========================================================
29
+
30
+ Rake::ExtensionTask.new('lfsr')
31
+
32
+ task :compile => :generate
33
+
34
+ # ==========================================================
35
+ # Testing
36
+ # ==========================================================
37
+
38
+ require 'rake/testtask'
39
+ Rake::TestTask.new('test') do |t|
40
+ t.test_files = FileList['test/*_test.rb']
41
+ t.ruby_opts += ['-rubygems'] if defined? Gem
42
+ end
43
+ task 'test' => [:compile]
44
+
45
+ # PACKAGING =================================================================
46
+
47
+ require 'rubygems'
48
+ $spec = eval(File.read('lfsr.gemspec'))
49
+
50
+ def package(ext='')
51
+ "pkg/lfsr-#{$spec.version}" + ext
52
+ end
53
+
54
+ desc 'Build packages'
55
+ task :package => package('.gem')
56
+
57
+ desc 'Build and install as local gem'
58
+ task :install => package('.gem') do
59
+ sh "gem install #{package('.gem')}"
60
+ end
61
+
62
+ directory 'pkg/'
63
+
64
+ file package('.gem') => %w[pkg/ lfsr.gemspec] + $spec.files do |f|
65
+ sh "gem build lfsr.gemspec"
66
+ mv File.basename(f.name), f.name
67
+ end
@@ -0,0 +1,38 @@
1
+ require 'lfsr/pure'
2
+
3
+ # The LFSR is 4 bits long, which means can iterate from 0 to 15. (15 == (2**4 - 1))
4
+ # A maximum value of 10 is set though, which means the values returned will be in the range [0, 9]
5
+ # The seed is 1. As long as you use the same seed, the pseudo-random psequence will be the same.
6
+ gen = LFSR::Size4.new 9, 2
7
+
8
+ 10.times do
9
+ print "#{gen.next_i} "
10
+ end
11
+
12
+ puts "\nonce the sequence is complete, it starts again"
13
+
14
+ 10.times do
15
+ print "#{gen.next_i} "
16
+ end
17
+
18
+ puts "\nThe seed can be changed at any time:"
19
+
20
+ gen.reset(0b1011)
21
+
22
+ 10.times do
23
+ print "#{gen.next_i} "
24
+ end
25
+
26
+
27
+ puts
28
+
29
+ gen = LFSR::Size4.new
30
+ rst = []
31
+
32
+ (2**6).times do
33
+ rst << gen.next_i
34
+ end
35
+
36
+ puts rst.sort.uniq.join(" ")
37
+
38
+ puts
@@ -0,0 +1,6 @@
1
+ require 'mkmf'
2
+
3
+ $CFLAGS += ' -O3'
4
+
5
+ dir_config('lfsr')
6
+ create_makefile('lfsr')
@@ -0,0 +1,974 @@
1
+ #include <stdio.h>
2
+ #include "ruby.h"
3
+
4
+ #define bit(n) ((reg & (1 << (n))) >> (n))
5
+ #define RUBY_EXPORT __attribute__ ((visibility ("default")))
6
+
7
+ VALUE rb_lfsr_next_i_2(VALUE self) {
8
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
9
+
10
+ label_shift2:
11
+ reg = (reg >> 1) | ((bit(0)^bit(1)) << 0x1);
12
+ if (reg > max) goto label_shift2;
13
+
14
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
15
+
16
+ return ULL2NUM(reg - 1);
17
+ }
18
+
19
+ VALUE rb_lfsr_next_i_3(VALUE self) {
20
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
21
+
22
+ label_shift3:
23
+ reg = (reg >> 1) | ((bit(0)^bit(1)) << 0x2);
24
+ if (reg > max) goto label_shift3;
25
+
26
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
27
+
28
+ return ULL2NUM(reg - 1);
29
+ }
30
+
31
+ VALUE rb_lfsr_next_i_4(VALUE self) {
32
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
33
+
34
+ label_shift4:
35
+ reg = (reg >> 1) | ((bit(0)^bit(1)) << 0x3);
36
+ if (reg > max) goto label_shift4;
37
+
38
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
39
+
40
+ return ULL2NUM(reg - 1);
41
+ }
42
+
43
+ VALUE rb_lfsr_next_i_5(VALUE self) {
44
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
45
+
46
+ label_shift5:
47
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(3)) << 0x4);
48
+ if (reg > max) goto label_shift5;
49
+
50
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
51
+
52
+ return ULL2NUM(reg - 1);
53
+ }
54
+
55
+ VALUE rb_lfsr_next_i_6(VALUE self) {
56
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
57
+
58
+ label_shift6:
59
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(3)^bit(4)) << 0x5);
60
+ if (reg > max) goto label_shift6;
61
+
62
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
63
+
64
+ return ULL2NUM(reg - 1);
65
+ }
66
+
67
+ VALUE rb_lfsr_next_i_7(VALUE self) {
68
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
69
+
70
+ label_shift7:
71
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(3)) << 0x6);
72
+ if (reg > max) goto label_shift7;
73
+
74
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
75
+
76
+ return ULL2NUM(reg - 1);
77
+ }
78
+
79
+ VALUE rb_lfsr_next_i_8(VALUE self) {
80
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
81
+
82
+ label_shift8:
83
+ reg = (reg >> 1) | ((bit(0)^bit(2)^bit(3)^bit(4)) << 0x7);
84
+ if (reg > max) goto label_shift8;
85
+
86
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
87
+
88
+ return ULL2NUM(reg - 1);
89
+ }
90
+
91
+ VALUE rb_lfsr_next_i_9(VALUE self) {
92
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
93
+
94
+ label_shift9:
95
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(3)^bit(4)) << 0x8);
96
+ if (reg > max) goto label_shift9;
97
+
98
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
99
+
100
+ return ULL2NUM(reg - 1);
101
+ }
102
+
103
+ VALUE rb_lfsr_next_i_10(VALUE self) {
104
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
105
+
106
+ label_shift10:
107
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(3)^bit(4)) << 0x9);
108
+ if (reg > max) goto label_shift10;
109
+
110
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
111
+
112
+ return ULL2NUM(reg - 1);
113
+ }
114
+
115
+ VALUE rb_lfsr_next_i_11(VALUE self) {
116
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
117
+
118
+ label_shift11:
119
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(4)) << 0xa);
120
+ if (reg > max) goto label_shift11;
121
+
122
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
123
+
124
+ return ULL2NUM(reg - 1);
125
+ }
126
+
127
+ VALUE rb_lfsr_next_i_12(VALUE self) {
128
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
129
+
130
+ label_shift12:
131
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(4)^bit(6)) << 0xb);
132
+ if (reg > max) goto label_shift12;
133
+
134
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
135
+
136
+ return ULL2NUM(reg - 1);
137
+ }
138
+
139
+ VALUE rb_lfsr_next_i_13(VALUE self) {
140
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
141
+
142
+ label_shift13:
143
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(3)^bit(4)) << 0xc);
144
+ if (reg > max) goto label_shift13;
145
+
146
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
147
+
148
+ return ULL2NUM(reg - 1);
149
+ }
150
+
151
+ VALUE rb_lfsr_next_i_14(VALUE self) {
152
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
153
+
154
+ label_shift14:
155
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(3)^bit(5)) << 0xd);
156
+ if (reg > max) goto label_shift14;
157
+
158
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
159
+
160
+ return ULL2NUM(reg - 1);
161
+ }
162
+
163
+ VALUE rb_lfsr_next_i_15(VALUE self) {
164
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
165
+
166
+ label_shift15:
167
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(4)) << 0xe);
168
+ if (reg > max) goto label_shift15;
169
+
170
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
171
+
172
+ return ULL2NUM(reg - 1);
173
+ }
174
+
175
+ VALUE rb_lfsr_next_i_16(VALUE self) {
176
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
177
+
178
+ label_shift16:
179
+ reg = (reg >> 1) | ((bit(0)^bit(2)^bit(3)^bit(5)) << 0xf);
180
+ if (reg > max) goto label_shift16;
181
+
182
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
183
+
184
+ return ULL2NUM(reg - 1);
185
+ }
186
+
187
+ VALUE rb_lfsr_next_i_17(VALUE self) {
188
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
189
+
190
+ label_shift17:
191
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(3)) << 0x10);
192
+ if (reg > max) goto label_shift17;
193
+
194
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
195
+
196
+ return ULL2NUM(reg - 1);
197
+ }
198
+
199
+ VALUE rb_lfsr_next_i_18(VALUE self) {
200
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
201
+
202
+ label_shift18:
203
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(5)) << 0x11);
204
+ if (reg > max) goto label_shift18;
205
+
206
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
207
+
208
+ return ULL2NUM(reg - 1);
209
+ }
210
+
211
+ VALUE rb_lfsr_next_i_19(VALUE self) {
212
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
213
+
214
+ label_shift19:
215
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(5)) << 0x12);
216
+ if (reg > max) goto label_shift19;
217
+
218
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
219
+
220
+ return ULL2NUM(reg - 1);
221
+ }
222
+
223
+ VALUE rb_lfsr_next_i_20(VALUE self) {
224
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
225
+
226
+ label_shift20:
227
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(4)^bit(6)) << 0x13);
228
+ if (reg > max) goto label_shift20;
229
+
230
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
231
+
232
+ return ULL2NUM(reg - 1);
233
+ }
234
+
235
+ VALUE rb_lfsr_next_i_21(VALUE self) {
236
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
237
+
238
+ label_shift21:
239
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(5)) << 0x14);
240
+ if (reg > max) goto label_shift21;
241
+
242
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
243
+
244
+ return ULL2NUM(reg - 1);
245
+ }
246
+
247
+ VALUE rb_lfsr_next_i_22(VALUE self) {
248
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
249
+
250
+ label_shift22:
251
+ reg = (reg >> 1) | ((bit(0)^bit(3)^bit(4)^bit(5)) << 0x15);
252
+ if (reg > max) goto label_shift22;
253
+
254
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
255
+
256
+ return ULL2NUM(reg - 1);
257
+ }
258
+
259
+ VALUE rb_lfsr_next_i_23(VALUE self) {
260
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
261
+
262
+ label_shift23:
263
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(3)^bit(5)) << 0x16);
264
+ if (reg > max) goto label_shift23;
265
+
266
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
267
+
268
+ return ULL2NUM(reg - 1);
269
+ }
270
+
271
+ VALUE rb_lfsr_next_i_24(VALUE self) {
272
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
273
+
274
+ label_shift24:
275
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(3)^bit(4)) << 0x17);
276
+ if (reg > max) goto label_shift24;
277
+
278
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
279
+
280
+ return ULL2NUM(reg - 1);
281
+ }
282
+
283
+ VALUE rb_lfsr_next_i_25(VALUE self) {
284
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
285
+
286
+ label_shift25:
287
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(3)) << 0x18);
288
+ if (reg > max) goto label_shift25;
289
+
290
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
291
+
292
+ return ULL2NUM(reg - 1);
293
+ }
294
+
295
+ VALUE rb_lfsr_next_i_26(VALUE self) {
296
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
297
+
298
+ label_shift26:
299
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(6)) << 0x19);
300
+ if (reg > max) goto label_shift26;
301
+
302
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
303
+
304
+ return ULL2NUM(reg - 1);
305
+ }
306
+
307
+ VALUE rb_lfsr_next_i_27(VALUE self) {
308
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
309
+
310
+ label_shift27:
311
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(5)) << 0x1a);
312
+ if (reg > max) goto label_shift27;
313
+
314
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
315
+
316
+ return ULL2NUM(reg - 1);
317
+ }
318
+
319
+ VALUE rb_lfsr_next_i_28(VALUE self) {
320
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
321
+
322
+ label_shift28:
323
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(4)^bit(6)) << 0x1b);
324
+ if (reg > max) goto label_shift28;
325
+
326
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
327
+
328
+ return ULL2NUM(reg - 1);
329
+ }
330
+
331
+ VALUE rb_lfsr_next_i_29(VALUE self) {
332
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
333
+
334
+ label_shift29:
335
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(4)) << 0x1c);
336
+ if (reg > max) goto label_shift29;
337
+
338
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
339
+
340
+ return ULL2NUM(reg - 1);
341
+ }
342
+
343
+ VALUE rb_lfsr_next_i_30(VALUE self) {
344
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
345
+
346
+ label_shift30:
347
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(4)^bit(6)) << 0x1d);
348
+ if (reg > max) goto label_shift30;
349
+
350
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
351
+
352
+ return ULL2NUM(reg - 1);
353
+ }
354
+
355
+ VALUE rb_lfsr_next_i_31(VALUE self) {
356
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
357
+
358
+ label_shift31:
359
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(3)) << 0x1e);
360
+ if (reg > max) goto label_shift31;
361
+
362
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
363
+
364
+ return ULL2NUM(reg - 1);
365
+ }
366
+
367
+ VALUE rb_lfsr_next_i_32(VALUE self) {
368
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
369
+
370
+ label_shift32:
371
+ reg = (reg >> 1) | ((bit(0)^bit(2)^bit(6)^bit(7)) << 0x1f);
372
+ if (reg > max) goto label_shift32;
373
+
374
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
375
+
376
+ return ULL2NUM(reg - 1);
377
+ }
378
+
379
+ VALUE rb_lfsr_next_i_33(VALUE self) {
380
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
381
+
382
+ label_shift33:
383
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(4)^bit(6)) << 0x20);
384
+ if (reg > max) goto label_shift33;
385
+
386
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
387
+
388
+ return ULL2NUM(reg - 1);
389
+ }
390
+
391
+ VALUE rb_lfsr_next_i_34(VALUE self) {
392
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
393
+
394
+ label_shift34:
395
+ reg = (reg >> 1) | ((bit(0)^bit(3)^bit(4)^bit(8)) << 0x21);
396
+ if (reg > max) goto label_shift34;
397
+
398
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
399
+
400
+ return ULL2NUM(reg - 1);
401
+ }
402
+
403
+ VALUE rb_lfsr_next_i_35(VALUE self) {
404
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
405
+
406
+ label_shift35:
407
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(7)^bit(8)) << 0x22);
408
+ if (reg > max) goto label_shift35;
409
+
410
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
411
+
412
+ return ULL2NUM(reg - 1);
413
+ }
414
+
415
+ VALUE rb_lfsr_next_i_36(VALUE self) {
416
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
417
+
418
+ label_shift36:
419
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(7)^bit(8)) << 0x23);
420
+ if (reg > max) goto label_shift36;
421
+
422
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
423
+
424
+ return ULL2NUM(reg - 1);
425
+ }
426
+
427
+ VALUE rb_lfsr_next_i_37(VALUE self) {
428
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
429
+
430
+ label_shift37:
431
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(4)^bit(6)) << 0x24);
432
+ if (reg > max) goto label_shift37;
433
+
434
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
435
+
436
+ return ULL2NUM(reg - 1);
437
+ }
438
+
439
+ VALUE rb_lfsr_next_i_38(VALUE self) {
440
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
441
+
442
+ label_shift38:
443
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(5)^bit(6)) << 0x25);
444
+ if (reg > max) goto label_shift38;
445
+
446
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
447
+
448
+ return ULL2NUM(reg - 1);
449
+ }
450
+
451
+ VALUE rb_lfsr_next_i_39(VALUE self) {
452
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
453
+
454
+ label_shift39:
455
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(4)^bit(7)) << 0x26);
456
+ if (reg > max) goto label_shift39;
457
+
458
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
459
+
460
+ return ULL2NUM(reg - 1);
461
+ }
462
+
463
+ VALUE rb_lfsr_next_i_40(VALUE self) {
464
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
465
+
466
+ label_shift40:
467
+ reg = (reg >> 1) | ((bit(0)^bit(3)^bit(4)^bit(5)) << 0x27);
468
+ if (reg > max) goto label_shift40;
469
+
470
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
471
+
472
+ return ULL2NUM(reg - 1);
473
+ }
474
+
475
+ VALUE rb_lfsr_next_i_41(VALUE self) {
476
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
477
+
478
+ label_shift41:
479
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(3)) << 0x28);
480
+ if (reg > max) goto label_shift41;
481
+
482
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
483
+
484
+ return ULL2NUM(reg - 1);
485
+ }
486
+
487
+ VALUE rb_lfsr_next_i_42(VALUE self) {
488
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
489
+
490
+ label_shift42:
491
+ reg = (reg >> 1) | ((bit(0)^bit(2)^bit(5)^bit(7)) << 0x29);
492
+ if (reg > max) goto label_shift42;
493
+
494
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
495
+
496
+ return ULL2NUM(reg - 1);
497
+ }
498
+
499
+ VALUE rb_lfsr_next_i_43(VALUE self) {
500
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
501
+
502
+ label_shift43:
503
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(5)^bit(6)) << 0x2a);
504
+ if (reg > max) goto label_shift43;
505
+
506
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
507
+
508
+ return ULL2NUM(reg - 1);
509
+ }
510
+
511
+ VALUE rb_lfsr_next_i_44(VALUE self) {
512
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
513
+
514
+ label_shift44:
515
+ reg = (reg >> 1) | ((bit(0)^bit(2)^bit(5)^bit(6)) << 0x2b);
516
+ if (reg > max) goto label_shift44;
517
+
518
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
519
+
520
+ return ULL2NUM(reg - 1);
521
+ }
522
+
523
+ VALUE rb_lfsr_next_i_45(VALUE self) {
524
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
525
+
526
+ label_shift45:
527
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(3)^bit(4)) << 0x2c);
528
+ if (reg > max) goto label_shift45;
529
+
530
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
531
+
532
+ return ULL2NUM(reg - 1);
533
+ }
534
+
535
+ VALUE rb_lfsr_next_i_46(VALUE self) {
536
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
537
+
538
+ label_shift46:
539
+ reg = (reg >> 1) | ((bit(0)^bit(6)^bit(7)^bit(8)) << 0x2d);
540
+ if (reg > max) goto label_shift46;
541
+
542
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
543
+
544
+ return ULL2NUM(reg - 1);
545
+ }
546
+
547
+ VALUE rb_lfsr_next_i_47(VALUE self) {
548
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
549
+
550
+ label_shift47:
551
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(4)^bit(5)) << 0x2e);
552
+ if (reg > max) goto label_shift47;
553
+
554
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
555
+
556
+ return ULL2NUM(reg - 1);
557
+ }
558
+
559
+ VALUE rb_lfsr_next_i_48(VALUE self) {
560
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
561
+
562
+ label_shift48:
563
+ reg = (reg >> 1) | ((bit(0)^bit(4)^bit(7)^bit(9)) << 0x2f);
564
+ if (reg > max) goto label_shift48;
565
+
566
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
567
+
568
+ return ULL2NUM(reg - 1);
569
+ }
570
+
571
+ VALUE rb_lfsr_next_i_49(VALUE self) {
572
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
573
+
574
+ label_shift49:
575
+ reg = (reg >> 1) | ((bit(0)^bit(4)^bit(5)^bit(6)) << 0x30);
576
+ if (reg > max) goto label_shift49;
577
+
578
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
579
+
580
+ return ULL2NUM(reg - 1);
581
+ }
582
+
583
+ VALUE rb_lfsr_next_i_50(VALUE self) {
584
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
585
+
586
+ label_shift50:
587
+ reg = (reg >> 1) | ((bit(0)^bit(2)^bit(3)^bit(4)) << 0x31);
588
+ if (reg > max) goto label_shift50;
589
+
590
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
591
+
592
+ return ULL2NUM(reg - 1);
593
+ }
594
+
595
+ VALUE rb_lfsr_next_i_51(VALUE self) {
596
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
597
+
598
+ label_shift51:
599
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(3)^bit(6)) << 0x32);
600
+ if (reg > max) goto label_shift51;
601
+
602
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
603
+
604
+ return ULL2NUM(reg - 1);
605
+ }
606
+
607
+ VALUE rb_lfsr_next_i_52(VALUE self) {
608
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
609
+
610
+ label_shift52:
611
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(3)^bit(6)) << 0x33);
612
+ if (reg > max) goto label_shift52;
613
+
614
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
615
+
616
+ return ULL2NUM(reg - 1);
617
+ }
618
+
619
+ VALUE rb_lfsr_next_i_53(VALUE self) {
620
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
621
+
622
+ label_shift53:
623
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(6)) << 0x34);
624
+ if (reg > max) goto label_shift53;
625
+
626
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
627
+
628
+ return ULL2NUM(reg - 1);
629
+ }
630
+
631
+ VALUE rb_lfsr_next_i_54(VALUE self) {
632
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
633
+
634
+ label_shift54:
635
+ reg = (reg >> 1) | ((bit(0)^bit(3)^bit(6)^bit(8)) << 0x35);
636
+ if (reg > max) goto label_shift54;
637
+
638
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
639
+
640
+ return ULL2NUM(reg - 1);
641
+ }
642
+
643
+ VALUE rb_lfsr_next_i_55(VALUE self) {
644
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
645
+
646
+ label_shift55:
647
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(6)) << 0x36);
648
+ if (reg > max) goto label_shift55;
649
+
650
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
651
+
652
+ return ULL2NUM(reg - 1);
653
+ }
654
+
655
+ VALUE rb_lfsr_next_i_56(VALUE self) {
656
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
657
+
658
+ label_shift56:
659
+ reg = (reg >> 1) | ((bit(0)^bit(2)^bit(4)^bit(7)) << 0x37);
660
+ if (reg > max) goto label_shift56;
661
+
662
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
663
+
664
+ return ULL2NUM(reg - 1);
665
+ }
666
+
667
+ VALUE rb_lfsr_next_i_57(VALUE self) {
668
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
669
+
670
+ label_shift57:
671
+ reg = (reg >> 1) | ((bit(0)^bit(2)^bit(3)^bit(5)) << 0x38);
672
+ if (reg > max) goto label_shift57;
673
+
674
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
675
+
676
+ return ULL2NUM(reg - 1);
677
+ }
678
+
679
+ VALUE rb_lfsr_next_i_58(VALUE self) {
680
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
681
+
682
+ label_shift58:
683
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(5)^bit(6)) << 0x39);
684
+ if (reg > max) goto label_shift58;
685
+
686
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
687
+
688
+ return ULL2NUM(reg - 1);
689
+ }
690
+
691
+ VALUE rb_lfsr_next_i_59(VALUE self) {
692
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
693
+
694
+ label_shift59:
695
+ reg = (reg >> 1) | ((bit(0)^bit(2)^bit(4)^bit(7)) << 0x3a);
696
+ if (reg > max) goto label_shift59;
697
+
698
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
699
+
700
+ return ULL2NUM(reg - 1);
701
+ }
702
+
703
+ VALUE rb_lfsr_next_i_60(VALUE self) {
704
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
705
+
706
+ label_shift60:
707
+ reg = (reg >> 1) | ((bit(0)^bit(2)^bit(4)^bit(5)) << 0x3b);
708
+ if (reg > max) goto label_shift60;
709
+
710
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
711
+
712
+ return ULL2NUM(reg - 1);
713
+ }
714
+
715
+ VALUE rb_lfsr_next_i_61(VALUE self) {
716
+ unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);
717
+
718
+ label_shift61:
719
+ reg = (reg >> 1) | ((bit(0)^bit(1)^bit(2)^bit(5)) << 0x3c);
720
+ if (reg > max) goto label_shift61;
721
+
722
+ ROBJECT(self)->as.ary[0] = ULL2NUM(reg);
723
+
724
+ return ULL2NUM(reg - 1);
725
+ }
726
+
727
+
728
+ void RUBY_EXPORT Init_lfsr() {
729
+ VALUE rb_mLFSR = rb_const_get(rb_cObject, rb_intern("LFSR"));
730
+ VALUE rb_cLFSR_Base = rb_const_get(rb_mLFSR, rb_intern("Base"));
731
+ VALUE rb_mLFSR_Fast = rb_define_module_under(rb_mLFSR, "Fast");
732
+
733
+ VALUE rb_cLFSR_SubClass;
734
+
735
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size2", rb_cLFSR_Base);
736
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_2, 0);
737
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3LLU));
738
+
739
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size3", rb_cLFSR_Base);
740
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_3, 0);
741
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7LLU));
742
+
743
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size4", rb_cLFSR_Base);
744
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_4, 0);
745
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xfLLU));
746
+
747
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size5", rb_cLFSR_Base);
748
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_5, 0);
749
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1fLLU));
750
+
751
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size6", rb_cLFSR_Base);
752
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_6, 0);
753
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3fLLU));
754
+
755
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size7", rb_cLFSR_Base);
756
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_7, 0);
757
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7fLLU));
758
+
759
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size8", rb_cLFSR_Base);
760
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_8, 0);
761
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xffLLU));
762
+
763
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size9", rb_cLFSR_Base);
764
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_9, 0);
765
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1ffLLU));
766
+
767
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size10", rb_cLFSR_Base);
768
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_10, 0);
769
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3ffLLU));
770
+
771
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size11", rb_cLFSR_Base);
772
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_11, 0);
773
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7ffLLU));
774
+
775
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size12", rb_cLFSR_Base);
776
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_12, 0);
777
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xfffLLU));
778
+
779
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size13", rb_cLFSR_Base);
780
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_13, 0);
781
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1fffLLU));
782
+
783
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size14", rb_cLFSR_Base);
784
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_14, 0);
785
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3fffLLU));
786
+
787
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size15", rb_cLFSR_Base);
788
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_15, 0);
789
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7fffLLU));
790
+
791
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size16", rb_cLFSR_Base);
792
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_16, 0);
793
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xffffLLU));
794
+
795
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size17", rb_cLFSR_Base);
796
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_17, 0);
797
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1ffffLLU));
798
+
799
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size18", rb_cLFSR_Base);
800
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_18, 0);
801
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3ffffLLU));
802
+
803
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size19", rb_cLFSR_Base);
804
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_19, 0);
805
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7ffffLLU));
806
+
807
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size20", rb_cLFSR_Base);
808
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_20, 0);
809
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xfffffLLU));
810
+
811
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size21", rb_cLFSR_Base);
812
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_21, 0);
813
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1fffffLLU));
814
+
815
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size22", rb_cLFSR_Base);
816
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_22, 0);
817
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3fffffLLU));
818
+
819
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size23", rb_cLFSR_Base);
820
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_23, 0);
821
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7fffffLLU));
822
+
823
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size24", rb_cLFSR_Base);
824
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_24, 0);
825
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xffffffLLU));
826
+
827
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size25", rb_cLFSR_Base);
828
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_25, 0);
829
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1ffffffLLU));
830
+
831
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size26", rb_cLFSR_Base);
832
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_26, 0);
833
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3ffffffLLU));
834
+
835
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size27", rb_cLFSR_Base);
836
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_27, 0);
837
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7ffffffLLU));
838
+
839
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size28", rb_cLFSR_Base);
840
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_28, 0);
841
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xfffffffLLU));
842
+
843
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size29", rb_cLFSR_Base);
844
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_29, 0);
845
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1fffffffLLU));
846
+
847
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size30", rb_cLFSR_Base);
848
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_30, 0);
849
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3fffffffLLU));
850
+
851
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size31", rb_cLFSR_Base);
852
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_31, 0);
853
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7fffffffLLU));
854
+
855
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size32", rb_cLFSR_Base);
856
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_32, 0);
857
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xffffffffLLU));
858
+
859
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size33", rb_cLFSR_Base);
860
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_33, 0);
861
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1ffffffffLLU));
862
+
863
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size34", rb_cLFSR_Base);
864
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_34, 0);
865
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3ffffffffLLU));
866
+
867
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size35", rb_cLFSR_Base);
868
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_35, 0);
869
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7ffffffffLLU));
870
+
871
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size36", rb_cLFSR_Base);
872
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_36, 0);
873
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xfffffffffLLU));
874
+
875
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size37", rb_cLFSR_Base);
876
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_37, 0);
877
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1fffffffffLLU));
878
+
879
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size38", rb_cLFSR_Base);
880
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_38, 0);
881
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3fffffffffLLU));
882
+
883
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size39", rb_cLFSR_Base);
884
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_39, 0);
885
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7fffffffffLLU));
886
+
887
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size40", rb_cLFSR_Base);
888
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_40, 0);
889
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xffffffffffLLU));
890
+
891
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size41", rb_cLFSR_Base);
892
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_41, 0);
893
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1ffffffffffLLU));
894
+
895
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size42", rb_cLFSR_Base);
896
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_42, 0);
897
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3ffffffffffLLU));
898
+
899
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size43", rb_cLFSR_Base);
900
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_43, 0);
901
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7ffffffffffLLU));
902
+
903
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size44", rb_cLFSR_Base);
904
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_44, 0);
905
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xfffffffffffLLU));
906
+
907
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size45", rb_cLFSR_Base);
908
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_45, 0);
909
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1fffffffffffLLU));
910
+
911
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size46", rb_cLFSR_Base);
912
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_46, 0);
913
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3fffffffffffLLU));
914
+
915
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size47", rb_cLFSR_Base);
916
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_47, 0);
917
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7fffffffffffLLU));
918
+
919
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size48", rb_cLFSR_Base);
920
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_48, 0);
921
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xffffffffffffLLU));
922
+
923
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size49", rb_cLFSR_Base);
924
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_49, 0);
925
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1ffffffffffffLLU));
926
+
927
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size50", rb_cLFSR_Base);
928
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_50, 0);
929
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3ffffffffffffLLU));
930
+
931
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size51", rb_cLFSR_Base);
932
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_51, 0);
933
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7ffffffffffffLLU));
934
+
935
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size52", rb_cLFSR_Base);
936
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_52, 0);
937
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xfffffffffffffLLU));
938
+
939
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size53", rb_cLFSR_Base);
940
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_53, 0);
941
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1fffffffffffffLLU));
942
+
943
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size54", rb_cLFSR_Base);
944
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_54, 0);
945
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3fffffffffffffLLU));
946
+
947
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size55", rb_cLFSR_Base);
948
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_55, 0);
949
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7fffffffffffffLLU));
950
+
951
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size56", rb_cLFSR_Base);
952
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_56, 0);
953
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xffffffffffffffLLU));
954
+
955
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size57", rb_cLFSR_Base);
956
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_57, 0);
957
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1ffffffffffffffLLU));
958
+
959
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size58", rb_cLFSR_Base);
960
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_58, 0);
961
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x3ffffffffffffffLLU));
962
+
963
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size59", rb_cLFSR_Base);
964
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_59, 0);
965
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x7ffffffffffffffLLU));
966
+
967
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size60", rb_cLFSR_Base);
968
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_60, 0);
969
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0xfffffffffffffffLLU));
970
+
971
+ rb_cLFSR_SubClass = rb_define_class_under(rb_mLFSR_Fast, "Size61", rb_cLFSR_Base);
972
+ rb_define_method(rb_cLFSR_SubClass, "next_i", rb_lfsr_next_i_61, 0);
973
+ rb_define_const(rb_cLFSR_SubClass, "MASK", ULL2NUM(0x1fffffffffffffffLLU));
974
+ }