Implement J3ML Core Math & Unit Tests
This commit is contained in:
@@ -17,6 +17,14 @@
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
/// TODO: Implement lookup tables.
|
||||
|
||||
#ifdef USE_LOOKUP_TABLES
|
||||
|
||||
static float fast_cossin_table[MAX_CIRCLE_ANGLE];
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <J3ML/Algorithm/Reinterpret.hpp>
|
||||
|
||||
@@ -199,8 +207,12 @@ namespace J3ML::Math::Functions {
|
||||
/// Computes the relative error of the two variables.
|
||||
float RelativeError(float a, float b);
|
||||
|
||||
inline bool IsFinite(float f) { return (ReinterpretAs<u32>(f) << 1) < 0xFF000000u; }
|
||||
inline bool IsFinite(double d) { return (ReinterpretAs<u64>(d) << 1) < 0xFFE0000000000000ULL; }
|
||||
template <typename T> bool IsFinite(T) { return true;}
|
||||
|
||||
template<> inline bool IsFinite(float f) { return (ReinterpretAs<u32>(f) << 1) < 0xFF000000u; }
|
||||
template<> inline bool IsFinite(double d) { return (ReinterpretAs<u64>(d) << 1) < 0xFFE0000000000000ULL; }
|
||||
template<> inline bool IsFinite(u32 i) { return (i << 1) < 0xFF000000u; }
|
||||
template<> inline bool IsFinite(u64 i) { return (i << 1) < 0xFFE0000000000000ULL;}
|
||||
|
||||
inline bool IsNotANumber(float f) { return (ReinterpretAs<u32>(f) << 1) > 0xFF000000u; }
|
||||
inline bool IsNotANumber(double d) { return (ReinterpretAs<u64>(d) << 1) > 0xFFE0000000000000ULL; }
|
||||
|
8
include/J3ML/Math.hpp
Normal file
8
include/J3ML/Math.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by dawsh on 7/6/24.
|
||||
//
|
||||
|
||||
#ifndef MATH_HPP
|
||||
#define MATH_HPP
|
||||
|
||||
#endif //MATH_HPP
|
Reference in New Issue
Block a user