Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tan + sin funcs #391

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/hvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ static inline Numb operate(Numb a, Numb b) {
case OP_AND: return new_f24(atan2f(av, bv));
case OP_OR: return new_f24(logf(bv) / logf(av));
case OP_XOR: return new_f24(powf(av, bv));
case OP_SHL: return new_f24(sin(av + bv));
case OP_SHR: return new_f24(tan(av + bv));
default: return new_f24(0);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/hvm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ __device__ __host__ inline Numb operate(Numb a, Numb b) {
case OP_AND: return new_f24(atan2f(av, bv));
case OP_OR: return new_f24(logf(bv) / logf(av));
case OP_XOR: return new_f24(powf(av, bv));
case OP_SHL: return new_f24(sin(av + bv));
case OP_SHR: return new_f24(tan(av + bv));
default: return new_f24(0);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/hvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ impl Numb {
OP_AND => Numb::new_f24(av.atan2(bv)),
OP_OR => Numb::new_f24(bv.log(av)),
OP_XOR => Numb::new_f24(av.powf(bv)),
OP_SHL => Numb::new_f24((av + bv).sin()),
OP_SHR => Numb::new_f24((av + bv).tan()),
_ => unreachable!(),
}
}
Expand Down
8 changes: 7 additions & 1 deletion tests/programs/numerics/f24.hvm
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@
@tL = (* {n x}) & @tM ~ (* x) & -1.2 ~ $([%] $(+1.1 n)) // -0.1
@tM = (* {n x}) & @tN ~ (* x) & -1.2 ~ $([%] $(-1.1 n)) // -0.1

@tN = *
// modulo
@tN = (* {n x}) & @tO ~ (* x) & +0.0 ~ $([<<] $(+3.14159265 n)) // ~0
@tO = (* {n x}) & @tP ~ (* x) & +1.570796325 ~ $([<<] $(+0.0 n)) // 1.0
@tP = (* {n x}) & @tQ ~ (* x) & +0.0 ~ $([>>] $(+3.14159265 n)) // ~0
@tQ = (* {n x}) & @tR ~ (* x) & +0.785398162 ~ $([>>] $(+0.0 n)) // 1.0

@tR = *
4 changes: 2 additions & 2 deletions tests/snapshots/run__file@numerics__f24.hvm.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: tests/run.rs
expression: rust_output
input_file: tests/programs/f24.hvm
input_file: tests/programs/numerics/f24.hvm
---
Result: {+inf {-inf {+NaN {2.5 {-1.5 {1.1499939 {0.25 {0.5 {0 {1 {1 {0 {0 {0 {0 {+NaN {+inf {-inf {1.019989 {0.1000061 {0.1000061 {-0.1000061 {-0.1000061 *}}}}}}}}}}}}}}}}}}}}}}}
Result: {+inf {-inf {+NaN {2.5 {-1.5 {1.1499939 {0.25 {0.5 {0 {1 {1 {0 {0 {0 {0 {+NaN {+inf {-inf {1.019989 {0.1000061 {0.1000061 {-0.1000061 {-0.1000061 {-8.908799e-6 {1.0 {8.908799e-6 {1.0 *}}}}}}}}}}}}}}}}}}}}}}}}}}}
Loading