RubMat 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'rubmat'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestRubmat < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RubMat
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 3
5
+ prerelease:
5
6
  segments:
6
7
  - 2
7
8
  - 2
8
- - 1
9
- version: 2.2.1
9
+ - 2
10
+ version: 2.2.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Mahmut Bulut
@@ -14,52 +15,138 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2012-05-11 00:00:00 +03:00
18
- default_executable:
18
+ date: 2012-05-12 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: commander
22
- prerelease: false
21
+ type: :development
23
22
  requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ version_requirements: *id001
32
+ name: shoulda
33
+ prerelease: false
34
+ - !ruby/object:Gem::Dependency
35
+ type: :development
36
+ requirement: &id002 !ruby/object:Gem::Requirement
24
37
  none: false
25
38
  requirements:
26
39
  - - ~>
27
40
  - !ruby/object:Gem::Version
41
+ hash: 31
42
+ segments:
43
+ - 3
44
+ - 12
45
+ version: "3.12"
46
+ version_requirements: *id002
47
+ name: rdoc
48
+ prerelease: false
49
+ - !ruby/object:Gem::Dependency
50
+ type: :development
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 23
57
+ segments:
58
+ - 1
59
+ - 0
60
+ - 0
61
+ version: 1.0.0
62
+ version_requirements: *id003
63
+ name: bundler
64
+ prerelease: false
65
+ - !ruby/object:Gem::Dependency
66
+ type: :development
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ~>
71
+ - !ruby/object:Gem::Version
72
+ hash: 49
73
+ segments:
74
+ - 1
75
+ - 8
76
+ - 3
77
+ version: 1.8.3
78
+ version_requirements: *id004
79
+ name: jeweler
80
+ prerelease: false
81
+ - !ruby/object:Gem::Dependency
82
+ type: :development
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ version_requirements: *id005
93
+ name: rcov
94
+ prerelease: false
95
+ - !ruby/object:Gem::Dependency
96
+ type: :development
97
+ requirement: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ hash: 59
28
103
  segments:
29
104
  - 4
30
105
  - 1
31
106
  - 0
32
107
  version: 4.1.0
108
+ version_requirements: *id006
109
+ name: commander
110
+ prerelease: false
111
+ - !ruby/object:Gem::Dependency
33
112
  type: :runtime
34
- version_requirements: *id001
35
- description: Discrete Mathematics solver and Usable Library
36
- email: scienceblock@gmail.com
113
+ requirement: &id007 !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ hash: 59
119
+ segments:
120
+ - 4
121
+ - 1
122
+ - 0
123
+ version: 4.1.0
124
+ version_requirements: *id007
125
+ name: commander
126
+ prerelease: false
127
+ description: Discrete Mathematics REPL and built-in usable library for experimental and experimental projects
128
+ email: mahmutbulut0@gmail.com
37
129
  executables:
38
130
  - rubmat
39
131
  extensions: []
40
132
 
41
133
  extra_rdoc_files:
42
- - README.md
43
- - LICENSE
44
- - gplv3.png
45
- - RubMat.png
134
+ - LICENSE.txt
135
+ - README.rdoc
46
136
  files:
47
- - LICENSE
48
- - README.md
137
+ - .document
138
+ - Gemfile
139
+ - LICENSE.txt
140
+ - README.rdoc
49
141
  - Rakefile
50
- - gplv3.png
51
- - RubMat.png
52
- - bin/rubmat
53
- - lib/statics.yml
54
- - lib/librbdiscrete.rb
142
+ - VERSION
55
143
  - lib/rubmat.rb
56
- - lib/main.rb
57
- - lib/fixnumexpand.rb
58
- - lib/help.rb
59
- has_rdoc: true
60
- homepage: http://regularlambda.github.com/RubMat
61
- licenses: []
62
-
144
+ - test/helper.rb
145
+ - test/test_rubmat.rb
146
+ - bin/rubmat
147
+ homepage: http://github.com/regularlambda/RubMat
148
+ licenses:
149
+ - MIT
63
150
  post_install_message:
64
151
  rdoc_options: []
65
152
 
@@ -70,6 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
157
  requirements:
71
158
  - - ">="
72
159
  - !ruby/object:Gem::Version
160
+ hash: 3
73
161
  segments:
74
162
  - 0
75
163
  version: "0"
@@ -78,15 +166,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
166
  requirements:
