History

added fast pow functions

spiricom committed 6 years ago

Commit 4cb315f1 parent 53449994 files · +23 −-2Browse files

Unified · Split

4 files
  1. .DS_Store +0 −0
  2. LEAF/.DS_Store +0 −0
  3. LEAF/Inc/leaf-math.h +2 −0
  4. LEAF/Src/leaf-math.c +23 −0
.DS_Store+0−0

Binary file not shown.

LEAF/.DS_Store+0−0

Binary file not shown.

LEAF/Inc/leaf-math.h+2−0
@@ -142,6 +142,8 @@ extern "C" { · 141 unmodified lines
142142
143143 float fastexp2f(float f);
144144
145+ float fastPowf(float a, float b) ;
146+ double fastPow(double a, double b);
145147
146148 void LEAF_crossfade(float fade, float* volumes);
147149
LEAF/Src/leaf-math.c+23−0
@@ -152,6 +152,29 @@ float fastexp2f(float x) · 151 unmodified lines
152152 }
153153
154154
155+float fastPowf(float a, float b) {
156+ union
157+ {
158+ float d; int x;
159+ }
160+ u = { a };
161+
162+ u.x = (int)(b * (u.x - 1064866805) + 1064866805);
163+ return u.d;
164+}
165+
166+
167+double fastPow(double a, double b) {
168+ union {
169+ double d;
170+ int x[2];
171+ } u = { a };
172+
173+ u.x[1] = (int)(b * (u.x[1] - 1072632447) + 1072632447);
174+
175+ u.x[0] = 0;
176+ return u.d;
177+}
155178 /*
156179 you pass in a float array to get back two indexes representing the volumes of the left (index 0) and right (index 1) channels
157180 when t is -1, volumes[0] = 0, volumes[1] = 1

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t