Re:The type system is a programmer's best friend
by tremon on Saturday November 05, 2022 @03:25PM
(#33484731)
matrix multiplication with typed values (where each element of the matrix can have a different type/unit of measure)
Is this really a common occurrence? In most situations I've come across, it's the matrix itself (rows/columns) that has a unit of measurement, not the invididual columns. Tensors, rotation matrices, lighting maps: they all use the same units of measurement.
Re:The type system is a programmer's best friend
by tsimionescu on Saturday November 05, 2022 @03:43PM
(#33484875)
Matrix multiplication is often used for solving systems of linear equations, and you often have systems of linear equations involving different physical quantities (such as position, speed, time and mass if solving some classical mechanics equations, or pressure, volume, temperature, and time for thermodynamics etc).
And while it may be relatively common to start out and end up with matrices that have a single unit for each row (but different units on different rows), intermediate results will often end up with different combinations of units in each element.
This is a fundamental limitation of types - they tend to scale poorly to very complex non-uniform structures. That's not to say that they shouldn't be used when they do scale nicely, though!