Module: SyMath::Operation::Exterior
- Included in:
- Value
- Defined in:
- lib/symath/operation/exterior.rb
Instance Method Summary collapse
-
#flat ⇒ Object
Lower indices, transforming vectors to differential forms.
-
#hodge ⇒ Object
Calculate hodge star duality.
-
#sharp ⇒ Object
Raise indices, transforming differential forms to vectors.
Instance Method Details
#flat ⇒ Object
Lower indices, transforming vectors to differential forms
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/symath/operation/exterior.rb', line 9 def flat() res = recurse('flat', nil) if res.is_a?(SyMath::Definition::Variable) if res.type.is_subtype?('vector') return res.lower_vector end end return res end |
#hodge ⇒ Object
Calculate hodge star duality
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/symath/operation/exterior.rb', line 35 def hodge() # Recurse down sums and subtractions if is_sum_exp? return terms.map do |t| if t.is_a?(SyMath::Minus) - t.argument.hodge else t.hodge end end.inject(:+) else # FIXME: If expression is a product of sums, expand the product first # (distributive law), then hodge op on the new sum. # Replace nvectors and nforms with their hodge dual s = [] v = [] factors.each do |f| if f.type.is_vector? or f.type.is_dform? v.push f else s.push f end end h = SyMath::Definition::Variable.hodge_dual(v.inject(1.to_m, :*)) return s.inject(1.to_m, :*)*h end end |
#sharp ⇒ Object
Raise indices, transforming differential forms to vectors
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/symath/operation/exterior.rb', line 22 def sharp() res = recurse('sharp', nil) if res.is_a?(SyMath::Definition::Variable) if res.type.is_subtype?('dform') return res.raise_dform end end return res end |