mirror of
https://github.com/ziglang/zig.git
synced 2024-11-14 16:13:24 +00:00
Remove math.ln in favor of @log
This commit is contained in:
parent
4d7dd1689f
commit
9e19969e09
@ -273,7 +273,6 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/frexp.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/isinf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/isnan.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/ln.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/log.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/log10.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/log2.zig"
|
||||
|
@ -244,7 +244,6 @@ pub const atan2 = @import("math/atan2.zig").atan2;
|
||||
pub const hypot = @import("math/hypot.zig").hypot;
|
||||
pub const expm1 = @import("math/expm1.zig").expm1;
|
||||
pub const ilogb = @import("math/ilogb.zig").ilogb;
|
||||
pub const ln = @import("math/ln.zig").ln;
|
||||
pub const log = @import("math/log.zig").log;
|
||||
pub const log2 = @import("math/log2.zig").log2;
|
||||
pub const log10 = @import("math/log10.zig").log10;
|
||||
@ -395,7 +394,6 @@ test {
|
||||
_ = hypot;
|
||||
_ = expm1;
|
||||
_ = ilogb;
|
||||
_ = ln;
|
||||
_ = log;
|
||||
_ = log2;
|
||||
_ = log10;
|
||||
@ -438,6 +436,7 @@ pub const min = @compileError("deprecated; use @min instead");
|
||||
pub const max = @compileError("deprecated; use @max instead");
|
||||
pub const min3 = @compileError("deprecated; use @min instead");
|
||||
pub const max3 = @compileError("deprecated; use @max instead");
|
||||
pub const ln = @compileError("deprecated; use @log instead");
|
||||
|
||||
/// Limit val to the inclusive range [lower, upper].
|
||||
pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) {
|
||||
|
@ -1,34 +0,0 @@
|
||||
const std = @import("../std.zig");
|
||||
const math = std.math;
|
||||
const testing = std.testing;
|
||||
|
||||
/// Returns the natural logarithm of x.
|
||||
///
|
||||
/// Special Cases:
|
||||
/// - ln(+inf) = +inf
|
||||
/// - ln(0) = -inf
|
||||
/// - ln(x) = nan if x < 0
|
||||
/// - ln(nan) = nan
|
||||
/// TODO remove this in favor of `@log`.
|
||||
pub fn ln(x: anytype) @TypeOf(x) {
|
||||
const T = @TypeOf(x);
|
||||
switch (@typeInfo(T)) {
|
||||
.ComptimeFloat => {
|
||||
return @as(comptime_float, @log(x));
|
||||
},
|
||||
.Float => return @log(x),
|
||||
.ComptimeInt => {
|
||||
return @as(comptime_int, @floor(@log(@as(f64, x))));
|
||||
},
|
||||
.Int => |IntType| switch (IntType.signedness) {
|
||||
.signed => @compileError("ln not implemented for signed integers"),
|
||||
.unsigned => return @as(T, @floor(@log(@as(f64, x)))),
|
||||
},
|
||||
else => @compileError("ln not implemented for " ++ @typeName(T)),
|
||||
}
|
||||
}
|
||||
|
||||
test "math.ln" {
|
||||
try testing.expect(ln(@as(f32, 0.2)) == @log(0.2));
|
||||
try testing.expect(ln(@as(f64, 0.2)) == @log(0.2));
|
||||
}
|
Loading…
Reference in New Issue
Block a user