RubMat 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rubmat +10 -6
- data/lib/librbdiscrete.rb +1 -2
- data/lib/main.rb +114 -38
- metadata +27 -14
data/bin/rubmat
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# AUTHOR: Mahmut Bulut
|
4
3
|
require 'rubygems'
|
5
4
|
require 'bundler/setup'
|
5
|
+
Dir[File.dirname(__FILE__) + '/lib/*.rb'].each {|file| require file }
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
require '
|
10
|
-
require
|
7
|
+
# AUTHOR: Mahmut Bulut
|
8
|
+
#$LOAD_PATH.unshift File.dirname(__FILE__)
|
9
|
+
#require File.dirname(__FILE__) + '/lib/librbdiscrete.rb'
|
10
|
+
#require File.expand_path(File.join(File.dirname(__FILE__)))
|
11
|
+
#require 'librbdiscrete'
|
12
|
+
#require 'fixnumexpand'
|
13
|
+
#require 'commander'
|
14
|
+
#require 'help'
|
11
15
|
|
12
16
|
puts "===RubMat===
|
13
17
|
Copyright (C) <2011> <Mahmut Bulut>
|
@@ -122,4 +126,4 @@ command = ask(">=> ")
|
|
122
126
|
exp = ask("Enter power value: ", Integer)
|
123
127
|
puts ui_pow(base, exp)
|
124
128
|
end
|
125
|
-
end until(command == 'exit')
|
129
|
+
end until(command == 'exit')
|
data/lib/librbdiscrete.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
require 'yaml'
|
4
3
|
#constants1 = YAML::load_file('statics.yml')
|
5
4
|
|
6
5
|
EVALUE = 2.718281828459045235360287471352662497757247093
|
@@ -269,7 +268,7 @@ Underly array for printing.
|
|
269
268
|
def print_row(binary, size, low, mid, high)
|
270
269
|
for i in 0..size-1
|
271
270
|
if (i <low || i > high)
|
272
|
-
print
|
271
|
+
print " "
|
273
272
|
end
|
274
273
|
if(i == mid)
|
275
274
|
puts binary[i]
|
data/lib/main.rb
CHANGED
@@ -1,49 +1,125 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# AUTHOR:
|
4
|
-
|
5
|
-
require '
|
6
|
-
require
|
7
|
-
require '
|
3
|
+
# AUTHOR: Mahmut Bulut
|
4
|
+
#$LOAD_PATH.unshift File.dirname(__FILE__)
|
5
|
+
#require File.dirname(__FILE__) + '/lib/librbdiscrete.rb'
|
6
|
+
#require File.expand_path(File.join(File.dirname(__FILE__)))
|
7
|
+
require 'librbdiscrete'
|
8
|
+
require 'fixnumexpand'
|
9
|
+
require 'commander'
|
10
|
+
require 'help'
|
8
11
|
|
9
12
|
puts "===RubMat===
|
10
|
-
Copyright (C) <2011> <
|
13
|
+
Copyright (C) <2011> <Mahmut Bulut>
|
11
14
|
This program comes with ABSOLUTELY NO WARRANTY; for details type 'help'.
|
12
15
|
This is free software, and you are welcome to redistribute it
|
13
16
|
under certain conditions; type `certain' for details."
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def commfail
|
21
|
-
# Raise exceptions from fail situation and gives new command_line
|
22
|
-
end
|
23
|
-
|
24
|
-
class GetOpt
|
25
|
-
def command_line
|
26
|
-
print ">=> "
|
27
|
-
comm = gets
|
28
|
-
commnd = comm.chomp
|
29
|
-
puts ""
|
30
|
-
end
|
31
|
-
def clearscr
|
32
|
-
# Clears screen
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
def inspect
|
17
|
+
puts ""
|
18
|
+
begin
|
19
|
+
command = ask(">=> ")
|
20
|
+
#command = commn.chomp!
|
39
21
|
# Read arguments and defines commands
|
40
22
|
# Will handle command line whitespaces
|
41
23
|
|
42
|
-
if (
|
43
|
-
|
24
|
+
if (command == 'help')
|
25
|
+
puts help()
|
44
26
|
end
|
45
|
-
if (
|
46
|
-
|
27
|
+
if (command == 'certain')
|
28
|
+
puts "To see certain conditions please visit http://www.gnu.org/licenses/gpl-2.0.html#SEC3"
|
47
29
|
end
|
48
|
-
|
49
|
-
|
30
|
+
if (command == 'factorial')
|
31
|
+
n = ask("Enter N value: ", Integer)
|
32
|
+
puts factorial(n)
|
33
|
+
end
|
34
|
+
if (command == 'binsearch')
|
35
|
+
begin
|
36
|
+
binary = ask("Enter array name with [ & ] suffix: ")
|
37
|
+
size = ask("Enter size of search range: ", Integer)
|
38
|
+
search_key = ask("Enter search delimiter key", Integer)
|
39
|
+
low = ask("Lower limit: ", Integer)
|
40
|
+
middle = ask("Medium limit: ", Integer)
|
41
|
+
high = ask("High limit: ", Integer)
|
42
|
+
puts binary_search(binary, size, search_key, low, middle, high)
|
43
|
+
rescue => error
|
44
|
+
puts error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
if (command == 'birdseye')
|
48
|
+
n = ask("Enter workspace mass number: ", Integer)
|
49
|
+
k = ask("Enter selection mass number: ", Integer)
|
50
|
+
puts birds_eye(n, k)
|
51
|
+
end
|
52
|
+
if (command == 'combinatorial')
|
53
|
+
glb = ask("Enter global set objects number: ", Integer)
|
54
|
+
ksb = ask("Enter k-subset objects number: ", Integer)
|
55
|
+
puts combinatorial(glb, ksb)
|
56
|
+
end
|
57
|
+
if (command == 'distpres')
|
58
|
+
presnum = ask("Present number: ", Integer)
|
59
|
+
puts dist_pres(presnum)
|
60
|
+
end
|
61
|
+
if (command == 'eagleview')
|
62
|
+
m = ask("Enter m value: ", Integer)
|
63
|
+
t = ask("Enter t value: ", Integer)
|
64
|
+
puts eagle_view(m, t)
|
65
|
+
end
|
66
|
+
if (command == 'fermatlittle')
|
67
|
+
p = ans("Enter power number: ", Integer)
|
68
|
+
a = ans("Enter base number:", Integer)
|
69
|
+
puts fermat_little(p, a)
|
70
|
+
end
|
71
|
+
if (command == 'fib')
|
72
|
+
n = ans("Enter the last incremental number: ", Integer)
|
73
|
+
puts fib(n)
|
74
|
+
end
|
75
|
+
if (command == 'isprime')
|
76
|
+
raise RuntimeError.new("Have some critical issues closed to next minor version")
|
77
|
+
# nb = ask("Control number: ", Integer)
|
78
|
+
# puts is_prime(nb)
|
79
|
+
end
|
80
|
+
if (command == 'iterativefact')
|
81
|
+
begin
|
82
|
+
itrtnum = ask("Enter the factorial input: ", Integer)
|
83
|
+
throw :ball if (itrtnum >= MAX_INTEGER)
|
84
|
+
puts iterative_fact(itrtnum)
|
85
|
+
end
|
86
|
+
catch(:ball) do
|
87
|
+
raise ArgumentError.new("iterative factorial couldn't take this value's load. Terminated.")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
if (command == 'sigma')
|
91
|
+
inta = ask("Enter a value: ", Integer)
|
92
|
+
intx = ask("Enter x value: ", Integer)
|
93
|
+
intb = ask("Enter b value: ", Integer)
|
94
|
+
pw = ask("Enter power value: ", Integer)
|
95
|
+
puts sigma(inta, intx, intb, pw)
|
96
|
+
end
|
97
|
+
if (command == 'stirling')
|
98
|
+
begin
|
99
|
+
strln = ask("Enter stirling procedure value: ", Integer)
|
100
|
+
throw :glass if (strln >= MAX_INTEGER)
|
101
|
+
puts stirling(strln)
|
102
|
+
end
|
103
|
+
catch(:glass) do
|
104
|
+
raise ArgumentError.new("stirling couldn't take this value's load. Terminated.")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
if (command == 'subset')
|
108
|
+
gen = ask("Enter mass objects number: ", Integer)
|
109
|
+
zerosbst = agree("Include zero subset?")
|
110
|
+
puts subset(gen, zerosbst)
|
111
|
+
end
|
112
|
+
if (command == 'fibsum')
|
113
|
+
n = ask("Enter n value: ", Integer)
|
114
|
+
puts sum_of_fib(n)
|
115
|
+
end
|
116
|
+
if (command == 'twinprdx')
|
117
|
+
mass = ask("Enter mass number: ", Integer)
|
118
|
+
puts twin_prdx(mass)
|
119
|
+
end
|
120
|
+
if (command == 'uipow')
|
121
|
+
base = ask("Enter base value: ", Integer)
|
122
|
+
exp = ask("Enter power value: ", Integer)
|
123
|
+
puts ui_pow(base, exp)
|
124
|
+
end
|
125
|
+
end until(command == 'exit')
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RubMat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 2
|
8
7
|
- 2
|
9
|
-
-
|
10
|
-
version: 2.2.
|
8
|
+
- 1
|
9
|
+
version: 2.2.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Mahmut Bulut
|
@@ -15,9 +14,24 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2012-05-11 00:00:00
|
19
|
-
|
20
|
-
|
17
|
+
date: 2012-05-11 00:00:00 +03:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: commander
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 4
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
version: 4.1.0
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
21
35
|
description: Discrete Mathematics solver and Usable Library
|
22
36
|
email: scienceblock@gmail.com
|
23
37
|
executables:
|
@@ -36,12 +50,13 @@ files:
|
|
36
50
|
- gplv3.png
|
37
51
|
- RubMat.png
|
38
52
|
- bin/rubmat
|
39
|
-
- lib/
|
40
|
-
- lib/help.rb
|
53
|
+
- lib/statics.yml
|
41
54
|
- lib/librbdiscrete.rb
|
42
|
-
- lib/main.rb
|
43
55
|
- lib/rubmat.rb
|
44
|
-
- lib/
|
56
|
+
- lib/main.rb
|
57
|
+
- lib/fixnumexpand.rb
|
58
|
+
- lib/help.rb
|
59
|
+
has_rdoc: true
|
45
60
|
homepage: http://regularlambda.github.com/RubMat
|
46
61
|
licenses: []
|
47
62
|
|
@@ -55,7 +70,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
70
|
requirements:
|
56
71
|
- - ">="
|
57
72
|
- !ruby/object:Gem::Version
|
58
|
-
hash: 3
|
59
73
|
segments:
|
60
74
|
- 0
|
61
75
|
version: "0"
|
@@ -64,14 +78,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
78
|
requirements:
|
65
79
|
- - ">="
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
hash: 3
|
68
81
|
segments:
|
69
82
|
- 0
|
70
83
|
version: "0"
|
71
84
|
requirements: []
|
72
85
|
|
73
86
|
rubyforge_project:
|
74
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.3.7
|
75
88
|
signing_key:
|
76
89
|
specification_version: 3
|
77
90
|
summary: Discrete Mathematics solver and Usable Library
|