def define_unary_method( mod, op, conversion = :identity )
      mod.module_eval do
        define_method "#{op}_with_hornetseye" do |a|
          if a.matched?
            if a.dimension == 0 and a.variables.empty?
              target = a.typecode.send conversion
              target.new mod.send( op, a.simplify.get )
            else
              Hornetseye::ElementWise( proc { |x| mod.send op, x },
                                       "#{mod}.#{op}",
                                       proc { |x| x.send conversion } ).
                new(a).force
            end
          else
            send "#{op}_without_hornetseye", a
          end
        end
        alias_method_chain op, :hornetseye
        module_function "#{op}_without_hornetseye"
        module_function op
      end
    end
def define_unary_method( mod, op, conversion = :identity )
      mod.module_eval do
        define_method "#{op}_with_hornetseye" do |a|
          if a.matched?
            if a.dimension == 0 and a.variables.empty?
              target = a.typecode.send conversion
              target.new mod.send( op, a.simplify.get )
            else
              Hornetseye::ElementWise( proc { |x| mod.send op, x },
                                       "#{mod}.#{op}",
                                       proc { |x| x.send conversion } ).
                new(a).force
            end
          else
            send "#{op}_without_hornetseye", a
          end
        end
        alias_method_chain op, :hornetseye
        module_function "#{op}_without_hornetseye"
        module_function op
      end
    end
Extend unary method with capability to handle arrays

 @param [Module] mod The mathematics module.
 @param [Symbol,String] op The unary method to extend.
 @param [Symbol,String] conversion A method for doing the type conversion.
 @return [Proc] The new method.

 @private