Module: Algebra::AlgebraCreator
- Included in:
- LocalizedRing, MPolynomial, MatrixAlgebra, Polynomial, ResidueClassRing
- Defined in:
- lib/algebra/algebraic-system.rb
Instance Method Summary collapse
- #create(ground) ⇒ Object
- #superior?(otype) ⇒ Boolean
- #sysvar(var_name, value = nil, sw = false) ⇒ Object
-
#wedge(otype) ⇒ Object
Needed in the type conversion of MatrixAlgebra.
Instance Method Details
#create(ground) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/algebra/algebraic-system.rb', line 12 def create(ground) klass = Class.new(self) klass.sysvar :ground, ground def klass.inspect to_s end def klass.to_s s = super s = "(#{superclass.inspect}/#{ground.inspect})" if s =~ /^#/ # / s.gsub(/Algebra::/, '') end klass end |
#superior?(otype) ⇒ Boolean
38 39 40 41 42 43 44 45 46 |
# File 'lib/algebra/algebraic-system.rb', line 38 def superior?(otype) if otype <= Numeric || self <= otype true elsif respond_to?(:ground) && ground.respond_to?(:superior?) ground.superior?(otype) else false end end |
#sysvar(var_name, value = nil, sw = false) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/algebra/algebraic-system.rb', line 48 def sysvar(var_name, value = nil, sw = false) var_name = var_name.id2name if var_name.is_a?(Symbol) class_eval " @@\#{var_name} = nil\n def self.\#{var_name}; @@\#{var_name}; end\n def self.\#{var_name}=(value); @@\#{var_name} = value; end\n" send(var_name + '=', value) if value if sw class_eval " def \#{var_name}; @@\#{var_name}; end\n def \#{var_name}=(value); @@\#{var_name} = value; end\n" end end |
#wedge(otype) ⇒ Object
Needed in the type conversion of MatrixAlgebra
28 29 30 31 32 33 34 35 36 |
# File 'lib/algebra/algebraic-system.rb', line 28 def wedge(otype) # =:= tensor if superior?(otype) self elsif otype.respond_to?(:superior?) && otype.superior?(self) otype else raise "wedge: unknown pair (#{self}) .wedge (#{otype})" end end |