Example #1
0
 inline void check_pos_definite(const char* function, const char* name,
                                const Eigen::LDLT<Derived>& cholesky) {
   if (cholesky.info() != Eigen::Success
       || !cholesky.isPositive()
       || !(cholesky.vectorD().array() > 0.0).all())
     domain_error(function, "LDLT decomposition of", " failed", name);
 }
Example #2
0
 inline bool check_pos_definite(const char* function,
                                const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y,
                                const char* name,
                                T_result* result) {
   typedef 
     typename Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>::size_type 
     size_type;
   if (y.rows() == 1 && y(0,0) <= CONSTRAINT_TOLERANCE) {
     std::ostringstream message;
     message << name << " is not positive definite. " 
             << name << "(0,0) is %1%.";
     std::string msg(message.str());
     return dom_err(function,y(0,0),name,msg.c_str(),"",result);
   }
   Eigen::LDLT< Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic> > cholesky 
     = y.ldlt();
   if(cholesky.info() != Eigen::Success || 
      cholesky.isNegative() ||
      (cholesky.vectorD().array() <= CONSTRAINT_TOLERANCE).any()) {
     std::ostringstream message;
     message << name << " is not positive definite. " 
             << name << "(0,0) is %1%.";
     std::string msg(message.str());
     return dom_err(function,y(0,0),name,msg.c_str(),"",result);
   }
   return true;
 }
Example #3
0
    inline void check_pos_definite(const char* function, const char* name,
                                   const Eigen::Matrix<T_y, -1, -1>& y) {
      check_symmetric(function, name, y);
      check_positive_size(function, name, "rows", y.rows());
      if (y.rows() == 1 && !(y(0, 0) > CONSTRAINT_TOLERANCE))
        domain_error(function, name, "is not positive definite.", "");

      Eigen::LDLT<Eigen::MatrixXd> cholesky = value_of_rec(y).ldlt();
      if (cholesky.info() != Eigen::Success
          || !cholesky.isPositive()
          || (cholesky.vectorD().array() <= 0.0).any())
        domain_error(function, name, "is not positive definite.", "");
      check_not_nan(function, name, y);
    }