C# math library (System.Numerics vs Math.NET)
Asked Answered
D

1

6

I'm trying to make my own game engine for learning purposes, but I'm also trying to make something that is optimized and is capable of handling a diverse amount of cross-platform games.

That said, I'm now at a point where I need to choose a math library to deal with SIMD operations for graphics rendering, and I can't decide on which one should I pick.

After some research, I've found that Math.NET seems pretty good for the job, but the native System.Numerics seems somewhat easier to use and does not require a third-party dependency.

I've seen some posts that claimed System.Numerics was slow, but they were all long past the due date (3 to 6 years ago), so I don't think they have reliable results anymore.

So my question is, especially now that .NET Core 3.0 has been released, has System.Numerics become reliable enough that it can be used for heavy graphical computation, or should I forget about it and go for something like Math.NET?

Finally, would there be a better alternative that I haven't considered? I'll admit that it would be nice if there was a library which provided some kind of abstraction over platform-specific code (but it wouldn't be a problem to write it myself either)

Duley answered 30/9, 2019 at 16:54 Comment(0)
S
0

Might be a case of speed vs precision. Sometimes math calculations in games can get away with certain approximations, like in case of classic Fast Inverse Square Root calculation , rather than traditionally calculating it according to the formula.

It also seems that Math.NET started as a more feature-rich alternative to System.Numerics, with the later not being developed for high-speed computational purposes. With recent developments, System.Numerics might have caught up with Math.NET. Ultimately, profiling will help you find out which one is better.

Also a note - Unity having it's old math library, as well as the new SIMD-enabled math library both are a sign that maybe System.Numerics isn't that performant - but that's just an observation.

Simonides answered 18/12, 2023 at 15:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.