vector.rb
def abs(type=:L2)
      raise ArgumentError, "Required a Symbol (:L1, :L2, :Linf)" unless type.is_a? Symbol
      case type
      when :L1
        return @vector.inject { |s, e| s += e.abs }
      when :L2
        return Math::sqrt(@vector.inject { |s, e| s += (e ** 2) })
      when :Linf
        return @vector.max
      else
        raise CalcoloNumericoError, "Unknown norm"
      end
    end
##
# Returns the norm, usually norm L2, but can be selected also
# norm l1 and norm infinity
Returns the norm, usually norm L2, but can be selected also
norm l1 and norm infinity
Returns the norm usually norm L2 but can be selected also norm l1 and norm infinity
def abs(type=:L2)
      raise ArgumentError, "Required a Symbol (:L1, :L2, :Linf)" unless type.is_a? Symbol
      case type
      when :L1
        return @vector.inject { |s, e| s += e.abs }
      when :L2
        return Math::sqrt(@vector.inject { |s, e| s += (e ** 2) })
      when :Linf
        return @vector.max
      else
        raise CalcoloNumericoError, "Unknown norm"
      end
    end
def abs ( type = :L2 ) raise ArgumentError , "Required a Symbol (:L1, :L2, :Linf)" unless type . is_a? Symbol case type when :L1 return @vector . inject { | s , e | s += e . abs } when :L2 return Math :: sqrt ( @vector . inject { | s , e | s += ( e ** 2 ) } ) when :Linf return @vector . max else raise CalcoloNumericoError , "Unknown norm" end end
Returns the norm, usually norm L2, but can be selected also
norm l1 and norm infinity
Returns the norm usually norm L2 but can be selected also norm l1 and norm infinity
type