A Complex Math Library for Mojo

Hi folks, I've had way too much free time recently, so I wrote a complex math library for Mojo! It massively expands the existing ComplexSIMD type as well as adding all the standard functions like csqrt, csin, cexp, and so on. Of course, it's still a WIP, but if you want more let me know! I'm trying to align this as close to the stdlib as possible so it feels natural to use. https://github.com/JakeEBrooks/mojocmath
GitHub
GitHub - JakeEBrooks/mojocmath: A Mojo Math Library for Complex Num...
A Mojo Math Library for Complex Numbers. Contribute to JakeEBrooks/mojocmath development by creating an account on GitHub.
7 Replies
Darin Simmons
Darin Simmons4mo ago
@mad alex 1997
Jake Brooks
Jake Brooks3mo ago
Just pushed an update that adds docstrings for all functions, comments with formulas + derivations for the math functions, and tests for all math functions. This is v1.0, though I'm only like 80% sure that the math functions will behave correctly around the edge cases (particularly with +/- inf, NaNs, and zeros). If a user finds an issue here, definitely let me know.
alain
alain3mo ago
I'm interested how confident you are with complex math on integer valued variables eg int8, i.e are any conversions to float gonna happen under the hood for trigonometry for instance ?
Jake Brooks
Jake Brooks2mo ago
There are no under the hood conversions, as all the math functions apply the same floating-point constraint as in the normal Mojo math library. The only exception to that is csquare which can be performed on any DType.
benny
benny2mo ago
great work! id maybe consider a rename since right now i assumed this was calling glibc intrinsics (cmath)
Helehex
Helehex2mo ago
If you want to combine our efforts, or just want some more reference material for your own package, i just updated moplex https://github.com/helehex/moplex I took some liberties with my package.. but i just gave it an update that should hopefully make it a little more familiar, although, maybe not as close to the c++ spec as some may like
Jake Brooks
Jake Brooks2mo ago
Interesting package, I don't know about combination as I wanted to keep mine as just what one expects from a complex number standard library package. But it's interesting to see your implementation!
Want results from more Discord servers?
Add your server