halton 0.2.1.4-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7d052de097032cb9af5367b72eda195bde6f615616a04479c05cb6564390c8a0
4
+ data.tar.gz: 51b081e2aa2b7d316dd423627b0bdfe5111f28c11a75082df536239ec2b8b11b
5
+ SHA512:
6
+ metadata.gz: '00893d4176a20572ec99c79efd76b57443d82545d3d003f2529a6d5cfafb3354ece10c33e7f24547aa682521853edb09e952437ab06dc28c3c526c171f12cf25'
7
+ data.tar.gz: e5c921fe9bf0c1ee73e284fd99e6235a603d3b8babe3bb9b96e7b55119c352991dbaf2dc1c7074b62602c746d7179eb5cf692417b8508f871697fbe6716a22f2
data/README.rdoc ADDED
@@ -0,0 +1,45 @@
1
+ = Halton
2
+
3
+ A Ruby library for the fast generation of Halton sequences, a deterministic low
4
+ discrepancy sequence that appears to be random. The uniform distribution and
5
+ repeatability makes the sequence ideal for choosing sample points or placing
6
+ objects in 2D or 3D space.
7
+
8
+ grid = 10.times.map {10.times.map {"."}}
9
+ Halton.each(2, 3).take(26).zip("A".."Z") do |(x, y), c|
10
+ grid[y * 10][x * 10] = c
11
+ end
12
+ grid.each {|row| puts row.join(" ")}
13
+
14
+ Outputs:
15
+
16
+ . . R . . I . . . .
17
+ . L . . . . U C . .
18
+ X . . F . . . . . O
19
+ . . . J . A . . . .
20
+ . D . . . . M S . .
21
+ P . . . V . . . G .
22
+ . . B . . Y . . . .
23
+ . T . . . . E . K .
24
+ H . . . N . . . . W
25
+ . . . Z . Q . . . .
26
+
27
+ The method of generation is adapted from "Fast, portable, and reliable
28
+ algorithm for the calculation of Halton numbers" by Miroslav Kolář and Seamus F.
29
+ O'Shea.
30
+
31
+ == Install
32
+
33
+ Install via Rubygems:
34
+
35
+ gem install halton
36
+
37
+ or add it to your Gemfile if you're using Bundler:
38
+
39
+ gem "halton"
40
+
41
+ and then run the bundle command to install.
42
+
43
+ This gem requires a Rust compiler and the +cargo+ build tool to build the gem's
44
+ native extension. See https://www.rust-lang.org/tools/install for how to
45
+ install Rust. +cargo+ is usually part of the Rust installation.
Binary file
Binary file
Binary file
data/lib/halton.rb ADDED
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ /(?<ruby_version>\d+\.\d+)/ =~ RUBY_VERSION
5
+ require_relative "halton/#{ruby_version}/halton"
6
+ rescue LoadError
7
+ require_relative "halton/halton"
8
+ end
9
+
10
+ # The Halton module provides methods for generating Halton sequences, a
11
+ # deterministic low discrepancy sequence that appears to be random. The uniform
12
+ # distribution and repeatability makes the sequence ideal for choosing sample
13
+ # points or placing objects in 2D or 3D space.
14
+ #
15
+ # grid = 10.times.map {10.times.map {"."}}
16
+ # Halton.each(2, 3).take(26).zip("A".."Z") do |(x, y), c|
17
+ # grid[y * 10][x * 10] = c
18
+ # end
19
+ # grid.each {|row| puts row.join(" ")}
20
+ #
21
+ # Outputs:
22
+ #
23
+ # . . R . . I . . . .
24
+ # . L . . . . U C . .
25
+ # X . . F . . . . . O
26
+ # . . . J . A . . . .
27
+ # . D . . . . M S . .
28
+ # P . . . V . . . G .
29
+ # . . B . . Y . . . .
30
+ # . T . . . . E . K .
31
+ # H . . . N . . . . W
32
+ # . . . Z . Q . . . .
33
+ #
34
+ module Halton
35
+
36
+ ##
37
+ # :singleton-method: number
38
+ # :call-seq: Halton.number(base, index) -> int
39
+ #
40
+ # Returns the number at +index+ of the Halton sequence for +base+. The number
41
+ # returned will be > 0 and < 1, assuming +index+ > 1.
42
+ #
43
+ # While #each will be faster for most cases, this function may be
44
+ # useful for calulating a single number from a Halton sequence, or creating
45
+ # a 'leaped' sequence.
46
+ #
47
+ # 'leaped' Halton sequence:
48
+ #
49
+ # step = 409;
50
+ # i = 1;
51
+ # while i < 10 * step
52
+ # puts Halton.number(17, i)
53
+ # i += step
54
+ # end
55
+ #
56
+ # Beware that indexing #each is effectively 0-based, whereas the
57
+ # `index` argument for [`number`] is 1-based.
58
+ #
59
+ # Halton.each(2).take(10)[2] #=> 0.75
60
+ # Halton.number(2, 3) #=> 0.75
61
+
62
+ # :call-seq:
63
+ # Halton.each(base) {|n| ... }
64
+ # Halton.each(base_x, base_y) {|x, y| ... }
65
+ # Halton.each(base_x, base_y, base_z) {|x, y, z| ... }
66
+ # Halton.each(*bases) {|*n| ... }
67
+ # Halton.each(*bases) -> Enumerator
68
+ #
69
+ # Implements the fast generation of Halton sequences.
70
+ # The method of generation is adapted from "Fast, portable, and reliable
71
+ # algorithm for the calculation of Halton numbers" by Miroslav Kolář and
72
+ # Seamus F. O'Shea.
73
+ #
74
+ # The numbers yielded will be in the range > 0 and < 1.
75
+ #
76
+ def self.each(base, *bases, &block)
77
+ case bases.length
78
+ when 0
79
+ each_one(base, &block)
80
+ when 1
81
+ each_pair(base, bases.first, &block)
82
+ when 2
83
+ each_triple(base, bases.first, bases.last, &block)
84
+ else
85
+ each_many(*bases.unshift(base), &block)
86
+ end
87
+ end
88
+
89
+ # Halton::Sequence implements the fast generation of Halton sequences.
90
+ # The method of generation is adapted from "Fast, portable, and reliable
91
+ # algorithm for the calculation of Halton numbers" by Miroslav Kolář and
92
+ # Seamus F. O'Shea.
93
+ #
94
+ # This class is implemented as a stateful iterator, a pattern not common in
95
+ # Ruby. The Halton::each method provides a more friendly interface to this
96
+ # class.
97
+ #
98
+ class Sequence
99
+
100
+ ##
101
+ # :singleton-method: new
102
+ # :call-seq: Sequence.new(base) -> sequence
103
+ #
104
+ # Create a new Halton::Sequence.
105
+
106
+ ##
107
+ # :method: next
108
+ # :call-seq: sequence.next -> int
109
+ #
110
+ # Get the next number in the sequence. The numbers will be in the range > 0
111
+ # and < 1.
112
+ #
113
+ # Will raise StopIteration when the sequence has ended.
114
+
115
+ ##
116
+ # :method: skip
117
+ # :call-seq: sequence.skip(n) -> nil
118
+ #
119
+ # Can be used to efficiently skip large sections of the sequence. For small
120
+ # values of +n+ simply advances the sequence +n+ times.
121
+
122
+ ##
123
+ # :method: remaining
124
+ # :call-seq: sequence.remaining -> int or nil
125
+ #
126
+ # Returns the count of the remaining numbers in the sequence. May return
127
+ # +nil+ if the count is larger than the host platform's native unsigned
128
+ # integer type.
129
+
130
+ end
131
+
132
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: halton
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1.4
5
+ platform: x86_64-linux
6
+ authors:
7
+ - Mat Sadler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rb_sys
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.46
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.46
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ description: A module implementing the fast generation of Halton sequences. The method
56
+ of generation is adapted from "Fast, portable, and reliable algorithm for the calculation
57
+ of Halton number" by Miroslav Kolář and Seamus F. O'Shea.
58
+ email:
59
+ - mat@sourcetagsandcodes.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files:
63
+ - README.rdoc
64
+ files:
65
+ - README.rdoc
66
+ - lib/halton.rb
67
+ - lib/halton/2.7/halton.so
68
+ - lib/halton/3.0/halton.so
69
+ - lib/halton/3.1/halton.so
70
+ homepage: https://github.com/matsadler/halton-rb
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options:
76
+ - "--main"
77
+ - README.rdoc
78
+ - "--charset"
79
+ - utf-8
80
+ - "--exclude"
81
+ - ext/
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '2.7'
89
+ - - "<"
90
+ - !ruby/object:Gem::Version
91
+ version: 3.2.dev
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements:
98
+ - Rust >= 1.51.0
99
+ rubygems_version: 3.3.22
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: A module for generating Halton sequences
103
+ test_files: []