modai_prct10 0.0.1

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
+ SHA1:
3
+ metadata.gz: 05739c7ea7b0173c50241ff8657ac2ada85f4159
4
+ data.tar.gz: cbbc2e606c2bbac433c21c43cf674719a622fd74
5
+ SHA512:
6
+ metadata.gz: 35a2dfed99c627420196974c5199b0cf84fafcba3923f9e9ba2f9160098c52bbf0a7ac64909d86442acf97b53da1c2341e0f524a90e9c485a25ac25ba7a5fa0b
7
+ data.tar.gz: bab5d437aebbe4ae9b747953c6dcbe0e19e98c6038b7b48c3e225a2e966d2c0f21546889afd0f5bfcce2898903a42c5208e7c75a06e06709b98c2a8be0487362
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ # - 1.9.2
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ - rbx-19mode
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in modai_prct09.gemspec
4
+ gemspec
5
+ gem 'rake'
6
+ gem 'rspec'
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
data/Guardfile ADDED
@@ -0,0 +1,38 @@
1
+ guard 'bundler' do
2
+ watch('Gemfile')
3
+ watch(/^.+\.gemspec/)
4
+ end
5
+
6
+ guard 'rspec', :version => 2 do
7
+ watch(%r{^spec/.+_spec\.rb$})
8
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
+ watch('spec/spec_helper.rb') { "spec" }
10
+ end
11
+
12
+ guard :bundler do
13
+ watch('Gemfile')
14
+ # Uncomment next line if your Gemfile contains the `gemspec' command.
15
+ # watch(/^.+\.gemspec/)
16
+ end
17
+
18
+ guard :rspec do
19
+ watch(%r{^spec/.+_spec\.rb$})
20
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
21
+ watch('spec/spec_helper.rb') { "spec" }
22
+
23
+ # Rails example
24
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
25
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
26
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
27
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
28
+ watch('config/routes.rb') { "spec/routing" }
29
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
30
+
31
+ # Capybara features specs
32
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
33
+
34
+ # Turnip features and steps
35
+ watch(%r{^spec/acceptance/(.+)\.feature$})
36
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
37
+ end
38
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Dailos Herrera Bencomo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ Práctica : Práctica de Laboratorio #10 - EQUIPO.
2
+ ======================================================
3
+ Grupo : LPP-T-45.
4
+ Alumnos : DAILOS HERRERA BENCOMO.
5
+ MOHAMMED MAHRACH.
6
+ Asignatura : LPP.
7
+
8
+ -------------------------------------------------
9
+
10
+ Considere la Gema para Matrices que empezó a desarrollar en la práctica anterior. El objetivo de esta práctica es terminar su creación.
11
+
12
+ 1.- Desarrollar métodos para calcular el máximos y el mínimo de los elementos de una matriz.
13
+
14
+ 2.- Construir la gema
15
+
16
+ gem build
17
+
18
+ 3.- Considerar su publicacion
19
+
20
+ gem push
21
+
22
+ 4. Indique la URL del repositorio que ha desarrollado.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ $:.unshift File.dirname(__FILE__) + 'lib'
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new
6
+ task :default => :spec
data/lib/gcd.rb ADDED
@@ -0,0 +1,7 @@
1
+ def gcd(u, v)
2
+ u, v = u.abs, v.abs
3
+ while v > 0
4
+ u, v = v, u % v
5
+ end
6
+ u
7
+ end
@@ -0,0 +1,3 @@
1
+ module ModaiPrct10
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,391 @@
1
+ require "modai_prct10/version"
2
+ require "racional"
3
+
4
+ module ModaiPrct10
5
+
6
+ $tope = 9999999999.9
7
+
8
+ # Clase abstracta para herencia común de matrices densa y dispersa
9
+ class MatrizAbstracta
10
+
11
+ end
12
+
13
+ # Clase de Matriz densa
14
+ class MatrizDensa < MatrizAbstracta
15
+
16
+ # Inicialización
17
+ def initialize(matriz)
18
+
19
+ @matriz = matriz
20
+ @filas = matriz[0].size
21
+ @columnas = matriz[0].size
22
+
23
+ end
24
+
25
+ attr_reader :matriz, :filas, :columnas
26
+
27
+ # Convertimos a string
28
+ def to_s
29
+
30
+ fil = 0
31
+ print "["
32
+ while fil < filas
33
+
34
+ col = 0
35
+ while col < columnas
36
+
37
+ print "#{matriz[fil][col].to_s}"
38
+ if (col + 1) < columnas then print ", " end
39
+ col += 1
40
+
41
+ end
42
+
43
+ if (fil + 1) < filas then print ", " end
44
+ fil += 1
45
+
46
+ end
47
+ print "]"
48
+
49
+ end
50
+
51
+ # Matriz en punto flotante
52
+ def to_f
53
+
54
+ flotante = Array.new(matriz.size - 1)
55
+ for i in 0...matriz.size
56
+ flotante[i] = Array.new(matriz[i].size - 1)
57
+ for j in 0...matriz[i].size
58
+ flotante[i][j] = (matriz[i][j]).to_f
59
+ end
60
+ end
61
+ MatrizDensa.new(flotante)
62
+
63
+ end
64
+
65
+ # Suma de matrices
66
+ def +(o)
67
+
68
+ suma = Array.new(matriz.size - 1)
69
+ for i in 0...matriz.size
70
+ suma[i] = Array.new(matriz[i].size - 1)
71
+ for j in 0...matriz[i].size
72
+ suma[i][j] = matriz[i][j] + o.matriz[i][j]
73
+ end
74
+ end
75
+ MatrizDensa.new(suma)
76
+
77
+ end
78
+
79
+ # Resta de matrices
80
+ def -(o)
81
+
82
+ resta = Array.new(matriz.size - 1)
83
+ for i in 0...matriz.size
84
+ resta[i] = Array.new(matriz[i].size - 1)
85
+ for j in 0...matriz[i].size
86
+ resta[i][j] = matriz[i][j] - o.matriz[i][j]
87
+ end
88
+ end
89
+ MatrizDensa.new(resta)
90
+
91
+ end
92
+
93
+ # Multiplicación de matrices
94
+ def *(o)
95
+
96
+ prod = Array.new(matriz.size - 1,0)
97
+ for i in 0...matriz[0].size
98
+ prod[i] = Array.new(o.matriz.size,0)
99
+ for j in 0...o.matriz.size
100
+ for pos in 0...matriz.size
101
+ prod[i][j] = prod[i][j] + (matriz[i][pos] * o.matriz[pos][j])
102
+ end
103
+ end
104
+ end
105
+ MatrizDensa.new(prod)
106
+
107
+ end
108
+
109
+ # Máximo de matriz
110
+ def max
111
+
112
+ maximo = 0.to_f
113
+ for i in 0...matriz.size
114
+ for j in 0...matriz[i].size
115
+ if matriz[i][j].to_f > maximo
116
+ maximo = matriz[i][j].to_f
117
+ end
118
+ end
119
+ end
120
+ maximo
121
+
122
+ end
123
+
124
+ # Minimo de matriz
125
+ def min
126
+
127
+ minimo = $tope
128
+ for i in 0...matriz.size
129
+ for j in 0...matriz[i].size
130
+ if matriz[i][j].to_f < minimo
131
+ minimo = matriz[i][j].to_f
132
+ end
133
+ end
134
+ end
135
+ minimo
136
+
137
+ end
138
+
139
+ end
140
+
141
+ # Clase de Matriz dispersa
142
+ class MatrizDispersa < MatrizAbstracta
143
+
144
+ # Inicialización
145
+ def initialize(matriz)
146
+
147
+ @matriz = matriz
148
+ @filas = matriz.size
149
+ @columnas = matriz.size
150
+
151
+ end
152
+
153
+ attr_reader :matriz, :filas, :columnas
154
+
155
+ # Convertimos a string
156
+ def to_s
157
+
158
+ fil = 0
159
+ print "["
160
+ while fil < filas
161
+
162
+ col = 0
163
+ while col < columnas
164
+
165
+ # Hay datos en la fila
166
+ if matriz[fil] != nil
167
+
168
+ if matriz[fil].has_key?(col)
169
+ print "#{matriz[fil][col].to_s}"
170
+ else
171
+ print "0"
172
+ end
173
+ else
174
+ print "0"
175
+ end
176
+
177
+ if (col + 1) < columnas then print ", " end
178
+ col += 1
179
+
180
+ end
181
+
182
+
183
+ if (fil + 1) < filas then print ", " end
184
+ fil += 1
185
+
186
+ end
187
+ print "]"
188
+
189
+ end
190
+
191
+ # Matriz en punto flotante
192
+ def to_f
193
+
194
+ flotante = Array.new(matriz.size - 1)
195
+ for i in 0...matriz.size
196
+ # Hay datos en la fila
197
+ if matriz[i] != nil
198
+
199
+ flotante[i] = Hash.new()
200
+ matriz[i].each do |key, value|
201
+ flotante[i][key] = matriz[i][key].to_f
202
+ end
203
+
204
+ end
205
+
206
+ end
207
+ MatrizDispersa.new(flotante)
208
+
209
+ end
210
+
211
+ # Suma de matrices
212
+ def +(o)
213
+
214
+ suma = Array.new(matriz.size - 1)
215
+ for i in 0...matriz.size
216
+
217
+ # creamos el hash
218
+ if (matriz[i] != nil or o.matriz[i] != nil)
219
+
220
+ suma[i] = Hash.new()
221
+
222
+ case true
223
+
224
+ # Los dos tienen hash
225
+ when (matriz[i] != nil and o.matriz[i] != nil)
226
+
227
+ # cogemos matriz como base para la suma
228
+ suma[i] = matriz[i]
229
+
230
+ o.matriz[i].each do |key, value|
231
+
232
+ if suma[i].has_key?(key)
233
+ suma[i][key] = suma[i][key] + o.matriz[i][key]
234
+ else
235
+ suma[i][key] = o.matriz[i][key]
236
+ end
237
+
238
+ end
239
+
240
+ # matriz tiene hash
241
+ when matriz[i] != nil
242
+ suma[i] = matriz[i]
243
+
244
+ # o hash
245
+ when o.matriz[i] != nil
246
+ suma[i] = o.matriz[i]
247
+
248
+
249
+ end
250
+
251
+ end
252
+
253
+ end
254
+ MatrizDispersa.new(suma)
255
+
256
+ end
257
+
258
+ # Resta de matrices
259
+ def -(o)
260
+
261
+ resta = Array.new(matriz.size - 1)
262
+ for i in 0...matriz.size
263
+
264
+ # creamos el hash
265
+ if (matriz[i] != nil or o.matriz[i] != nil)
266
+
267
+ resta[i] = Hash.new()
268
+
269
+ case true
270
+
271
+ # Los dos tienen hash
272
+ when (matriz[i] != nil and o.matriz[i] != nil)
273
+
274
+ # cogemos matriz como base para la resta
275
+ resta[i] = matriz[i]
276
+
277
+ o.matriz[i].each do |key, value|
278
+
279
+ if resta[i].has_key?(key)
280
+ resta[i][key] = resta[i][key] - o.matriz[i][key]
281
+ else
282
+ resta[i][key] = o.matriz[i][key] * -1
283
+ end
284
+
285
+ end
286
+
287
+ # matriz tiene hash
288
+ when matriz[i] != nil
289
+ resta[i] = matriz[i]
290
+
291
+ # o hash
292
+ when o.matriz[i] != nil
293
+ resta[i] = o.matriz[i]
294
+ resta[i].each do |key, value|
295
+ resta[i][key] = resta[i][key] * -1
296
+ end
297
+
298
+ end
299
+
300
+ end
301
+
302
+ end
303
+ MatrizDispersa.new(resta)
304
+
305
+ end
306
+
307
+ =begin
308
+ # Multiplicación de matrices
309
+ def *(o)
310
+
311
+ prod = Array.new(matriz.size - 1,0)
312
+ for i in 0...matriz.size
313
+
314
+ if (o.matriz[i] != nil)
315
+
316
+ aux = 0
317
+ for j in 0...o.matriz.size
318
+
319
+ if (matriz[j] != nil)
320
+
321
+ if matriz[j].has_key?(i)
322
+
323
+ # No existe hash en la fila
324
+ if prod[j] != nil
325
+ prod[j] = Hash.new()
326
+ end
327
+
328
+ aux = aux + (o.matriz[i][j] * matriz[j][i])
329
+
330
+ end
331
+
332
+ end
333
+
334
+ end
335
+ if aux <> 0
336
+ prod.merge!({"#{}" => "#{aux}"})
337
+ end
338
+
339
+ end
340
+
341
+ # prod[i][j] = prod[i][j] + (matriz[i][pos] * o.matriz[pos][j])
342
+
343
+
344
+
345
+ end
346
+ MatrizDispersa.new(prod)
347
+
348
+ end
349
+
350
+ =end
351
+
352
+ # Máximo de matriz
353
+ def max
354
+
355
+ maximo = 0.to_f
356
+ for i in 0...matriz.size
357
+ # Hay datos en la fila
358
+ if matriz[i] != nil
359
+ matriz[i].each do |key, value|
360
+ if matriz[i][key].to_f > maximo
361
+ maximo = matriz[i][key].to_f
362
+ end
363
+ end
364
+ end
365
+ end
366
+ maximo
367
+
368
+ end
369
+
370
+ # Minimo de matriz
371
+ def min
372
+
373
+ minimo = 0.to_f
374
+ for i in 0...matriz.size
375
+ # Hay datos en la fila
376
+ if matriz[i] != nil
377
+ matriz[i].each do |key, value|
378
+ if matriz[i][key].to_f < minimo
379
+ minimo = matriz[i][key].to_f
380
+ end
381
+ end
382
+ end
383
+ end
384
+ minimo
385
+
386
+ end
387
+
388
+ end
389
+
390
+ end
391
+
data/lib/racional.rb ADDED
@@ -0,0 +1,89 @@
1
+ # racional.rb
2
+ require "gcd"
3
+
4
+ class Racional
5
+
6
+ include Comparable
7
+
8
+ # Se inicializa la fracción en su forma reducida haciendo uso de gcd
9
+ def initialize(num, denom)
10
+
11
+ raise TypeError, "El denominador debe ser mayor que cero" unless (denom != 0)
12
+
13
+ div = gcd(num, denom)
14
+ @num = num/div
15
+ @denom = denom/div
16
+
17
+ end
18
+
19
+ # Gets y Sets de @num y @denom
20
+ attr_reader :num, :denom
21
+
22
+ #mostar por la consola la fraccion de la forma: a/b
23
+ def to_s
24
+ "#{num}/#{denom}"
25
+ end
26
+
27
+ #comparar que dos fracciones son iguales
28
+ def ==(o)
29
+ if o.instance_of? Racional
30
+ @num == o.num && @denom == o.denom
31
+ else
32
+ false
33
+ end
34
+ end
35
+
36
+ # Mostar la fraccion en formato flotante
37
+ def to_f
38
+ num.to_f/denom
39
+ end
40
+
41
+ # Calcular el valor absoluto de una fraccion con el metodo abs
42
+ def abs
43
+ Racional.new(num.abs, denom.abs)
44
+ end
45
+
46
+ # calcular el reciproco de una fraccion con el metodo reciprocal
47
+ def reciprocal
48
+ Racional.new(denom, num)
49
+ end
50
+
51
+ # Calcular el opuesto de una fraccion con -
52
+ def -@
53
+ Racional.new(-denom, num)
54
+ end
55
+
56
+ # suma dos fracciones con + y dar el resultado de forma reducida
57
+ def +(o)
58
+ Racional.new(num*o.denom + o.num*denom, denom*o.denom)
59
+ end
60
+
61
+ # resta dos fracciones con - y dar el resultado de forma reducida
62
+ def -(o)
63
+ Racional.new(num*o.denom - o.num*denom, denom*o.denom)
64
+ end
65
+
66
+ #multiplica dos fracciones con * y dar el resultado de forma reducida
67
+ def *(o)
68
+ Racional.new(num*o.num,denom*o.denom)
69
+ end
70
+
71
+ # divide dos fracciones con / y dar el resultado de forma reducida
72
+ def /(o)
73
+ Racional.new(num*o.denom,denom*o.num)
74
+ end
75
+
76
+ # calcula el resto dos fracciones con % y dar el resultado de forma reducida
77
+ def %(o)
78
+ Racional.new(num%denom, o.num%o.denom)
79
+ end
80
+
81
+ # Comparación de mayor, mayor igual, menor, menor igual
82
+ def <=>(o)
83
+ return nil unless o.instance_of? Racional
84
+ (num.to_f / denom) <=> (o.num.to_f / o.denom)
85
+ end
86
+
87
+ end
88
+
89
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'modai_prct10/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "modai_prct10"
8
+ spec.version = ModaiPrct10::VERSION
9
+ spec.authors = ["Dailos Herrera Bencomo y Mohammed Mahrach"]
10
+ spec.email = ["alu0100036862@etsii.ull.es"]
11
+ spec.description = %q{Simply generates modai_prct10 ipsum text.}
12
+ spec.summary = %q{modai_prct10 ipsum generator}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,218 @@
1
+ require 'spec_helper'
2
+ require 'modai_prct10'
3
+ include ModaiPrct10
4
+
5
+ describe ModaiPrct10 do
6
+
7
+ before :each do
8
+
9
+ # Matrices DENSAS
10
+ matA = [[1,2],[3,4]]
11
+ matB = [[221,2],[3,4]]
12
+
13
+ matA_R = [[Racional.new(1,1),Racional.new(4,2)],[Racional.new(9,3),Racional.new(16,4)]]
14
+ matB_R = [[Racional.new(442,2),Racional.new(4,2)],[Racional.new(9,3),Racional.new(16,4)]]
15
+
16
+ @matrizA = MatrizDensa.new(matA)
17
+ @matrizB = MatrizDensa.new(matB)
18
+
19
+ @matrizA_R = MatrizDensa.new(matA_R)
20
+ @matrizB_R = MatrizDensa.new(matB_R)
21
+
22
+ # Matrices DISPERSAS
23
+ matC = [nil, {1 => 4}] # [[0,0],[0,4]]
24
+ matD = [{0 => 5}, nil] # [[5,0],[0,0]]
25
+
26
+ matC_R = [nil, {1 => Racional.new(4,1)}] # [[Racional.new(0,1),Racional.new(0,1)],[Racional.new(0,1),Racional.new(4,1)]]
27
+ matD_R = [{0 => Racional.new(5,1)}, nil] # [[Racional.new(5,1),Racional.new(0,1)],[Racional.new(0,1),Racional.new(0,1)]]
28
+
29
+ @matrizC = MatrizDispersa.new(matC)
30
+ @matrizC = MatrizDispersa.new(matD)
31
+
32
+ @matrizC_R = MatrizDispersa.new(matC_R)
33
+ @matrizC_R = MatrizDispersa.new(matD_R)
34
+
35
+ end
36
+
37
+ context 'comprobar los accessors (DENSA)' do
38
+
39
+ it "Se debe invocar al metodo matriz() para obtener la matriz (DENSA)" do
40
+ @matrizA.respond_to?("matriz").should == true
41
+ end
42
+
43
+ it "Se debe invocar al metodo filas() para obtener el numero de filas (DENSA)" do
44
+ @matrizA.respond_to?("filas").should == true
45
+ end
46
+
47
+ it "Se debe invocar al metodo columnas() para obtener el numero de columnas (DENSA)" do
48
+ @matrizA.respond_to?("columnas").should == true
49
+ end
50
+
51
+ it "Se debe invocar al metodo matriz() para obtener la matriz de racionales (DENSA)" do
52
+ @matrizA_R.respond_to?("matriz").should == true
53
+ end
54
+
55
+ it "Se debe invocar al metodo filas() para obtener el numero de filas de matriz de racionales (DENSA)" do
56
+ @matrizA_R.respond_to?("filas").should == true
57
+ end
58
+
59
+ it "Se debe invocar al metodo columnas() para obtener el numero de columnas de matriz de racionales (DENSA)" do
60
+ @matrizA_R.respond_to?("columnas").should == true
61
+ end
62
+
63
+ end
64
+
65
+ context 'Comprobar metodos de conversion (DENSA)' do
66
+
67
+ it "Se debe mostrar la matriz (DENSA)" do
68
+ @matrizA.to_s.should == MatrizDensa.new([[1,2],[3,4]]).to_s
69
+ end
70
+
71
+ it "Se debe convertir a punto flotantes (DENSA)" do
72
+ @matrizA.to_f.to_s.should == MatrizDensa.new([[1.0,2.0],[3.0,4.0]]).to_s
73
+ end
74
+
75
+ it "Se debe mostrar la matriz de racionales (DENSA)" do
76
+ @matrizA_R.to_s.should == MatrizDensa.new([[Racional.new(1,1),Racional.new(4,2)],[Racional.new(9,3),Racional.new(16,4)]]).to_s
77
+ end
78
+
79
+ end
80
+
81
+ context 'Comprobar las operaciones entre matrices (DENSA)' do
82
+
83
+ it "Se debe poder sumar dos matrices (DENSA)" do
84
+ (@matrizA + @matrizB).to_s.should == MatrizDensa.new([[222,4], [6,8]]).to_s
85
+ end
86
+
87
+ it "Se debe poder restar dos matrices (DENSA)" do
88
+ (@matrizA - @matrizB).to_s.should == MatrizDensa.new([[-220,0], [0,0]]).to_s
89
+ end
90
+
91
+ it "Se debe poder multiplicar dos matrices (DENSA)" do
92
+ (@matrizA * @matrizB).to_s.should == MatrizDensa.new([[227,10], [675,22]]).to_s
93
+ end
94
+
95
+ it "Se debe poder sumar dos matrices de racionales (DENSA)" do
96
+ (@matrizA_R + @matrizB_R).to_s.should == MatrizDensa.new([[Racional.new(222,1),Racional.new(4,1)],[Racional.new(6,1),Racional.new(8,1)]]).to_s
97
+ end
98
+
99
+ it "Se debe poder restar dos matrices de racionales (DENSA)" do
100
+ (@matrizA_R - @matrizB_R).to_s.should == MatrizDensa.new([[Racional.new(-220,1),Racional.new(0,1)],[Racional.new(0,1),Racional.new(0,1)]]).to_s
101
+ end
102
+
103
+ end
104
+
105
+ context 'Comprobar las operaciones de la propia matriz (DENSA)' do
106
+
107
+ it "Se debe mostrar el max de la matriz (DENSA)" do
108
+ @matrizA.max == 4.0
109
+ end
110
+
111
+ it "Se debe mostrar el min de la matriz (DENSA)" do
112
+ @matrizA.min == 1.0
113
+ end
114
+
115
+ it "Se debe mostrar el max de la matriz de racionales (DENSA)" do
116
+ @matrizA_R.max == Racional.new(1,1)
117
+ end
118
+
119
+ it "Se debe mostrar el min de la matriz de racionales (DENSA)" do
120
+ @matrizA_R.min == Racional.new(16,4)
121
+ end
122
+
123
+ end
124
+
125
+ context 'comprobar los accessors (DISPERSA)' do
126
+
127
+ it "Se debe invocar al metodo matriz() para obtener la matriz (DISPERSA)" do
128
+ @matrizC.respond_to?("matriz").should == true
129
+ end
130
+
131
+ it "Se debe invocar al metodo filas() para obtener el numero de filas (DISPERSA)" do
132
+ @matrizC.respond_to?("filas").should == true
133
+ end
134
+
135
+ it "Se debe invocar al metodo columnas() para obtener el numero de columnas (DISPERSA)" do
136
+ @matrizC.respond_to?("columnas").should == true
137
+ end
138
+
139
+ it "Se debe invocar al metodo matriz() para obtener la matriz de racionales (DISPERSA)" do
140
+ @matrizC_R.respond_to?("matriz").should == true
141
+ end
142
+
143
+ it "Se debe invocar al metodo filas() para obtener el numero de filas de matriz de racionales (DISPERSA)" do
144
+ @matrizC_R.respond_to?("filas").should == true
145
+ end
146
+
147
+ it "Se debe invocar al metodo columnas() para obtener el numero de columnas de matriz de racionales (DISPERSA)" do
148
+ @matrizC_R.respond_to?("columnas").should == true
149
+ end
150
+
151
+ end
152
+
153
+ context 'Comprobar metodos de conversion (DISPERSA)' do
154
+
155
+ it "Se debe mostrar la matriz (DISPERSA)" do
156
+ @matrizC.to_s.should == MatrizDispersa.new([nil, {1 => 4}]).to_s
157
+ end
158
+
159
+ it "Se debe convertir a punto flotantes (DISPERSA)" do
160
+ @matrizC.to_f.to_s.should == MatrizDispersa.new([nil, {1 => 4.0}]).to_s
161
+ end
162
+
163
+ it "Se debe mostrar la matriz de racionales (DISPERSA)" do
164
+ @matrizC_R.to_s.should == MatrizDispersa.new([nil, {1 => Racional.new(4,1)}]).to_s
165
+ end
166
+
167
+ end
168
+
169
+ context 'Comprobar las operaciones entre matrices (DISPERSA)' do
170
+
171
+
172
+ it "Se debe poder sumar dos matrices (DISPERSA)" do
173
+ (@matrizC + @matrizC).to_s.should == MatrizDispersa.new([{0 => 5}, {1 => 4}]).to_s
174
+ end
175
+
176
+ it "Se debe poder restar dos matrices (DISPERSA)" do
177
+ (@matrizC - @matrizC).to_s.should == MatrizDispersa.new([{0 => -5}, {1 => 4}]).to_s
178
+ end
179
+
180
+ =begin
181
+ it "Se debe poder multiplicar dos matrices (DISPERSA)" do
182
+ (@matrizC * @matrizC).to_s.should == MatrizDispersa.new([[227,10], [675,22]]).to_s
183
+ end
184
+
185
+ =end
186
+ it "Se debe poder sumar dos matrices de racionales (DISPERSA)" do
187
+ (@matrizC_R + @matrizC_R).to_s.should == MatrizDispersa.new([{0 => Racional.new(5,1)}, {1 => Racional.new(4,1)}]).to_s
188
+ end
189
+
190
+ it "Se debe poder restar dos matrices de racionales (DISPERSA)" do
191
+ (@matrizC_R - @matrizC_R).to_s.should == MatrizDispersa.new([{0 => Racional.new(-5,1)}, {1 => Racional.new(4,1)}]).to_s
192
+ end
193
+
194
+ end
195
+
196
+ context 'Comprobar las operaciones de la propia matriz (DISPERSA)' do
197
+
198
+ it "Se debe mostrar el max de la matriz (DISPERSA)" do
199
+ @matrizC.max == 4
200
+ end
201
+
202
+ it "Se debe mostrar el min de la matriz (DISPERSA)" do
203
+ @matrizC.min == 0
204
+ end
205
+
206
+ it "Se debe mostrar el max de la matriz de racionales (DISPERSA)" do
207
+ @matrizC_R.max == Racional.new(4,1)
208
+ end
209
+
210
+ it "Se debe mostrar el min de la matriz de racionales (DISPERSA)" do
211
+ @matrizC_R.min == Racional.new(0,1)
212
+ end
213
+
214
+ end
215
+
216
+ end
217
+
218
+
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: modai_prct10
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dailos Herrera Bencomo y Mohammed Mahrach
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Simply generates modai_prct10 ipsum text.
42
+ email:
43
+ - alu0100036862@etsii.ull.es
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .travis.yml
50
+ - Gemfile
51
+ - Guardfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - lib/gcd.rb
56
+ - lib/modai_prct10.rb
57
+ - lib/modai_prct10/version.rb
58
+ - lib/racional.rb
59
+ - modai_prct10.gemspec
60
+ - spec/modai_prct10_spec.rb
61
+ - spec/spec_helper.rb
62
+ homepage: ''
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.0.3
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: modai_prct10 ipsum generator
86
+ test_files:
87
+ - spec/modai_prct10_spec.rb
88
+ - spec/spec_helper.rb
89
+ has_rdoc: