Sha256: dcb18b68b32e89d760f8c9394c214c0c6eae11ece53035184718b4aaaa7ec834

Contents?: true

Size: 670 Bytes

Versions: 3

Compression:

Stored size: 670 Bytes

Contents

module Dydx
  module Algebra
    module Operator
      module Parts
        module Inverse
          def +(x)
            if self.x == x && operator == :+
              e0
            elsif !x.is_a?(Inverse)
              x + self
            else
              super(x)
            end
          end

          def *(x)
            if self.x == x && operator == :*
              e1
            else
              super(x)
            end
          end

          def ^(x)
            case operator
            when :+
              super(x)
            when :*
              inverse(self.x ^ x, :*)
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dydx-0.0.7 lib/dydx/algebra/operator/parts/inverse.rb
dydx-0.0.6 lib/dydx/algebra/operator/parts/inverse.rb
dydx-0.0.5 lib/dydx/algebra/operator/parts/inverse.rb