cgmath icon indicating copy to clipboard operation
cgmath copied to clipboard

Question: Utility of DiagonalMatrix struct

Open richard-uk1 opened this issue 7 years ago • 2 comments

Multiplying by a diagonal matrix is faster than a general matrix, because it is equivalent to scaling rows if mat * diag, or columns if diag * mat. Should there be a DiagonalMatrix stored as a vector that implements matrix mult like this to be faster?

An application, for example, is scaling in a rotation/scale/translation transformation.

richard-uk1 avatar Apr 22 '18 11:04 richard-uk1

An alternative is some method on a matrix that takes a vector and applies it in this way.

richard-uk1 avatar Apr 22 '18 15:04 richard-uk1

Yeah, originally I was thinking this would be a nice optimization! I don't currently do it though. It's also a handy invariant to know in some cases, but again, I haven't taken advantage of it. Lots of unfinished business on cgmath - if you want to chat further I'm on Gitter!

brendanzab avatar Apr 27 '18 15:04 brendanzab