Switch Num.tan to a zig builtin

It should be able to share some work between sine and cosine to run faster.
This commit is contained in:
Brendan Hansknecht 2023-09-16 21:27:51 -07:00
parent 7986d6cdba
commit 108d9a54e3
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
11 changed files with 25 additions and 4 deletions

View file

@ -163,6 +163,7 @@ comptime {
num.exportSin(T, ROC_BUILTINS ++ "." ++ NUM ++ ".sin.");
num.exportCos(T, ROC_BUILTINS ++ "." ++ NUM ++ ".cos.");
num.exportTan(T, ROC_BUILTINS ++ "." ++ NUM ++ ".tan.");
num.exportPow(T, ROC_BUILTINS ++ "." ++ NUM ++ ".pow.");
num.exportLog(T, ROC_BUILTINS ++ "." ++ NUM ++ ".log.");

View file

@ -168,6 +168,15 @@ pub fn exportCos(comptime T: type, comptime name: []const u8) void {
@export(f, .{ .name = name ++ @typeName(T), .linkage = .Strong });
}
pub fn exportTan(comptime T: type, comptime name: []const u8) void {
comptime var f = struct {
fn func(input: T) callconv(.C) T {
return math.tan(input);
}
}.func;
@export(f, .{ .name = name ++ @typeName(T), .linkage = .Strong });
}
pub fn exportLog(comptime T: type, comptime name: []const u8) void {
comptime var f = struct {
fn func(input: T) callconv(.C) T {