Esempio n. 1
0
 void DM::sandwich_inplace(SpdMatrix &m) const {
   assert((nrow() == m.nrow()) && (m.ncol() == ncol()));
   for (int i = 0; i < nrow(); ++i) {
     m.row(i) *= diagonal_elements_[i];
     m.col(i) *= diagonal_elements_[i];
   }
 }
Esempio n. 2
0
 //======================================================================
 void ArStateModel::set_initial_state_variance(const SpdMatrix &Sigma){
   if(Sigma.nrow() != state_dimension()){
     report_error("attempt to set Sigma to the wrong size in "
                  "ArStateModel::set_initial_state_mean");
   }
   initial_state_variance_ = Sigma;
 }
Esempio n. 3
0
 WM::WishartModel(double pri_df, const SpdMatrix &PriVarEst)
   : ParamPolicy(new UnivParams(pri_df), new SpdParams(PriVarEst*pri_df)),
     DataPolicy(new WS(PriVarEst.nrow())),
     PriorPolicy()
 {
   Chol chol(sumsq());
   if (!chol.is_pos_def()) {
     report_error("Sum of squares matrix must be positive definite in "
                  "WishartModel constructor");
   }
 }
Esempio n. 4
0
File: mvn.cpp Progetto: cran/Boom
 Vector rmvn_robust_mt(RNG &rng, const Vector &mu, const SpdMatrix &V) {
   uint n = V.nrow();
   Matrix eigenvectors(n, n);
   Vector eigenvalues = eigen(V, eigenvectors);
   for (uint i = 0; i < n; ++i) {
     // We're guaranteed that eigenvalues[i] is real and non-negative.  We
     // can take the absolute value of eigenvalues[i] to guard against
     // spurious negative numbers close to zero.
     eigenvalues[i] = sqrt(fabs(eigenvalues[i])) * rnorm_mt(rng, 0, 1);
   }
   Vector ans(eigenvectors * eigenvalues);
   ans += mu;
   return ans;
 }
Esempio n. 5
0
 SpdMatrix sandwich(const Matrix &A, const SpdMatrix &V){  // AVA^T
   Matrix tmp(A.nrow(), V.ncol());
   cblas_dsymm(CblasColMajor, CblasRight, CblasUpper,
     	  tmp.nrow(),
     	  tmp.ncol(),
     	  1.0,
     	  V.data(),
     	  V.nrow(),
     	  A.data(),
     	  A.nrow(),
     	  0.0,
     	  tmp.data(),
     	  tmp.nrow());
   return matmultT(tmp, A);
 }
Esempio n. 6
0
 void local_add_outer(SpdMatrix &S, const V &v, double w){
   assert(v.size()==S.nrow());
   cblas_dsyr(CblasColMajor, CblasUpper, v.size(), w, v.data(), v.stride(),
     	 S.data(), S.nrow());
 }
Esempio n. 7
0
 inline void zero_upper(SpdMatrix &V){
   uint n = V.nrow();
   for(uint i=0; i<n; ++i){
     dVector::iterator b = V.col_begin(i);
     dVector::iterator e = b+i;
     std::fill(b,e,0.0);}}
Esempio n. 8
0
 void DRSM::set_initial_state_variance(const SpdMatrix &V) {
   check_size(V.nrow());
   initial_state_variance_ = V;
 }