Пример #1
0
Файл: mvn.cpp Проект: cran/Boom
 //======================================================================
 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;
 }
Пример #2
0
 Matrix operator-(const Matrix &m1, const DiagonalMatrix &m2) {
   Matrix ans(m1);
   ans.diag() -= m2.diag();
   return ans;
 }
Пример #3
0
 Matrix operator-(const DiagonalMatrix &m1, const Matrix &m2) {
   Matrix ans(-m2);
   ans.diag() += m1.diag();
   return ans;
 }
Пример #4
0
 DiagonalMatrix operator-(const DiagonalMatrix &d) {
   return DiagonalMatrix(-1 * d.diag());
 }