Skip to content
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

Make + and * universally associative/distributive; use +. and *. for Real #97

Open
jasone opened this issue Nov 11, 2020 · 1 comment
Open

Comments

@jasone
Copy link
Contributor

jasone commented Nov 11, 2020

Basis currently uses the +, *, etc. operators for both integer and real types. However, there are compelling static and dynamic optimization opportunities if these operators are universally treated as associative and commutative. Operations on Real.t cannot in general be treated as associative and commutative, because re-ordering operations can affect the degree of precision loss. Therefore, we need to provide special operators for Real.t, +., *., etc., that are not subject to the same suite of optimizations. We could provide both set of operators for Real, but that may not be worthwhile because it exposes the programmer to the risk of accidentally using the associative/commutative variants and getting numerically unstable results.

@jasone
Copy link
Contributor Author

jasone commented Dec 14, 2020

The integer types have a // function which produces a real result. Although not strictly related to the + vs +. distinction for real, it may also make sense to rename // to /. as a clearer indication that the function is floating-point-related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant