Class: Numeric

Inherits:
Object show all
Defined in:
lib/algebra/numeric-supplement.rb

Overview

Numeric Supplements

by Shin-ichiro Hara

Version 1.01 (2001.04.10)

Direct Known Subclasses

Complex, Float, Integer, Rational

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.const(x) ⇒ Object



28
29
30
# File 'lib/algebra/numeric-supplement.rb', line 28

def self.const(x)
  x
end

.euclidian?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/algebra/numeric-supplement.rb', line 58

def self.euclidian?
  true
end

.field?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/algebra/numeric-supplement.rb', line 54

def self.field?
  true
end

.indeterminate(x) ⇒ Object



24
25
26
# File 'lib/algebra/numeric-supplement.rb', line 24

def self.indeterminate(x)
  eval(x)
end

.regulate(x) ⇒ Object



66
67
68
69
70
71
# File 'lib/algebra/numeric-supplement.rb', line 66

def self.regulate(x)
  #    if x.is_a? self
  if x.is_a? Numeric
    x # Numeric's can be operated each other.
  end
end

.ufd?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/algebra/numeric-supplement.rb', line 62

def self.ufd?
  true
end

.unityObject



8
9
10
# File 'lib/algebra/numeric-supplement.rb', line 8

def self.unity
  1
end

.zeroObject



12
13
14
# File 'lib/algebra/numeric-supplement.rb', line 12

def self.zero
  0
end

Instance Method Details

#eachObject



32
# File 'lib/algebra/numeric-supplement.rb', line 32

def each; end

#inverseObject



50
51
52
# File 'lib/algebra/numeric-supplement.rb', line 50

def inverse
  self == -1 ? -1 : 1
end

#monomial?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/algebra/numeric-supplement.rb', line 46

def monomial?
  true
end

#pdivmod(other) ⇒ Object



34
35
36
# File 'lib/algebra/numeric-supplement.rb', line 34

def pdivmod(other)
  divmod(other)
end

#unit?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/algebra/numeric-supplement.rb', line 42

def unit?
  self == unity || self == -unity
end

#unityObject



20
21
22
# File 'lib/algebra/numeric-supplement.rb', line 20

def unity
  self.class.unity
end

#unity?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/algebra/numeric-supplement.rb', line 38

def unity?
  self == 1
end

#zeroObject



16
17
18
# File 'lib/algebra/numeric-supplement.rb', line 16

def zero
  self.class.zero
end