Fast `diag(A' * B * A)`

Crap, yeah you’re right that I should have done += on zeros. The good news is that it does not result in a big performance loss. Updating my post yet again.

1 Like