Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

a high-performance math library originally written in Jai, then translated to C and Rust. It provides optimized implementations of common mathematical functions with significant speed improvements over standard libc functions.

License

NotificationsYou must be signed in to change notification settings

666rayen999/x-math

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

X-Math is a high-performance mathematical library originally written in Jai, then translated to C and Rust. It provides optimized implementations of common mathematical functions with significant speed improvements over standard libc functions.

Features:

  • Highly optimized mathematical functions
  • Faster than standard libc implementations
  • Available in both accurate and ultra-fast approximations
  • Written in Jai, C and Rust

Performance Comparison:

The following table compares the performance of X-Math against standard libc functions. Benchmarks were written in C and compiled with-Ofast -fno-builtin to ensure that libc does not use SSE instructions (sqrtss, roundss, etc.).

Functionlibc (ns)x-math++ (ns)Speedup (x)Error++x-math (ns)SpeedError
sin894301360380x2.50.000071---------
cos905995323477x30.000067---------
tan2258915270688x80.019074---------
atan2177153772401x250.0002---------
asin1126285344500x3.30.00362883723x130.021762
acos1109464462021x2.40.00362898461x110.021761
sinh1174550274020x4.30.00236462051x190.035897
cosh1204881296126x40.00167351518x230.045089
tanh348166128467x2.70.006632---------
abs118373478x3.4------------
trunc18772683275x32------------
floor20560225818x8------------
ceil20332055778x3.6------------
round31837523788x13------------
mod129844342901x30------------
fract26608574657x3.5------------
sqrt18070634635x50.0000159032x200.000626
1/sqrt208274108058x20.00004651971x40.001748
cbrt1559505223349x70.00027---------
exp236234558915x60.00172511337x320.038194
log241887085594x50.00894211762x350.028652
exp41107282206x50.00172614405x280.038925

Notes:

  • ++ in the table indicates the default high-accuracy versions.
  • Some functions also have even faster, but less accurate, versions.
  • Functions like tan, exp, ..., are less accurate for large values, but the relative error remains small.

Usage:

  • C:
#defineX_MATH_ACC#defineX_MATH_SSE#include"x_math.h"
  • Rust:
cargo add x-math
[dependencies]x-math = {version ="*",features = ["acc","sse"] }
  • Jai:
// SSE will be detected automatically (CPU == .X64)MATH_ACC ::true;#load"x_math.jai";

License:

X-Math is released under the MIT License.

Contributions:

Contributions are welcome! Feel free to submit a pull request or open an issue.

Credits:

All credits are added as a comment in each function.

About

a high-performance math library originally written in Jai, then translated to C and Rust. It provides optimized implementations of common mathematical functions with significant speed improvements over standard libc functions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp