Class: BooleanMatrix
Constant Summary collapse
- @@masks_max =
1000
- @@masks =
calc_masks(0,@@masks_max)
Instance Method Summary collapse
- #directed_graph ⇒ Object
- #indices(anInteger) ⇒ Object
-
#initialize(objects) ⇒ BooleanMatrix
constructor
A new instance of BooleanMatrix.
- #mask(index) ⇒ Object
- #or(index1, index2) ⇒ Object
- #transitive_closure ⇒ Object
Constructor Details
#initialize(objects) ⇒ BooleanMatrix
Returns a new instance of BooleanMatrix.
348 349 350 351 352 353 354 355 356 357 |
# File 'lib/rpdf2txt-rockit/directed_graph.rb', line 348 def initialize(objects) @index, @objects, @matrix = Hash.new, objects, Array.new cnt = 0 objects.each do |o| @index[o] = cnt @matrix[cnt] = 0 # Use Integers to represent the booleans cnt += 1 end @num_obects = cnt end |
Instance Method Details
#directed_graph ⇒ Object
384 385 386 387 388 389 390 391 392 |
# File 'lib/rpdf2txt-rockit/directed_graph.rb', line 384 def directed_graph dg = Directedgraph.new @matrix.each_with_index do |v,i| indices(v) do |index| dg.link_nodes(@objects[i], @objects[index]) end end dg end |
#indices(anInteger) ⇒ Object
375 376 377 378 379 380 381 382 |
# File 'lib/rpdf2txt-rockit/directed_graph.rb', line 375 def indices(anInteger) index = 0 while anInteger > 0 yeild(index) if anInteger & 1 anInteger >>= 1 index += 1 end end |
#mask(index) ⇒ Object
362 363 364 365 366 367 368 369 |
# File 'lib/rpdf2txt-rockit/directed_graph.rb', line 362 def mask(index) mask = @@masks[index] unless mask calc_masks(@@masks_max+1, index, @@masks) mask = @masks[index] end mask end |
#or(index1, index2) ⇒ Object
371 372 373 |
# File 'lib/rpdf2txt-rockit/directed_graph.rb', line 371 def or(index1, index2) @matrix[index1] |= @matrix[index2] end |
#transitive_closure ⇒ Object
394 395 396 397 398 399 400 |
# File 'lib/rpdf2txt-rockit/directed_graph.rb', line 394 def transitive_closure for i in (0..@num_obects) for j in (0..@num_obects) end end end |