RubMat 2.1.5

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.
data/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ == RubMat ==
2
+
3
+ RubMat == Discrete Mathematics solver and Usable Library
4
+ Copyright (C) <2011> <Mahmut Bulut>
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
data/README ADDED
@@ -0,0 +1,4 @@
1
+ == RubMat ==
2
+ ============
3
+
4
+ DOCUMENTATION OF PROJECT
@@ -0,0 +1,42 @@
1
+
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'rake/clean'
5
+ require 'rake/gempackagetask'
6
+ require 'rake/rdoctask'
7
+ require 'rake/testtask'
8
+
9
+ spec = Gem::Specification.new do |s|
10
+ s.name = 'RubMat'
11
+ s.version = '2.1.5'
12
+ s.has_rdoc = true
13
+ s.extra_rdoc_files = ['README', 'LICENSE', 'gplv3.png', 'RubMat.png']
14
+ s.summary = 'Discrete Mathematics solver and Usable Library'
15
+ s.description = s.summary
16
+ s.author = 'Matthew Manahan'
17
+ s.email = 'scienceblock@gmail.com'
18
+ # s.executables = ['your_executable_here']
19
+ s.files = %w(LICENSE README Rakefile gplv3.png RubMat.png) + Dir.glob("{bin,lib,spec}/**/*")
20
+ s.require_path = "lib"
21
+ s.bindir = "bin"
22
+ s.homepage = 'http://regularlambda.github.com/RubMat'
23
+ end
24
+
25
+ Rake::GemPackageTask.new(spec) do |p|
26
+ p.gem_spec = spec
27
+ p.need_tar = true
28
+ p.need_zip = true
29
+ end
30
+
31
+ Rake::RDocTask.new do |rdoc|
32
+ files =['README', 'LICENSE', 'lib/**/*.rb', 'lib/**/*.yml']
33
+ rdoc.rdoc_files.add(files)
34
+ rdoc.main = "README" # page to start on
35
+ rdoc.title = "RubMat Docs"
36
+ rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
37
+ rdoc.options << '--line-numbers'
38
+ end
39
+
40
+ Rake::TestTask.new do |t|
41
+ t.test_files = FileList['test/**/*.rb']
42
+ end
Binary file
Binary file
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby
2
+
3
+ =begin
4
+ = NAME
5
+ Fixnum Expandation Code v1.2.0
6
+
7
+ = SYNOPSIS
8
+ .seconds =1
9
+ .minutes =60
10
+ .hours =3600
11
+ .days =86400
12
+ .weeks =604800
13
+
14
+ = DESCRIPTION
15
+ This snippet expands Fixnum class and convert
16
+ time counts to (('string'))((-Object ending string-))
17
+ =end
18
+
19
+ class Fixnum
20
+ def seconds
21
+ self
22
+ end
23
+ def minutes
24
+ self * 60
25
+ end
26
+ def hours
27
+ self * 60 * 60
28
+ end
29
+ def days
30
+ self * 60 * 60 * 24
31
+ end
32
+ def weeks
33
+ self * 60 * 60 * 24 * 7
34
+ end
35
+ end
@@ -0,0 +1,412 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'yaml'
4
+ #constants1 = YAML::load_file('statics.yml')
5
+
6
+ EVALUE = 2.718281828459045235360287471352662497757247093
7
+ PIVALUE = 3.141592653589793238462643383279502884197169399
8
+
9
+ err = "An error occured during during procedure"
10
+
11
+ =begin
12
+ = NAME
13
+ Recursive Factorial Procedure Definition v1.1.3
14
+
15
+ = SYNOPSIS
16
+ factorial(n)
17
+ 'n' is the number which will calculated in procedure
18
+
19
+ = DESCRIPTION
20
+ Iterative factorial definition
21
+ =end
22
+ def factorial( n )
23
+ if n <= 1
24
+ return 1
25
+ else
26
+ return n*factorial( n-1 ).to_i
27
+ end
28
+ end
29
+
30
+ =begin
31
+ = NAME
32
+ Power procedure of two input arguments v2.1.3
33
+
34
+ = SYNOPSIS
35
+ ui_pow(base, exp)
36
+ 'base' argument is the base of power procedure
37
+ 'exp' argument is the upscript of power procedure
38
+
39
+ = DESCRIPTION
40
+ Wide representation of power procedure
41
+ =end
42
+ def ui_pow(base, exp)
43
+ result = 1;
44
+ while (exp)
45
+ if (exp & 1)
46
+ result *= base
47
+ end
48
+ exp >>= 1;
49
+ base *= base
50
+ end
51
+ if(exp==0)
52
+ result=base
53
+ end
54
+ return result
55
+ end
56
+
57
+ =begin
58
+ = NAME
59
+ Iterative Factorial Procedure v1.0.3
60
+
61
+ = SYNOPSIS
62
+ Get input arguments from simple argument
63
+
64
+ = DESCRIPTION
65
+ Iterative factorial of procedural representation
66
+ =end
67
+ def iterative_fact(itrtnum)
68
+ itrtnum.downto(1) do
69
+ total *= factorial(itrtnum)
70
+ end
71
+ return total
72
+ end
73
+
74
+ =begin
75
+ = NAME
76
+ Subset Procedure v1.1.3
77
+
78
+ = SYNOPSIS
79
+ subset(gen, zerosbst)
80
+ 'zerosbst' variable, decision mechanism of zero subset is included or not included
81
+ 'gen' is the
82
+
83
+ = DESCRIPTION
84
+ Calculate subset number of input arguments
85
+ =end
86
+ def subset(gen, zerosbst)
87
+ main = case (zerosbst)
88
+ when zerosbst == 'y'
89
+ rslt = ui_pow(2, gen) - 1
90
+ return rslt
91
+ when zerosbst == 'n'
92
+ rslt = ui_pow(2, gen)
93
+ return rslt
94
+ else
95
+ puts "Enter 'y' or 'n' char"
96
+ end
97
+ return main
98
+ end
99
+
100
+ #/*
101
+ #int subset(void){
102
+ # char zerosbst;
103
+ # float rslt=0;int gen=0;
104
+ # printf("Enter the mass elements number: ");
105
+ # scanf("%d", &gen);
106
+ # //Dönmeleri düzelt formatlamaları düzelt, cast ı düzelt
107
+ # //Elemanları binary string olarak döndür
108
+ # printf("Want to get subsets?(y/n)\n");
109
+ # zerosbst=getchar();
110
+ # switch (zerosbst){
111
+ #
112
+ # case 'y':
113
+ # rslt = ui_pow(2, gen) - 1;
114
+ # int rslt = rslt;
115
+ # printf("%d", rslt);
116
+ # break;
117
+ # case 'n':
118
+ # rslt = ui_pow(2, gen);
119
+ # //printf("%f", rslt);
120
+ # break;
121
+ # default:
122
+ # puts("Enter y or n char");
123
+ # break;
124
+ # }
125
+ # return EXIT_SUCCESS;
126
+ #}
127
+ #*/
128
+
129
+ ## Combinatorial problems solver
130
+ #
131
+ #
132
+
133
+ =begin
134
+ = NAME
135
+ Combinatorial Procedure v1.1.5
136
+
137
+ = SYNOPSIS
138
+ combinatorial(glb, ksb)
139
+ 'glb' represents is General mass of combinatorial approach
140
+ 'klb' represents is Selection mass of combinatorial approach
141
+
142
+ = DESCRIPTION
143
+ Combinatorial selection number of a input argument mass
144
+ =end
145
+ def combinatorial(glb, ksb)
146
+ if(glb < ksb)
147
+ raise RuntimeError.new("Global set cannot be greater than k-subsets")
148
+ end
149
+ sbst_given_size = factorial(glb)/(factorial(ksb)*factorial(glb-ksb)).to_f
150
+ return sbst_given_size
151
+ end
152
+
153
+ =begin
154
+ = NAME
155
+ Sigma Procedure v1.1.5
156
+
157
+ = SYNOPSIS
158
+ sigma(inta, intx, intb, pw)
159
+ Sigma procedure's simple procedure is rely on '(ax+b)^pw'
160
+ a represented by inta;
161
+ b represented by intb;
162
+ x represented by intx;
163
+ power represented by pw.
164
+
165
+ = DESCRIPTION
166
+ 'Sigma of the one unknowned equation' procedure
167
+ =end
168
+
169
+ def sigma(inta, intx, intb, pw)
170
+ ttl = 0
171
+ for i in 1..intx
172
+ ttl += (inta*intx+intb)
173
+ end
174
+ if(pw == 1)
175
+ return ttl
176
+ end
177
+ if(pw > 1)
178
+ ttl=ui_pow(ttl, pw)
179
+ return ttl
180
+ end
181
+ if(pw == 0)
182
+ return 1
183
+ end
184
+ end
185
+
186
+ =begin
187
+ = NAME
188
+ Stirling Procedure v1.1.5
189
+
190
+ = SYNOPSIS
191
+ stirling(strln)
192
+ 'strln' is the stirling number in stirling formula
193
+
194
+ = DESCRIPTION
195
+ Stirling Procedure for Stirling Lemma
196
+ =end
197
+ def stirling(strln)
198
+ return (strln/constants1.EVALUE**strln)*Math.sqrt(2*constants1.PIVALUE*strln);
199
+ end
200
+
201
+ =begin
202
+ = NAME
203
+ Twin Paradox Lemma Solver v1.1.5
204
+
205
+ = SYNOPSIS
206
+ twin_prdx(mass)
207
+ Selection mass represented by 'mass' value
208
+
209
+ = DESCRIPTION
210
+ Twin Paradox Lemma Solution Procedure
211
+ =end
212
+ def twin_prdx(mass)
213
+ top=1
214
+ for i in 366..366-mass
215
+ top *= i
216
+ end
217
+ return top/ui_pow(366, mass)
218
+ end
219
+
220
+ =begin
221
+ = NAME
222
+ Distrubuting Presents Procedure v1.1.3
223
+
224
+ = SYNOPSIS
225
+ dist_pres(presnum)
226
+ 'presnum' value represents Present count.
227
+
228
+ = DESCRIPTION
229
+ Use of Sequence of factorial and iterative_fact procedures for
230
+ distributing presents.
231
+ =end
232
+ def dist_pres(presnum)
233
+ return factorial(presnum)/iterative_fact(presnum);
234
+ end
235
+
236
+ =begin
237
+ = NAME
238
+ Recursive adding of procedure fibonacci
239
+
240
+ = SYNOPSIS
241
+ fib(n)
242
+ 'n' represents recursive definition
243
+
244
+ = DESCRIPTION
245
+ Additive recursive definition of Fibonacci
246
+ =end
247
+ def fib(n)
248
+ if (n <= 1)
249
+ return n;
250
+ elsif
251
+ return fib(n-1)+fib(n-2);
252
+ end
253
+ end
254
+
255
+ =begin
256
+ = NAME
257
+ Printing Row v1.5.5
258
+
259
+ = SYNOPSIS
260
+ print_row(binary, size, low, mid, high)
261
+ 'binary' represents binary array
262
+ 'size' represents general size
263
+ 'low' represents minimum value of binary array
264
+ 'mid' represents middle value of binary array
265
+ 'high' represents maximum value of binary array
266
+
267
+ = DESCRIPTION
268
+ Underly array for printing.
269
+ =end
270
+ def print_row(binary, size, low, mid, high)
271
+ for i in 0..size-1
272
+ if (i <low || i > high)
273
+ print (" ")
274
+ end
275
+ if(i == mid)
276
+ puts binary[i]
277
+ end
278
+ if(nil)
279
+ puts binary[i]
280
+ end
281
+ end
282
+ end
283
+
284
+ =begin
285
+ = NAME
286
+ Binary Search Spec. Procedure v1.5.9
287
+
288
+ = SYNOPSIS
289
+ binary_search(binary, size, searchKey, low, middle, high)
290
+ == Binary search
291
+ *binary => array
292
+ *size => binary array's size
293
+ *searchKey => Compare string
294
+ *General values
295
+ *low => low value representation
296
+ *middle => middle value representation
297
+ *high => high value representation
298
+
299
+ = DESCRIPTION
300
+ Binary search
301
+ =end
302
+ def binary_search(binary, size, searchKey, low, middle, high)
303
+ while (low <= high)
304
+ middle=(low+high)/2;
305
+ print_row(binary, size, low, middle, high);
306
+ if (searchKey == binary[middle])
307
+ return middle;
308
+ elsif (searchKey <= binary[middle])
309
+ high=middle-1
310
+ else
311
+ low=middle+1
312
+ end
313
+ end
314
+ end
315
+
316
+ =begin
317
+ = NAME
318
+ Bird's Eye View v1.1.3
319
+
320
+ = SYNOPSIS
321
+ Basic rep.s
322
+
323
+ = DESCRIPTION
324
+ Bird's Eye View Procedure
325
+ =end
326
+ def birds_eye(n, k)
327
+ return ((n-k)/(k+1));
328
+ end
329
+
330
+ =begin
331
+ = NAME
332
+ Eagle View v1.1.3
333
+
334
+ = SYNOPSIS
335
+ Basic rep.s
336
+
337
+ = DESCRIPTION
338
+ Eagle View Procedure
339
+ =end
340
+ def eagle_view(m, t)
341
+ return (EVALUE**((t*t)/m));
342
+ end
343
+
344
+ =begin
345
+ = NAME
346
+ Sum of Fibonacci Procedure v1.1.1
347
+
348
+ = SYNOPSIS
349
+ sum_of_fib(n)
350
+ 'n' is the number
351
+ Basic reps
352
+
353
+ = DESCRIPTION
354
+ Bird's Eye View Procedure
355
+ =end
356
+ def sum_of_fib(n)
357
+ return fib(n+2)-1;
358
+ end
359
+
360
+ #
361
+ #def fibFormula(long int n)
362
+ # return (1/Math.sqrt(5))*(powl(((1+sqrt(5))/2), n)-powl(((1-sqrt(5))/2), n));
363
+ #end
364
+
365
+ =begin
366
+ = NAME
367
+ Is Prime Procedure v1.1.5
368
+
369
+ = SYNOPSIS
370
+ is_prime(nb)
371
+ 'nb' is the input argument number of procedure
372
+
373
+ = DESCRIPTION
374
+ Is Prime Procedure
375
+ =end
376
+ def is_prime(nb)
377
+ test = count = 0
378
+ if (nb != 1)
379
+ return -1
380
+ end
381
+ for i in 2..nb-1
382
+ count++
383
+ if (nb % i == 0)
384
+ test = 1
385
+ end
386
+ end
387
+ if (!test)
388
+ return 1
389
+ elsif
390
+ return 0
391
+ end
392
+ end
393
+
394
+ =begin
395
+ = NAME
396
+ Fermat's Little Theorem v1.1.3
397
+
398
+ = SYNOPSIS
399
+ fermat_little(p, a)
400
+
401
+ = DESCRIPTION
402
+ Fermat Little Theorem's Procedural Representation
403
+
404
+ (('WARNING'))((-Modular representation maybe couldn't evaluated-))
405
+ =end
406
+ def fermat_little(p, a)
407
+ if(p%(ui_pow(a, (p-1))-1) == 0)
408
+ return 0
409
+ elsif
410
+ return 1
411
+ end
412
+ end
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # AUTHOR: Matthew Manahan
4
+
5
+ require 'yaml'
6
+ require 'librbdiscrete.rb'
7
+ require 'fixnumexpand.rb'
8
+
9
+ puts "===RubMat===
10
+ Copyright (C) <2011> <Matthew Manahan>
11
+ This program comes with ABSOLUTELY NO WARRANTY; for details type 'help'.
12
+ This is free software, and you are welcome to redistribute it
13
+ under certain conditions; type `certain' for details."
@@ -0,0 +1,4 @@
1
+ ## AUTHOR : Matthew Manahan
2
+ ---
3
+ EVALUE: 2.718281828459045235360287471352662497757247093
4
+ PIVALUE: 3.141592653589793238462643383279502884197169399
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: RubMat
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
+ prerelease:
6
+ segments:
7
+ - 2
8
+ - 1
9
+ - 5
10
+ version: 2.1.5
11
+ platform: ruby
12
+ authors:
13
+ - Matthew Manahan
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-20 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Discrete Mathematics solver and Usable Library
22
+ email: scienceblock@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README
29
+ - LICENSE
30
+ - gplv3.png
31
+ - RubMat.png
32
+ files:
33
+ - LICENSE
34
+ - README
35
+ - Rakefile
36
+ - gplv3.png
37
+ - RubMat.png
38
+ - lib/fixnumexpand.rb
39
+ - lib/librbdiscrete.rb
40
+ - lib/main.rb
41
+ - lib/statics.yml
42
+ homepage: http://regularlambda.github.com/RubMat
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.7.2
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Discrete Mathematics solver and Usable Library
75
+ test_files: []
76
+