Better formulation of X' * diag_matrix(v) * X

Maybe someone knows if there is a better way to write this matrix formulation?

vector[K] v;
matrix[K, J] X;

\\ X' * diag_matrix(v) * X
matrix[J, J] G = diag_post_multiply(X', v) * X;  

I really want something like

matrix quad_form_diag(vector a, matrix B)
which is equivalent to B' * diag_matrix(a) * B

I do

crossprod(diag_pre_multiply(sqrt(v), X));

assuming v is positive.