Module: StairCar::PMatrixCompare

Included in:
PMatrix
Defined in:
lib/stair_car/pmatrix/compare.rb

Instance Method Summary collapse

Instance Method Details

#<(val) ⇒ Object



11
12
13
# File 'lib/stair_car/pmatrix/compare.rb', line 11

def <(val)
 map {|v| (v < val) ? 1 : 0 }
end

#<=(val) ⇒ Object



15
16
17
# File 'lib/stair_car/pmatrix/compare.rb', line 15

def <=(val)
  map {|v| (v <= val) ? 1 : 0 }
end

#==(matrix2) ⇒ Object

Compares this matrix to another to see if they are the same (in values)



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/stair_car/pmatrix/compare.rb', line 28

def ==(matrix2)
  if matrix2.is_a?(Fixnum) || matrix2.is_a?(Float)
    # See if its a 1x1
    if rows != 1 || cols != 1
      return false
    else
      # Check if the value matches
      return self.to_i == matrix2
    end
  else
    return self.data.equals(matrix2.data)
  end
end

#>(val) ⇒ Object



3
4
5
# File 'lib/stair_car/pmatrix/compare.rb', line 3

def >(val)
 map {|v| (v > val) ? 1 : 0 }
end

#>=(val) ⇒ Object



7
8
9
# File 'lib/stair_car/pmatrix/compare.rb', line 7

def >=(val)
  map {|v| (v >= val) ? 1 : 0 }
end

#any?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/stair_car/pmatrix/compare.rb', line 23

def any?
  @data.cardinality > 0
end

#find(matrix) ⇒ Object



19
20
21
# File 'lib/stair_car/pmatrix/compare.rb', line 19

def find(matrix)

end