Skip to content

Commit 405cb0a

Browse files
committed
Scaffolding for LUT proc macro
1 parent 73a1cce commit 405cb0a

5 files changed

Lines changed: 36 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ anyhow = "1.0"
1313
log = "0.4"
1414
env_logger = "0.11.8"
1515
libc = "0.2"
16+
exp_lut_macro = { path = "./exp_lut_macro"}
1617

1718
[dev-dependencies]
1819
criterion = { version = "0.7", features = ["html_reports"] }
1920

21+
[workspace]
22+
members = ["exp_lut_macro"]
23+
2024
[[bench]]
2125
name = "benchmarks"
2226
harness = false

exp_lut_macro/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "exp_lut_macro"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[lib]
7+
proc-macro = true
8+
9+
[dependencies]
10+
proc-macro2 = "1"
11+
quote = "1"
12+
syn = { version = "2", features = ["full"] }

exp_lut_macro/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extern crate proc_macro;
2+
3+
use proc_macro::TokenStream;

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ impl AnxiousState {
3939
}
4040
}
4141

42+
/// Constants for the exponential lookup table
43+
const EXP_LOOKUP_START: f32 = -20.0;
44+
const EXP_LOOKUP_END: f32 = 20.0;
45+
const EXP_LOOKUP_STEPS: usize = 1000;
46+
const EXP_LOOKUP_STEP_SIZE: f32 = (EXP_LOOKUP_END - EXP_LOOKUP_START) / EXP_LOOKUP_STEPS as f32;
47+
48+
4249
#[inline(always)]
4350
/// We use a logistic function as the transformation function.
4451
/// f(vel) = max_sens / (1 + C * e^(-ramp_up_rate * vel)), where

0 commit comments

Comments
 (0)