Sha256: 8b92a0a7afb6a73b8bbdae147ca49f01a269981cca848cde27cdf3254616fcd6

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

# encoding: utf-8

module Axiom
  class Function
    class Numeric

      # A class representing a exponentiation function
      class Exponentiation < Numeric
        include Comparable, Binary::Invertible, Binary

        undef_method :inverse

        # Return the Exponentiation operation
        #
        # @example
        #   Exponentiation.operation  # => :**
        #
        # @return [Symbol]
        #
        # @api public
        def self.operation
          :**
        end

        # Return the inverse function
        #
        # @example
        #   inverse = exponentiation.inverse
        #
        # @return [Exponentiation]
        #
        # @api public
        def inverse
          self.class.new(left, Division.new(1, right)).memoize(:inverse, self)
        end

        module Methods
          extend Aliasable

          inheritable_alias(
            :**  => :exponent,
            pow: :exponent
          )

          # Return an exponential function
          #
          # @example
          #   exponentiation = attribute.exponent(other)
          #
          # @param [Object] other
          #
          # @return [Exponentiation]
          #
          # @api public
          def exponent(other)
            Exponentiation.new(self, other)
          end

        end # module Methods

        Attribute::Numeric.class_eval { include Methods }
        Numeric.class_eval            { include Methods }

        memoize :inverse

      end # class Exponentiation
    end # class Numeric
  end # class Function
end # module Axiom

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.1 lib/axiom/function/numeric/exponentiation.rb