You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is there any reason that there are no constant constructors for types like all matrixes or even for just for some common ones like identity.
And on that same point, Is it posible to get a literal for a Matrix/Vector
The text was updated successfully, but these errors were encountered:
Can you elaborate on what you mean by "types like all matrixes"? Owned matrices of constant size appear to expose const constructors for sizes up to 6x6. Not every matrix can be initialized in a const context because their data may not be const; for example, you can't have a dynamic matrix in a const, because its storage is a Vec, which would require a dynamic allocation.
I suspect the issue with making identityconst is that it's a generic function over the scalar field; it invokes Zero::zero and One::one to populate the relevant entries of the matrix. Without a stable way to parameterize over specifically-const implementations of these trait functions I don't think it's possible to produce the relevant const? annotation on identity. Something like from_diagonal but that allows specifying both the on-diagonal and off-diagonal entries would be possible, but currently you can explicitly write new(1.0, 0.0, 0.0, 1.0) to get a const identity matrix.
I don't believe Rust has custom literals at all, but you can get a similar effect using the matrix! macro. It invokes new and so should be usable in a const context when invoking a constnew. So you should also be able to write matrix![1.0, 0.0; 0.0, 1.0] to produce a 2x2 identity matrix.
is there any reason that there are no constant constructors for types like all matrixes or even for just for some common ones like identity.
And on that same point, Is it posible to get a literal for a Matrix/Vector
The text was updated successfully, but these errors were encountered: