Sha256: 770d0e1ce0438a836f716bf41c5f9e0bc98496f82b444a66de5282e490268543

Contents?: true

Size: 792 Bytes

Versions: 2

Compression:

Stored size: 792 Bytes

Contents

require 'symath/value'
require 'symath/definition/operator'

module SyMath
  class Definition::CoDiff < Definition::Operator
    def initialize()
      # The co-differential is defined as: (-1)**(n*k+ 1)*d*(F).
      # n : Dimension of the basis vector space
      # k : Grade of input function F
      # (the sign is calculated by the overridden evaluate method)
      super(:codiff, args: [:f], exp: 'hodge(xd(hodge(f)))')
    end

    def description()
      return 'codiff(f) - codifferential of function f'
    end

    def evaluate_call(c)
      vars = SyMath.get_variable(:basis.to_m).row(0)
      n = vars.length
      k = c.args[0].type.degree
      sign = ((-1)**(n*k + 1)).to_m

      return sign*super(c)
    end

    def latex_format()
      return '\delta %s'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
symath-0.1.1 lib/symath/definition/codiff.rb
symath-0.1.0 lib/symath/definition/codiff.rb