A supplementary SIMD math library to Unity.Mathematics, extending it to all C# numeric types while adding many new types and functions. Written entirely with hardware intrinsics, using Unity.Burst.
npm install com.mrunbelievable.maxmath#MaxMath
MaxMath is the most powerful and extensive SIMD math library available to Unity developers. Built on top of Unity.Mathematics and utilizing Unity.Burst, it introduces the following key features:
- Support For All Primitive Data Types: MaxMath adds support for (s)byte, (u)short, and (u)long vectors and matrices. These data types come with specialized overloads for all functions in Unity.Mathematics. Additionally, specialized Random8/16/32/64/128 types are available for efficient pseudo-random number generation.
- Wider Vectors With Full Hardware Support: Vector types are expanded to 256 bits, enabling types like byte32, short16, int8, and float8. This allows you to leverage the full potential of SIMD computation.
- Many Additional Functions: MaxMath includes a massive library of mathematical functions not found in Unity.Mathematics, with about five times as many highly optimized functions at your disposal. Each function is fully documented with XML annotations. A full list is provided further below.
- Exotic Data Types: MaxMath introduces data types such as (U)Int128 (scalar only), 128-bit quadruple precision floats (scalar only), and 8-bit quarter precision floats (in both scalar and vector forms). Additionally, Divider offers highly optimized integer division operations, extending and outperforming specialized libraries like libdivide.
- Written Entirely With Hardware Intrinsics: MaxMath guarantees optimal performance by utilizing specialized CPU instructions for both ARM and x86 ISAs, while abstracting these complexities away from the user entirely.
- Extends The Burst Compiler: MaxMath integrates deeply with Unity.Burst and LLVM, leveraging Unity.Burst.CompilerServices.Constant.IsConstantExpression to include code typically only found in optimizing compilers. This functionality allows MaxMath to choose more optimized code paths at compile time, and users can influence this behavior via the optional Promise enum parameter available in many functions.
- Easy To Use: MaxMath is just as easy to use as Unity.Mathematics. It supports features like implicit and explicit type conversions, making it seamless for you to use if you expect typical C# behavior of primitive types.
- Extensive Test Coverage: MaxMath is backed by 250,000 lines of unit tests for its 400,000 lines of code, as well as DEBUG only runtime checks where appropriate, together ensuring it is _production ready_.