79
167
  - - ">="
80
168
  - !ruby/object:Gem::Version
169
+ hash: 3
81
170
  segments:
82
171
  - 0
83
172
  version: "0"
84
173
  requirements: []
85
174
 
86
175
  rubyforge_project:
87
- rubygems_version: 1.3.7
176
+ rubygems_version: 1.8.24
88
177
  signing_key:
89
178
  specification_version: 3
90
- summary: Discrete Mathematics solver and Usable Library
179
+ summary: Discrete Mathematics REPL and built-in usable library
91
180
  test_files: []
92
181
 
data/LICENSE DELETED
@@ -1,17 +0,0 @@
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.md DELETED
@@ -1,9 +0,0 @@
1
- RubMat
2
- ============
3
-
4
- Docs link is http://github.com/regularlambda/RubMat/doc/index.html
5
-
6
- Special thanks for Emirhan Aksu for his contributions
7
- Special thanks for Martin Watson for his contributions
8
-
9
- Works like a charm!
data/RubMat.png DELETED
Binary file
data/gplv3.png DELETED
Binary file
@@ -1,35 +0,0 @@
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
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env ruby
2
- def help
3
- puts "
4
- Valid Commands
5
- ===============
6
- help Show this manpage
7
- certain Show certain conditions page
8
- factorial Recursive definition of factorial
9
- 'n' is the number which will calculated in procedure
10
- binsearch *binary => array
11
- *size => binary array's size
12
- *search_key => Compare string
13
- *General values
14
- *low => low value representation
15
- *middle => middle value representation
16
- *high => high value representation
17
- birdseye Bird's Eye View Procedure
18
- combinatorial 'glb' represents is General mass of combinatorial approach
19
- 'klb' represents is Selection mass of combinatorial approach
20
- distpres 'presnum' value represents Present count.
21
- eagleview Eagle View Procedure
22
- fermatlittle Fermat Little Theorem's Procedural Representation
23
- fib Additive recursive definition of Fibonacci
24
- isprime Is Prime Procedure
25
- 'nb' is the input argument number of procedure
26
- iterativefact Iterative factorial of procedural representation
27
- sigma Sigma procedure's simple procedure is rely on '(ax+b)^pw'
28
- a represented by inta;
29
- b represented by intb;
30
- x represented by intx;
31
- power represented by pw.
32
- stirling 'strln' is the stirling number in stirling formula
33
- subset 'zerosbst' variable, decision mechanism of zero subset is included or not included
34
- 'gen' is the general mass elements(objects) number
35
- fibsum Fibonacci Sum Procedure
36
- twinprdx Twin Paradox Lemma Solution Procedure
37
- Selection mass represented by 'mass' value
38
- uipow Non-balanced power calculation procedure
39
- "
40
- end
@@ -1,435 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- #constants1 = YAML::load_file('statics.yml')
4
-
5
- EVALUE = 2.718281828459045235360287471352662497757247093
6
- PIVALUE = 3.141592653589793238462643383279502884197169399
7
- MAX_INTEGER = 1073741823
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 general mass elements(objects) number
82
-
83
- = DESCRIPTION
84
- Calculate subset number of input arguments
85
- =end
86
- def subset(gen, zerosbst)
87
- main = case (zerosbst)
88
- when zerosbst == true
89
- rslt = ui_pow(2, gen) - 1
90
- return rslt
91
- when zerosbst == false
92
- rslt = ui_pow(2, gen)
93
- return rslt
94
- end
95
- return main
96
- end
97
-
98
- #/*
99
- #int subset(void){
100
- # char zerosbst;
101
- # float rslt=0;int gen=0;
102
- # printf("Enter the mass elements number: ");
103
- # scanf("%d", &gen);
104
- # //Dönmeleri düzelt formatlamaları düzelt, cast ı düzelt
105
- # //Elemanları binary string olarak döndür
106
- # printf("Want to get subsets?(y/n)\n");
107
- # zerosbst=getchar();
108
- # switch (zerosbst){
109
- #
110
- # case 'y':
111
- # rslt = ui_pow(2, gen) - 1;
112
- # int rslt = rslt;
113
- # printf("%d", rslt);
114
- # break;
115
- # case 'n':
116
- # rslt = ui_pow(2, gen);
117
- # //printf("%f", rslt);
118
- # break;
119
- # default:
120
- # puts("Enter y or n char");
121
- # break;
122
- # }
123
- # return EXIT_SUCCESS;
124
- #}
125
- #*/
126
-
127
- ## Combinatorial problems solver
128
- #
129
- #
130
-
131
- =begin
132
- = NAME
133
- Combinatorial Procedure v1.1.5
134
-
135
- = SYNOPSIS
136
- combinatorial(glb, ksb)
137
- 'glb' represents is General mass of combinatorial approach
138
- 'klb' represents is Selection mass of combinatorial approach
139
-
140
- = DESCRIPTION
141
- Combinatorial selection number of a input argument mass
142
- =end
143
- def combinatorial(glb, ksb)
144
- if(glb < ksb)
145
- raise RuntimeError.new("Global set cannot be greater than k-subsets")
146
- end
147
- sbst_given_size = factorial(glb)/(factorial(ksb)*factorial(glb-ksb)).to_f
148
- return sbst_given_size
149
- end
150
-
151
- =begin
152
- = NAME
153
- Sigma Procedure v1.1.5
154
-
155
- = SYNOPSIS
156
- sigma(inta, intx, intb, pw)
157
- Sigma procedure's simple procedure is rely on '(ax+b)^pw'
158
- a represented by inta;
159
- b represented by intb;
160
- x represented by intx;
161
- power represented by pw.
162
-
163
- = DESCRIPTION
164
- 'Sigma of the one unknowned equation' procedure
165
- =end
166
-
167
- def sigma(inta, intx, intb, pw)
168
- ttl = 0
169
- for i in 1..intx
170
- ttl += (inta*intx+intb)
171
- end
172
- if(pw == 1)
173
- return ttl
174
- end
175
- if(pw > 1)
176
- ttl=ui_pow(ttl, pw)
177
- return ttl
178
- end
179
- if(pw == 0)
180
- return 1
181
- end
182
- end
183
-
184
- =begin
185
- = NAME
186
- Stirling Procedure v1.1.5
187
-
188
- = SYNOPSIS
189
- stirling(strln)
190
- 'strln' is the stirling number in stirling formula
191
-
192
- = DESCRIPTION
193
- Stirling Procedure for Stirling Lemma
194
- =end
195
- def stirling(strln)
196
- return (strln/constants1.EVALUE**strln)*Math.sqrt(2*constants1.PIVALUE*strln);
197
- end
198
-
199
- =begin
200
- = NAME
201
- Twin Paradox Lemma Solver v1.1.5
202
-
203
- = SYNOPSIS
204
- twin_prdx(mass)
205
- Selection mass represented by 'mass' value
206
-
207
- = DESCRIPTION
208
- Twin Paradox Lemma Solution Procedure
209
- =end
210
- def twin_prdx(mass)
211
- top=1
212
- for i in 366..366-mass
213
- top *= i
214
- end
215
- return top/ui_pow(366, mass)
216
- end
217
-
218
- =begin
219
- = NAME
220
- Distrubuting Presents Procedure v1.1.3
221
-
222
- = SYNOPSIS
223
- dist_pres(presnum)
224
- 'presnum' value represents Present count.
225
-
226
- = DESCRIPTION
227
- Use of Sequence of factorial and iterative_fact procedures for
228
- distributing presents.
229
- =end
230
- def dist_pres(presnum)
231
- return factorial(presnum)/iterative_fact(presnum);
232
- end
233
-
234
- =begin
235
- = NAME
236
- Recursive adding of procedure fibonacci
237
-
238
- = SYNOPSIS
239
- fib(n)
240
- 'n' represents recursive definition
241
-
242
- = DESCRIPTION
243
- Additive recursive definition of Fibonacci
244
- =end
245
- def fib(n)
246
- if (n <= 1)
247
- return n;
248
- else
249
- return fib(n-1)+fib(n-2);
250
- end
251
- end
252
-
253
- =begin
254
- = NAME
255
- Printing Row v1.5.5
256
-
257
- = SYNOPSIS
258
- print_row(binary, size, low, mid, high)
259
- 'binary' represents binary array
260
- 'size' represents general size
261
- 'low' represents minimum value of binary array
262
- 'mid' represents middle value of binary array
263
- 'high' represents maximum value of binary array
264
-
265
- = DESCRIPTION
266
- Underly array for printing.
267
- =end
268
- def print_row(binary, size, low, mid, high)
269
- for i in 0..size-1
270
- if (i <low || i > high)
271
- print " "
272
- end
273
- if(i == mid)
274
- puts binary[i]
275
- end
276
- if(nil)
277
- puts binary[i]
278
- end
279
- end
280
- end
281
-
282
- =begin
283
- = NAME
284
- Binary Search Spec. Procedure v1.5.9
285
-
286
- = SYNOPSIS
287
- binary_search(binary, size, search_key, low, middle, high)
288
- == Binary search
289
- *binary => array
290
- *size => binary array's size
291
- *search_key => Compare string
292
- *General values
293
- *low => low value representation
294
- *middle => middle value representation
295
- *high => high value representation
296
-
297
- = DESCRIPTION
298
- Binary search
299
- =end
300
- def binary_search(binary, size, search_key, low, middle, high)
301
- while (low <= high)
302
- middle=(low+high)/2;
303
- print_row(binary, size, low, middle, high);
304
- if (search_key == binary[middle])
305
- return middle;
306
- elsif (search_key <= binary[middle])
307
- high=middle-1
308
- else
309
- low=middle+1
310
- end
311
- end
312
- end
313
-
314
- =begin
315
- = NAME
316
- Bird's Eye View v1.1.3
317
-
318
- = SYNOPSIS
319
- Basic rep.s
320
-
321
- = DESCRIPTION
322
- Bird's Eye View Procedure
323
- =end
324
- def birds_eye(n, k)
325
- return ((n-k)/(k+1));
326
- end
327
-
328
- =begin
329
- = NAME
330
- Eagle View v1.1.3
331
-
332
- = SYNOPSIS
333
- Basic rep.s
334
-
335
- = DESCRIPTION
336
- Eagle View Procedure
337
- =end
338
- def eagle_view(m, t)
339
- return (EVALUE**((t*t)/m));
340
- end
341
-
342
- =begin
343
- = NAME
344
- Sum of Fibonacci Procedure v1.1.1
345
-
346
- = SYNOPSIS
347
- sum_of_fib(n)
348
- 'n' is the number
349
- Basic reps
350
-
351
- = DESCRIPTION
352
- Fibonacci Sum Procedure
353
- =end
354
- def sum_of_fib(n)
355
- return fib(n+2)-1;
356
- end
357
-
358
- #
359
- #def fibFormula(long int n)
360
- # return (1/Math.sqrt(5))*(powl(((1+sqrt(5))/2), n)-powl(((1-sqrt(5))/2), n));
361
- #end
362
-
363
- =begin
364
- = NAME
365
- Is Prime Procedure v1.1.5
366
-
367
- = SYNOPSIS
368
- is_prime(nb)
369
- 'nb' is the input argument number of procedure
370
-
371
- = DESCRIPTION
372
- Is Prime Procedure
373
- =end
374
- def is_prime(nb)
375
- test = count = 0
376
- if (nb == 1)
377
- return -1
378
- end
379
- for i in 2..nb-1
380
- count++
381
- if (nb % i == 0)
382
- test = false
383
- end
384
- end
385
- if (!test)
386
- return 1
387
- else
388
- return 0
389
- end
390
- end
391
-
392
- =begin
393
- = NAME
394
- Fermat's Little Theorem v1.1.3
395
-
396
- = SYNOPSIS
397
- fermat_little(p, a)
398
-
399
- = DESCRIPTION
400
- Fermat Little Theorem's Procedural Representation
401
-
402
- (('WARNING'))((-Modular representation maybe couldn't evaluated-))
403
- =end
404
- def fermat_little(p, a)
405
- begin
406
- if(p%(ui_pow(a, (p-1))-1) == 0)
407
- return 0
408
- else
409
- return 1
410
- end
411
- end
412
- rescue
413
- begin
414
- ArgumentError.new("High load. Terminated.")
415
- end
416
- end
417
-
418
- =begin
419
- = NAME
420
- to_bool v.0.0.1
421
-
422
- =SYNOPSIS
423
- to_bool(void)
424
- =DESCRIPTION
425
- to bool is convert integer valus to string boolean
426
- =end
427
- def to_bool
428
- if (self.to_bool == 1)
429
- puts "TRUE"
430
- elsif (self.to_bool == 0)
431
- puts "FALSE"
432
- elsif (self.to_bool == -1)
433
- puts "NaN"
434
- end
435
- end