![]() |
SH4ZAM! 0.9.1
Fast math library for the Sega Dreamcast's SH4 CPU
|


Go to the source code of this file.
Macros | |
| #define | SHZ_FLT_EPSILON |
Functions | |
Comparisons | |
Routines for comparing and classifying floating-point values. | |
| float | shz_fminf (float a, float b) noexcept |
| float | shz_fmaxf (float a, float b) noexcept |
| bool | shz_equalf (float a, float b) noexcept |
| bool | shz_equalf_abs (float a, float b) noexcept |
| bool | shz_equalf_rel (float a, float b) noexcept |
Rounding | |
Routines for rounding and manipulating floats. | |
| float | shz_floorf (float x) noexcept |
| float | shz_ceilf (float x) noexcept |
| float | shz_roundf (float x) noexcept |
| float | shz_truncf (float x) noexcept |
| float | shz_remainderf (float num, float denom) noexcept |
| float | shz_fmodf (float num, float denom) noexcept |
| float | shz_remquof (float num, float denom, float *quot) noexcept |
Mapping | |
Routines for mapping a number to another range. | |
| float | shz_clampf (float value, float min, float max) noexcept |
| float | shz_normalizef (float current, float from, float to) noexcept |
| float | shz_normalizef_fsrra (float current, float from, float to) noexcept |
| float | shz_remapf (float value, float inputStart, float inputEnd, float outputStart, float outputEnd) noexcept |
| float | shz_remapf_fsrra (float value, float inputStart, float inputEnd, float outputStart, float outputEnd) noexcept |
| float | shz_wrapf (float value, float min, float max) noexcept |
| float | shz_wrapf_fsrra (float value, float min, float max) noexcept |
| float | shz_fractf (float x) noexcept |
| float | shz_signf (float x) noexcept |
| float | shz_saturatef (float x) noexcept |
Miscellaneous | |
Assorted routines implementing other fp operations. | |
| float | shz_fabsf (float x) noexcept |
| float | shz_copysignf (float x, float y) noexcept |
| float | shz_fmaf (float a, float b, float c) noexcept |
| float | shz_fdimf (float x, float y) noexcept |
| float | shz_hypotf (float x, float y) noexcept |
| float | shz_cbrtf (float x) noexcept |
| float | shz_lerpf (float a, float b, float t) noexcept |
| float | shz_barycentric_lerpf (float a, float b, float c, float u, float v) noexcept |
| bool | shz_quadratic_roots (float a, float b, float c, float *root1, float *root2) noexcept |
| float | shz_randf (int *seed) noexcept |
| float | shz_randf_range (int *seed, float min, float max) noexcept |
| float | shz_stepf (float x, float edge) noexcept |
| float | shz_smoothstepf (float x, float edge0, float edge1) noexcept |
| float | shz_smoothstepf_safe (float x, float edge0, float edge1) noexcept |
FSRRA | |
Routines built around fast reciprocal square root instruction. | |
| float | shz_inv_sqrtf_fsrra (float x) noexcept |
| float | shz_inv_sqrtf (float x) noexcept |
| float | shz_sqrtf_fsrra (float x) noexcept |
| float | shz_sqrtf (float x) noexcept |
| float | shz_invf_fsrra (float x) noexcept |
| float | shz_invf (float x) noexcept |
| float | shz_divf_fsrra (float num, float denom) noexcept |
| float | shz_divf (float num, float denom) noexcept |
FIPR | |
Routines built around fast 4D dot product.
| |
| float | shz_dot6f (float x1, float y1, float z1, float x2, float y2, float z2) noexcept |
| float | shz_dot8f (float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2) noexcept |
| float | shz_mag_sqr3f (float x, float y, float z) noexcept |
| float | shz_mag_sqr4f (float x, float y, float z, float w) noexcept |
Transcendental | |
Fast approximations for non-trig transcendental functions. | |
| float | shz_pow2f (float p) noexcept |
| float | shz_powf (float x, float p) noexcept |
| float | shz_pow10f (float x) noexcept |
| float | shz_log2f (float x) noexcept |
| float | shz_logf (float x) noexcept |
| float | shz_log10f (float x) noexcept |
| float | shz_expf (float p) noexcept |
General-purpose scalar math routines.
This file provides a collection of general-purpose math routines for operating on floating-point scalar values.
Definition in file shz_scalar.h.
| #define SHZ_FLT_EPSILON |
Floating-point epsilon used with inexact FP-based comparisons.
Definition at line 40 of file shz_scalar.h.
|
noexcept |
Returns the minimum value of two given floats.
|
noexcept |
Returns the maximum value of two given floats.
|
noexcept |
Checks for equality based on EITHER the absolute tolerance or relative tolerance, using SHZ_FLT_EPSILON.
|
noexcept |
Checks for equality based on the absolute tolerance using SHZ_FLT_EPSILON.
|
noexcept |
Checks for equality based on the relative tolerance using SHZ_FLT_EPSILON.
|
noexcept |
Replacement for the <math.h> routine, floorf().
Returns the closest integral value to x, rounded down, as a float.
x <= INT32_MAX.
|
noexcept |
Replacement for the <math.h> routine, ceilf().
Returns the closest integral value to x, rounded up, as a float.
x <= INT32_MAX.
|
noexcept |
Replacement for the <math.h> routine, roundf().
Returns the value of x rounded to the nearest integer, as a float.
x <= UINT32_MAX.
|
noexcept |
Replacement for the <math.h> routine, truncf().
Returns the value of with its fractional component discarded.
x <= INT32_MAX.
|
noexcept |
Replacement for the <math.h> routine, remainderf().
Returns the floating-point remainder of num divided by denom, rounded to the nearest integer (as a float).
num / denom <= INT32_MAX.
|
noexcept |
Replacement for the <math.h> routine, fmodf().
Returns the floating-point remainder of num divided by denom, rounded towards zero.
|
noexcept |
(Sorta) Replacement for the <math.h> routine, remquof().
Returns the floating-point remainder of num divided by denom, rounded to the nearest integer (as a float). quot is set equal to the quotient which is used as part of the calculation.
quot is returning as a float rather than an int as with standard C. Simply cast to an int manually afterwards if that is the desired behavior.
|
noexcept |
Clamps a floating-point value by the given min and max values.
|
noexcept |
Maps a value within the given range from to to, to be within the range of 0.0f += 1.0f.
|
noexcept |
Maps a value within the given range from to to, to be within the range of 0.0f + 1.0f more quickly, provided to - from is a positive difference.
|
noexcept |
Maps a value within the given range inputStart to inputEnd, to be within the range of outputStart to outputEnd.
|
noexcept |
Maps a value within the given range inputStart to inputEnd, to be within the range of outputStart to outputEnd more quickly, provided the outputEnd - outputStart is a positive difference.
|
noexcept |
Wraps the given value back to be within the range of min to max.
|
noexcept |
Wraps the given value back to be within the range of min to max more quickly, provided max - min is a positive difference.
|
noexcept |
Returns the fractional part of x, equivalent to GLSL fract().
|
noexcept |
Returns -1.0f if x < 0, 0.0f if x == 0, or 1.0f if x > 0.
|
noexcept |
Clamps x to the range [0.0f, 1.0f].
|
noexcept |
Replacement for the <math.h> routine, fabsf().
Returns the absolute value of x.
|
noexcept |
Replacement for the <math.h> routine, copysignf().
Returns the value of x with the sign of y.
y == -0.0f, a positive value is returned.
|
noexcept |
Replacement for the <math.h> routine, fmaf().
Returns a * b + c, performing an FP multiply + accumulate operation.
|
noexcept |
Replacement for the <math.h> routine, fdimf(),.
Returns the positive difference between x and y or zero if y >= x.
|
noexcept |
Replacement for the <math.h> routine, hypotf().
Returns the hypoteneuse of the right triangle with the given legs.
|
noexcept |
Replacement for the <math.h> routine, cbrtf().
Returns the cubed root of x, using a fast approximation.
|
noexcept |
Returns a value that is linearly interpolated between a and b by the given ratio, t.
|
noexcept |
Returns a value that is barycentrically interpolated between a, b, and c using the given barycentric coordinates, u and v.
|
noexcept |
Uses the quadratic formula with the given coefficients to solve for the two roots, returning true if any real roots exist, and false if the roots are only imaginary.
|
noexcept |
Returns a random floating-point number between 0.0f and 1.0f, using and updating the given seed.
|
noexcept |
Returns a random floating-point number between min and max, using and updating the given seed.
|
noexcept |
returns 0.0f if x < edge, otherwise 1.0f
|
noexcept |
Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. edge0 must be less than edge1 or result is undefined.
|
noexcept |
Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges.
|
noexcept |
Calculates 1.0f/sqrtf( x), using a fast approximation.
|
noexcept |
Calculates 1.0f/sqrtf( x ), using a fast approximation, while safely protecting against division-by-zero.
|
noexcept |
Returns the fast approximate square root of the given value, x.
|
noexcept |
Returns the fast approximate square root of the given value, x, safely returning 0.0f is x == 0.0f.
|
noexcept |
Takes the inverse of x using a very fast approximation, returning a positive result.
|
noexcept |
Takes the inverse of x using a slighty faster approximation than doing a full division, safely handling negative values.
|
noexcept |
Divides num by denom using a very fast approximation, which requires denom be a positive value.
|
noexcept |
Divides num by denom using a slightly faster approximation, allowing denom to be negative.
|
noexcept |
Takes two sets of 3D vectors as 3 floats and calculates their dot product using an approximation.
|
noexcept |
Takes two sets of 4D vectors as 4 floats and calculates their dot product using an approximation.
|
noexcept |
Takes a 3D vector as 3 floats and calculates its squared magnitude using a fast approximation.
|
noexcept |
Takes a 4D vector as 4 floats and calculates its squared magnitude using a fast approximation.
|
noexcept |
Fast approximation for raising 2 to a floating-point power.
|
noexcept |
Fast approximation for C's powf().
|
noexcept |
Fast approximation of POSIX's pow10f().
|
noexcept |
Fast approximation for C's log2f().
|
noexcept |
Fast approximation for C's logf().
|
noexcept |
Fast approximation for C's log10f().
|
noexcept |
Fast approximation for C's expf().