core/math.rbs in rbs-3.2.2 vs core/math.rbs in rbs-3.3.0.pre.1

- old
+ new

@@ -125,10 +125,41 @@ # #### Hypotenuse Function # # * ::hypot: Returns `sqrt(a**2 + b**2)` for the given `a` and `b`. # module Math + # <!-- rdoc-file=math.c --> + # Definition of the mathematical constant E for Euler's number (e) as a Float + # number. + # + E: Float + + # <!-- rdoc-file=math.c --> + # Definition of the mathematical constant PI as a Float number. + # + PI: Float + + # <!-- rdoc-file=math.c --> + # Raised when a mathematical function is evaluated outside of its domain of + # definition. + # + # For example, since `cos` returns values in the range -1..1, its inverse + # function `acos` is only defined on that interval: + # + # Math.acos(42) + # + # *produces:* + # + # Math::DomainError: Numerical argument is out of domain - "acos" + # + class DomainError < StandardError + end + + # A type that's passable to `Math` functions: A `Numeric` type that defines `.to_f`. + # + type double = Numeric & _ToF + # <!-- # rdoc-file=math.c # - Math.acos(x) -> float # --> # Returns the [arc @@ -142,11 +173,11 @@ # # acos(-1.0) # => 3.141592653589793 # PI # acos(0.0) # => 1.5707963267948966 # PI/2 # acos(1.0) # => 0.0 # - def self.acos: (Numeric x) -> Float + def self.acos: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.acosh(x) -> float # --> @@ -160,11 +191,11 @@ # Examples: # # acosh(1.0) # => 0.0 # acosh(INFINITY) # => Infinity # - def self.acosh: (Numeric x) -> Float + def self.acosh: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.asin(x) -> float # --> @@ -179,11 +210,11 @@ # # asin(-1.0) # => -1.5707963267948966 # -PI/2 # asin(0.0) # => 0.0 # asin(1.0) # => 1.5707963267948966 # PI/2 # - def self.asin: (Numeric x) -> Float + def self.asin: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.asinh(x) -> float # --> @@ -198,11 +229,11 @@ # # asinh(-INFINITY) # => -Infinity # asinh(0.0) # => 0.0 # asinh(INFINITY) # => Infinity # - def self.asinh: (Numeric x) -> Float + def self.asinh: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.atan(x) -> Float # --> @@ -222,11 +253,11 @@ # atan(0.0) # => 0.0 # atan(PI/2) # => 1.0038848218538872 # atan(PI) # => 1.2626272556789115 # atan(INFINITY) # => 1.5707963267948966 # PI/2 # - def self.atan: (Numeric x) -> Float + def self.atan: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.atan2(y, x) -> float # --> @@ -245,11 +276,11 @@ # atan2(-1.0, -1.0) # => -2.356194490192345 # -3*PI/4 # atan2(-1.0, 0.0) # => -1.5707963267948966 # -PI/2 # atan2(-1.0, 1.0) # => -0.7853981633974483 # -PI/4 # atan2(0.0, -1.0) # => 3.141592653589793 # PI # - def self.atan2: (Numeric y, Numeric x) -> Float + def self.atan2: (double y, double x) -> Float # <!-- # rdoc-file=math.c # - Math.atanh(x) -> float # --> @@ -264,11 +295,11 @@ # # atanh(-1.0) # => -Infinity # atanh(0.0) # => 0.0 # atanh(1.0) # => Infinity # - def self.atanh: (Numeric x) -> Float + def self.atanh: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.cbrt(x) -> float # --> @@ -290,11 +321,11 @@ # cbrt(2.0) # => 1.2599210498948732 # cbrt(8.0) # => 2.0 # cbrt(27.0) # => 3.0 # cbrt(INFINITY) # => Infinity # - def self.cbrt: (Numeric x) -> Float + def self.cbrt: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.cos(x) -> float # --> @@ -312,11 +343,11 @@ # cos(-PI/2) # => 6.123031769111886e-17 # 0.0000000000000001 # cos(0.0) # => 1.0 # cos(PI/2) # => 6.123031769111886e-17 # 0.0000000000000001 # cos(PI) # => -1.0 # - def self.cos: (Numeric x) -> Float + def self.cos: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.cosh(x) -> float # --> @@ -333,11 +364,11 @@ # # cosh(-INFINITY) # => Infinity # cosh(0.0) # => 1.0 # cosh(INFINITY) # => Infinity # - def self.cosh: (Numeric x) -> Float + def self.cosh: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.erf(x) -> float # --> @@ -354,11 +385,11 @@ # erf(0.0) # => 0.0 # erf(INFINITY) # => 1.0 # # Related: Math.erfc. # - def self.erf: (Numeric x) -> Float + def self.erf: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.erfc(x) -> Float # --> @@ -376,11 +407,11 @@ # erfc(0.0) # => 1.0 # erfc(INFINITY) # => 0.0 # # Related: Math.erf. # - def self.erfc: (Numeric x) -> Float + def self.erfc: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.exp(x) -> float # --> @@ -398,11 +429,11 @@ # exp(0.5) # => 1.6487212707001282 # sqrt(E) # exp(1.0) # => 2.718281828459045 # E # exp(2.0) # => 7.38905609893065 # E**2 # exp(INFINITY) # => Infinity # - def self.exp: (Numeric x) -> Float + def self.exp: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.frexp(x) -> [fraction, exponent] # --> @@ -429,11 +460,11 @@ # frexp(2.0) # => [0.5, 2] # frexp(INFINITY) # => [Infinity, -1] # # Related: Math.ldexp (inverse of Math.frexp). # - def self.frexp: (Numeric x) -> [ Float, Integer ] + def self.frexp: (double x) -> [Float, Integer] # <!-- # rdoc-file=math.c # - Math.gamma(x) -> float # --> @@ -456,11 +487,11 @@ # gamma(4.0) # => 6.0 # gamma(5.0) # => 24.0 # # Related: Math.lgamma. # - def self.gamma: (Numeric x) -> Float + def self.gamma: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.hypot(a, b) -> float # --> @@ -481,11 +512,11 @@ # hypot(1.0, sqrt(3.0)) # => 1.9999999999999998 # Near 2.0 # # Note that if either argument is `INFINITY` or `-INFINITY`, the result is # `Infinity`. # - def self.hypot: (Numeric x, Numeric y) -> Float + def self.hypot: (double x, double y) -> Float # <!-- # rdoc-file=math.c # - Math.ldexp(fraction, exponent) -> float # --> @@ -509,11 +540,11 @@ # ldexp(-0.5, 2) # => 2.0 # ldexp(INFINITY, -1) # => Infinity # # Related: Math.frexp (inverse of Math.ldexp). # - def self.ldexp: (Numeric fraction, Numeric exponent) -> Float + def self.ldexp: (double fraction, int exponent) -> Float # <!-- # rdoc-file=math.c # - Math.lgamma(x) -> [float, -1 or 1] # --> @@ -550,11 +581,11 @@ # lgamma(1.5) # => [-0.12078223763524676, 1] # lgamma(2.5) # => [0.2846828704729205, 1] # # Related: Math.gamma. # - def self.lgamma: (Numeric x) -> [ Float, Integer ] + def self.lgamma: (double x) -> [Float, -1 | 1] # <!-- # rdoc-file=math.c # - Math.log(x, base = Math::E) -> Float # --> @@ -578,11 +609,11 @@ # # log(0.0, 10.0) # => -Infinity # log(1.0, 10.0) # => 0.0 # log(10.0, 10.0) # => 1.0 # - def self.log: (Numeric x, ?Numeric base) -> Float + def self.log: (double x, ?double base) -> Float # <!-- # rdoc-file=math.c # - Math.log10(x) -> float # --> @@ -598,11 +629,11 @@ # log10(0.0) # => -Infinity # log10(1.0) # => 0.0 # log10(10.0) # => 1.0 # log10(INFINITY) # => Infinity # - def self.log10: (Numeric x) -> Float + def self.log10: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.log2(x) -> float # --> @@ -618,11 +649,11 @@ # log2(0.0) # => -Infinity # log2(1.0) # => 0.0 # log2(2.0) # => 1.0 # log2(INFINITY) # => Infinity # - def self.log2: (Numeric x) -> Float + def self.log2: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.sin(x) -> float # --> @@ -640,11 +671,11 @@ # sin(-PI/2) # => -1.0 # sin(0.0) # => 0.0 # sin(PI/2) # => 1.0 # sin(PI) # => 1.2246063538223773e-16 # 0.0000000000000001 # - def self.sin: (Numeric x) -> Float + def self.sin: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.sinh(x) -> float # --> @@ -661,11 +692,11 @@ # # sinh(-INFINITY) # => -Infinity # sinh(0.0) # => 0.0 # sinh(INFINITY) # => Infinity # - def self.sinh: (Numeric x) -> Float + def self.sinh: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.sqrt(x) -> float # --> @@ -684,11 +715,11 @@ # sqrt(2.0) # => 1.4142135623730951 # sqrt(4.0) # => 2.0 # sqrt(9.0) # => 3.0 # sqrt(INFINITY) # => Infinity # - def self.sqrt: (Numeric x) -> Float + def self.sqrt: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.tan(x) -> float # --> @@ -707,11 +738,11 @@ # tan(-PI/2) # => -1.633123935319537e+16 # -16331239353195370.0 # tan(0.0) # => 0.0 # tan(PI/2) # => 1.633123935319537e+16 # 16331239353195370.0 # tan(PI) # => -1.2246467991473532e-16 # -0.0000000000000001 # - def self.tan: (Numeric x) -> Float + def self.tan: (double x) -> Float # <!-- # rdoc-file=math.c # - Math.tanh(x) -> float # --> @@ -728,34 +759,7 @@ # # tanh(-INFINITY) # => -1.0 # tanh(0.0) # => 0.0 # tanh(INFINITY) # => 1.0 # - def self.tanh: (Numeric x) -> Float -end - -# <!-- rdoc-file=math.c --> -# Definition of the mathematical constant E for Euler's number (e) as a Float -# number. -# -Math::E: Float - -# <!-- rdoc-file=math.c --> -# Definition of the mathematical constant PI as a Float number. -# -Math::PI: Float - -# <!-- rdoc-file=math.c --> -# Raised when a mathematical function is evaluated outside of its domain of -# definition. -# -# For example, since `cos` returns values in the range -1..1, its inverse -# function `acos` is only defined on that interval: -# -# Math.acos(42) -# -# *produces:* -# -# Math::DomainError: Numerical argument is out of domain - "acos" -# -class Math::DomainError < StandardError + def self.tanh: (double x) -> Float end