-
Notifications
You must be signed in to change notification settings - Fork 2
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
Extended analysis #36
Comments
struct Dimension {
length: i32,
mass: i32,
...,
orientation: Orientation3D,
} where However, in order to support non-scalar quantities, we'd first need to support heterogeneously-dimensioned vectors, as in your #3, since the components of the vectors should have different orientations. As a side comment, there is the simpler approach of treating angles as angles, not as dimensionless quantities as defined in SI. If I understand this correctly, this kind of analysis is a subset of what can be done with orientational analysis. It comes with a lot of the benefits such as differentiating torque and energy, making conversions between While it is less powerful than orientational analysis, it might still be worth thinking about providing this too, because it avoids the problem of needing dimensionally-heterogeneous vectors, if I am not mistaken.
struct Dimension {
temperature: (i32, Kind),
...
}
enum Kind {
Relative,
Absolute,
} and then changing the definitions of some of the inbuilt functions (for example of the Contravariance/Covariance and Derivatives should be representable in a similar way, if I am not mistaken. As above, I'd like to make this an optional choice only, so that people can opt-out of the additional complexity and have a simpler unit system. Using enzyme alongside dimensional analysis is very interesting!
struct Heterogeneous<const N: usize, const DS: [Dimension; N]>(NDarray<N>); Of course it doesn't stop there, because we'd also need matrices (and probably even higher dimensional tensors?). My very first experiment with this wasn't very promising:
So at least with the current implementation of This could be possible, but would require quite a bit of macro code. It's something that could be tested quite quickly. Interfacing with the linear algebra library is the next problem of course. I'd probably start by picking a single library and then trying to implement some of the basic methods for all of the As a more general comment that seems like it might be relevant here: One thing that bothers me is that everytime more information is added to the |
Thanks for writing this out.
In my applications, the small matrices/vectors are assembled into large ones (dimension in the millions), with some rows/columns eliminated for boundary conditions so there isn't a trivial pattern identifying dimensions for any given entry (and in any case, the size is also not known at compile time). As for libraries suitable for the large sizes, faer is by far the most interesting. I think it's not super relevant here because typing likely only applies to statically-dimensioned matrices. nalgebra is probably the most popular for statically sized matrices. |
I created three new issues for each of the separate topics and will close this instead. |
I just wanted to mention some extensions in case a good implementation strategy for any emerge
uom
distinguishes (absolute)ThermodynamicTemperature
fromTemperatureInterval
, and one can't add two absolute temperatures. There are other places where distinguishing absolute and incremental quantities is important, especially when working with derivatives (I intend to experiment with diman and Enzyme once some minor bugs are fixed to better understand the safety/usability tradeoff).tests/gas
structures as vectors, supposing that only one direction is implemented (typical for equations of state for real gasses), then using Newton's method to numerically invert the transformation. Doing that naively, you have 5-vectors with heterogeneous dimension and a 5x5 matrix with matched (also heterogeneous) dimension. To use third-party linear algebra, we'd need to shed the dimensional layer, but how safe could we make it?The text was updated successfully, but these errors were encountered: