Stan Math Library  2.12.0
reverse mode automatic differentiation
check_lower_triangular.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_LOWER_TRIANGULAR_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_LOWER_TRIANGULAR_HPP
3 
7 #include <sstream>
8 #include <string>
9 
10 namespace stan {
11  namespace math {
31  template <typename T_y>
32  inline bool
34  const char* function,
35  const char* name,
36  const Eigen::Matrix<T_y, Eigen::Dynamic, Eigen::Dynamic>& y
37  ) {
38  for (int n = 1; n < y.cols(); ++n) {
39  for (int m = 0; m < n && m < y.rows(); ++m) {
40  if (y(m, n) != 0) {
41  std::stringstream msg;
42  msg << "is not lower triangular;"
43  << " " << name << "[" << stan::error_index::value + m << ","
44  << stan::error_index::value + n << "]=";
45  std::string msg_str(msg.str());
46  domain_error(function, name, y(m, n),
47  msg_str.c_str());
48  return false;
49  }
50  }
51  }
52  return true;
53  }
54 
55  }
56 }
57 #endif
bool check_lower_triangular(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if the specified matrix is lower triangular.
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.

     [ Stan Home Page ] © 2011–2016, Stan Development Team.