-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add version of tree with double internals #4
Comments
Hello, Do you have a suggestion which would solve this without duplicating the complete codebase? |
I will close this issue now, but in case you submit a pull request, I would be glad to review it. |
It seems there is no easy way to have generic implementations on number types because there are no contracts/constrains for numerical operators. One would need to implement a kind of calculator class for every generic parameter (double, float). This kind of implementation makes the code harder to read and might bring performance penalties. |
I think T4 templates can make it work while also keeping the codebase maintainable and readable. Since mostly only the numerical operators and static methods from That way a Note: I wouldn't go for Source Generators, as it is still a new feature under preview as far as I have followed it. |
I'm not firm on how to use T4 templates. It seems to be the proper tool here though. As it seems to me that the dependencies of this project should be minimal, I'd use something like dotnet-t4 to transform the templates. |
FYI .Net 6 added support for generic mathematical operators. |
Thanks @myblindy for sharing this information here. Generic mathematical operators would significantly simplify this issue. |
Since then we have moved on to use the Further development can be made to use |
I will test an implementation using |
Thanks for the update @sqeezy on this topic. The related blog post is useful and interesting, although the results seems te be odd for me at some points. (The custom vector implementation was better than the built-in |
I reopen this issue, as in another issue #8 , it was suggested by @ricaun that we could use the System.DoubleNumerics library for double internal support. With the original idea of using T4 templates or Source Generators, this could provide a solution which could be implemented without much effort. |
I believe Vector is not really useful here. When having exactly three long vectors all the time, the fixed length types should be better. How did you come across System.DoubleNumerics? This one is new to me. |
System.DoubleNumerics was suggested by @ricaun . I was also not familiar with it before, mostly it seems like a simple copy-paste of System.Numerics' source code, modified to use doubles instead of float. This way we could use the fixed length (3) version, no need for |
In the end this wouldn't give us the SIMD optimization of the framework types. At least that's my understanding. After short research that actually should work with Vector so my test must have been flawed. I will look into that again. Reference: https://stackoverflow.com/questions/51225026/vectordouble-weak-simd-performance/51289848#51289848 |
These SIMD optimizations should automatically kick in to my knowledge, but I am not an expert on this topic. At least some people managed to implement custom vector types with the same performance as the built-in ones. @ricaun , since you mentioned you have used System.DoubleNumerics for a longer time, what was your experience with it? Have you ever compared its performance to the classic System.Numerics library? |
I believe this is the source code of the package: https://github.com/Weingartner/System.Numerics.DoubleVectors In my case, I need to compute vector and quaternions but my input is in I didn't make any performance benchmark. |
It would be super helpful to have a version of this library that works with
double
instead offloat
internals. Would this be a possible addition? I would be happy to provide a pull request.The text was updated successfully, but these errors were encountered: