//====================================================================== Vector rmvn_mt(RNG &rng, const Vector &mu, const DiagonalMatrix &V) { Vector ans(mu); const ConstVectorView variances(V.diag()); for (int i = 0; i < mu.size(); ++i) { ans[i] += rnorm_mt(rng, 0, sqrt(variances[i])); } return ans; }
Matrix operator-(const Matrix &m1, const DiagonalMatrix &m2) { Matrix ans(m1); ans.diag() -= m2.diag(); return ans; }
Matrix operator-(const DiagonalMatrix &m1, const Matrix &m2) { Matrix ans(-m2); ans.diag() += m1.diag(); return ans; }
DiagonalMatrix operator-(const DiagonalMatrix &d) { return DiagonalMatrix(-1 * d.diag()); }