Skip to content

Commit 96f0d67

Browse files
committed
Add fast exp + minor fixes
1 parent b4da9bd commit 96f0d67

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

exp_lut_macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate proc_macro;
33
use proc_macro::TokenStream;
44
use quote::quote;
55
use syn::{
6-
Ident, LitFloat, LitInt, LitStr, Result, Token, parse::{Parse, ParseStream}, parse_macro_input
6+
Ident, LitFloat, LitInt, Result, Token, parse::{Parse, ParseStream}, parse_macro_input
77
};
88

99
#[derive(Debug, Clone)]

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ exp_lut_macro::exp_lut_macro!(
5757
steps: 1000
5858
);
5959

60+
#[inline(always)]
61+
fn fast_exp(x: f32) -> f32 {
62+
if x >= EXP_LOOKUP_START && x <= EXP_LOOKUP_END {
63+
let index = ((x - EXP_LOOKUP_START) / EXP_LOOKUP_STEP_SIZE) as usize;
64+
EXP_LOOKUP_LUT[index]
65+
} else {
66+
x.exp()
67+
}
68+
}
69+
6070

6171
#[inline(always)]
6272
/// We use a logistic function as the transformation function.

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use evdev::{Device, EventType, RelativeAxisCode, uinput::VirtualDevice};
44
use log::{error, info};
55
use mouse_scroll_daemon::{AnxiousParams, AnxiousState, process_events};
66
use std::path::PathBuf;
7-
use std::path::Path;
87

98
#[derive(Parser, Debug)]
109
#[command(author, version, about, long_about = None)]

0 commit comments

Comments
 (0)