quasi 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metadata +42 -28
- data/Manifest +0 -7
- data/Rakefile +0 -26
- data/lib/LowDiscrepancySequence.rb +0 -164
- data/lib/NX.rb +0 -1385
- data/lib/halton.rb +0 -93
- data/lib/quasi.rb +0 -18
- data/quasi.gemspec +0 -30
data/lib/halton.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'narray'
|
3
|
-
|
4
|
-
require 'LowDiscrepancySequence'
|
5
|
-
include Math
|
6
|
-
|
7
|
-
#halton
|
8
|
-
module Quasi
|
9
|
-
|
10
|
-
class Halton < LowDiscrepancySequence
|
11
|
-
|
12
|
-
def initialize(dim)
|
13
|
-
super(dim)
|
14
|
-
compute_primes()
|
15
|
-
@x=NArray.float(dim)
|
16
|
-
end
|
17
|
-
|
18
|
-
def compute_primes()
|
19
|
-
@prime= NArray.int(@dim)
|
20
|
-
@prime[0]=2
|
21
|
-
if(@dim>1)
|
22
|
-
@prime[1]=3
|
23
|
-
end
|
24
|
-
|
25
|
-
if(@dim>2)
|
26
|
-
@prime[2]=5
|
27
|
-
end
|
28
|
-
|
29
|
-
for j in 3..@dim
|
30
|
-
q=@prime[j-1]+2
|
31
|
-
while !isPrime(q) do
|
32
|
-
q+=1
|
33
|
-
end
|
34
|
-
@prime[j]=q
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
def isPrime(q)
|
40
|
-
is_prime=false
|
41
|
-
m=Math.sqrt(q).to_int
|
42
|
-
i=0
|
43
|
-
p=@prime[i]
|
44
|
-
|
45
|
-
while(p<=m) do
|
46
|
-
if(q%p==0)
|
47
|
-
return false
|
48
|
-
end
|
49
|
-
i+=1
|
50
|
-
p=@prime[i]
|
51
|
-
end
|
52
|
-
return true
|
53
|
-
end
|
54
|
-
|
55
|
-
#THE HALTON POINTS
|
56
|
-
|
57
|
-
def point(n,s)
|
58
|
-
p=@prime[s]
|
59
|
-
x,f = 0.0,1.0
|
60
|
-
|
61
|
-
while (n>0)
|
62
|
-
f/=p
|
63
|
-
x+=(n%p)*f
|
64
|
-
n=n/p
|
65
|
-
end
|
66
|
-
|
67
|
-
return x
|
68
|
-
end
|
69
|
-
|
70
|
-
def pointO(n)
|
71
|
-
x=Array.new(@dim)
|
72
|
-
for s in 0..@dim-1 #@dim-1 here
|
73
|
-
x[s]=point(n,s)
|
74
|
-
end
|
75
|
-
return x
|
76
|
-
end
|
77
|
-
|
78
|
-
def nextPoint
|
79
|
-
n=@index
|
80
|
-
@index+=1
|
81
|
-
return pointO(n)
|
82
|
-
end
|
83
|
-
|
84
|
-
def getName
|
85
|
-
return "Halton Sequence"
|
86
|
-
end
|
87
|
-
|
88
|
-
end #end of class
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end #end module
|
93
|
-
|
data/lib/quasi.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
$:.unshift File.expand_path(File.dirname(__FILE__))
|
2
|
-
|
3
|
-
require 'extensions/fixnum'
|
4
|
-
require 'extensions/nil_class'
|
5
|
-
require 'extensions/string'
|
6
|
-
|
7
|
-
require 'LowDiscrepancySequence'
|
8
|
-
require 'halton'
|
9
|
-
require 'NX'
|
10
|
-
|
11
|
-
module Quasi
|
12
|
-
VERSION = '0.0.1'
|
13
|
-
|
14
|
-
|
15
|
-
def self.version
|
16
|
-
VERSION
|
17
|
-
end
|
18
|
-
end
|
data/quasi.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{quasi}
|
5
|
-
s.version = "0.0.1"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Thomas Adolfsson"]
|
9
|
-
s.date = %q{2010-09-15}
|
10
|
-
s.description = %q{A gem for Low Discrepancy Sequences}
|
11
|
-
s.email = %q{thoad747@gmail.com}
|
12
|
-
s.extra_rdoc_files = ["lib/LowDiscrepancySequence.rb", "lib/NX.rb", "lib/halton.rb", "lib/quasi.rb"]
|
13
|
-
s.files = ["Manifest", "Rakefile", "lib/LowDiscrepancySequence.rb", "lib/NX.rb", "lib/halton.rb", "lib/quasi.rb", "quasi.gemspec"]
|
14
|
-
s.homepage = %q{http://gammabox.heroku.com}
|
15
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Quasi"]
|
16
|
-
s.require_paths = ["lib"]
|
17
|
-
s.rubyforge_project = %q{quasi}
|
18
|
-
s.rubygems_version = %q{1.3.7}
|
19
|
-
s.summary = %q{A gem for Low Discrepancy Sequences}
|
20
|
-
|
21
|
-
if s.respond_to? :specification_version then
|
22
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
-
s.specification_version = 3
|
24
|
-
|
25
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
-
else
|
27
|
-
end
|
28
|
-
else
|
29
|
-
end
|
30
|
-
end
|