add license, clean up code

This commit is contained in:
2026-04-03 13:58:59 +02:00
parent 082590e5f5
commit 6e21f484a9

View File

@@ -1,5 +1,25 @@
// Auto-generated lookup tables for fixed-point log/exp /*
// Do not edit manually * lut.h
* Copyright (c) 2025 Christopher Herb
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once #pragma once
@@ -9,7 +29,6 @@
namespace trnr { namespace trnr {
// Fixed-point log lookup table (Q12) // Fixed-point log lookup table (Q12)
// Input: normalized float [0.0001, 1.0000] -> Output: log value
constexpr int32_t LOG_TABLE_SIZE = 256; constexpr int32_t LOG_TABLE_SIZE = 256;
constexpr int32_t LOG_FRACTIONAL_BITS = 12; constexpr int32_t LOG_FRACTIONAL_BITS = 12;
constexpr int32_t LOG_TABLE[LOG_TABLE_SIZE] = { constexpr int32_t LOG_TABLE[LOG_TABLE_SIZE] = {
@@ -42,13 +61,8 @@ constexpr int32_t LOG_TABLE[LOG_TABLE_SIZE] = {
}; };
// Fixed-point exp lookup table (Q12) // Fixed-point exp lookup table (Q12)
// Input: normalized float [0.0000, 4.5000] -> Output: exp value
constexpr int32_t EXP_TABLE_SIZE = 256; constexpr int32_t EXP_TABLE_SIZE = 256;
constexpr int32_t EXP_FRACTIONAL_BITS = 12; constexpr int32_t EXP_FRACTIONAL_BITS = 12;
constexpr float MIN_LOG_INPUT = 0.0001f;
constexpr float MAX_LOG_INPUT = 1.0f;
constexpr float MIN_EXP_INPUT = 0.0f;
constexpr float MAX_EXP_INPUT = 4.5f;
constexpr int32_t EXP_TABLE[EXP_TABLE_SIZE] = { constexpr int32_t EXP_TABLE[EXP_TABLE_SIZE] = {
4096, 4169, 4243, 4319, 4396, 4474, 4553, 4635, 4717, 4801, 4096, 4169, 4243, 4319, 4396, 4474, 4553, 4635, 4717, 4801,