| author | |
| committer | |
| log | 9e19969e09ffee8aca39f28a42d566cc62b479d6 |
| tree | 794fd9d774e0ee7e7d3f6ad80d092697b045e86b |
| parent | 4d7dd1689fb1e7344fa9e4ca80394369569d0379 |
3 files changed, 1 insertions(+), 37 deletions(-)
CMakeLists.txt-1| ... | ... | @@ -273,7 +273,6 @@ set(ZIG_STAGE2_SOURCES |
| 273 | 273 | "${CMAKE_SOURCE_DIR}/lib/std/math/frexp.zig" |
| 274 | 274 | "${CMAKE_SOURCE_DIR}/lib/std/math/isinf.zig" |
| 275 | 275 | "${CMAKE_SOURCE_DIR}/lib/std/math/isnan.zig" |
| 276 | "${CMAKE_SOURCE_DIR}/lib/std/math/ln.zig" | |
| 277 | 276 | "${CMAKE_SOURCE_DIR}/lib/std/math/log.zig" |
| 278 | 277 | "${CMAKE_SOURCE_DIR}/lib/std/math/log10.zig" |
| 279 | 278 | "${CMAKE_SOURCE_DIR}/lib/std/math/log2.zig" |
lib/std/math.zig+1-2| ... | ... | @@ -244,7 +244,6 @@ pub const atan2 = @import("math/atan2.zig").atan2; |
| 244 | 244 | pub const hypot = @import("math/hypot.zig").hypot; |
| 245 | 245 | pub const expm1 = @import("math/expm1.zig").expm1; |
| 246 | 246 | pub const ilogb = @import("math/ilogb.zig").ilogb; |
| 247 | pub const ln = @import("math/ln.zig").ln; | |
| 248 | 247 | pub const log = @import("math/log.zig").log; |
| 249 | 248 | pub const log2 = @import("math/log2.zig").log2; |
| 250 | 249 | pub const log10 = @import("math/log10.zig").log10; |
| ... | ... | @@ -395,7 +394,6 @@ test { |
| 395 | 394 | _ = hypot; |
| 396 | 395 | _ = expm1; |
| 397 | 396 | _ = ilogb; |
| 398 | _ = ln; | |
| 399 | 397 | _ = log; |
| 400 | 398 | _ = log2; |
| 401 | 399 | _ = log10; |
| ... | ... | @@ -438,6 +436,7 @@ pub const min = @compileError("deprecated; use @min instead"); |
| 438 | 436 | pub const max = @compileError("deprecated; use @max instead"); |
| 439 | 437 | pub const min3 = @compileError("deprecated; use @min instead"); |
| 440 | 438 | pub const max3 = @compileError("deprecated; use @max instead"); |
| 439 | pub const ln = @compileError("deprecated; use @log instead"); | |
| 441 | 440 | |
| 442 | 441 | /// Limit val to the inclusive range [lower, upper]. |
| 443 | 442 | pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) { |
lib/std/math/ln.zig deleted-34| ... | ... | @@ -1,34 +0,0 @@ |
| 1 | const std = @import("../std.zig"); | |
| 2 | const math = std.math; | |
| 3 | const testing = std.testing; | |
| 4 | ||
| 5 | /// Returns the natural logarithm of x. | |
| 6 | /// | |
| 7 | /// Special Cases: | |
| 8 | /// - ln(+inf) = +inf | |
| 9 | /// - ln(0) = -inf | |
| 10 | /// - ln(x) = nan if x < 0 | |
| 11 | /// - ln(nan) = nan | |
| 12 | /// TODO remove this in favor of `@log`. | |
| 13 | pub fn ln(x: anytype) @TypeOf(x) { | |
| 14 | const T = @TypeOf(x); | |
| 15 | switch (@typeInfo(T)) { | |
| 16 | .ComptimeFloat => { | |
| 17 | return @as(comptime_float, @log(x)); | |
| 18 | }, | |
| 19 | .Float => return @log(x), | |
| 20 | .ComptimeInt => { | |
| 21 | return @as(comptime_int, @floor(@log(@as(f64, x)))); | |
| 22 | }, | |
| 23 | .Int => |IntType| switch (IntType.signedness) { | |
| 24 | .signed => @compileError("ln not implemented for signed integers"), | |
| 25 | .unsigned => return @as(T, @floor(@log(@as(f64, x)))), | |
| 26 | }, | |
| 27 | else => @compileError("ln not implemented for " ++ @typeName(T)), | |
| 28 | } | |
| 29 | } | |
| 30 | ||
| 31 | test "math.ln" { | |
| 32 | try testing.expect(ln(@as(f32, 0.2)) == @log(0.2)); | |
| 33 | try testing.expect(ln(@as(f64, 0.2)) == @log(0.2)); | |
| 34 | } |