Stan Math Library: stan/math/prim/mat/err/check_lower_triangular.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/scal/meta/error_index.hpp>
6 #include <stan/math/prim/scal/err/domain_error.hpp>
7 #include <sstream>
8 #include <string>
9
10 namespace stan {
11
12 namespace math {
32 template <typename T_y>
33 inline bool
34 check_lower_triangular(
35 const char* function,
36 const char* name,
37 const Eigen::Matrix<T_y, Eigen::Dynamic, Eigen::Dynamic>& y
38 ) {
39 for (int n = 1; n < y.cols(); ++n) {
40 for (int m = 0; m < n && m < y.rows(); ++m) {
41 if (y(m, n) != 0) {
42 std::stringstream msg;
43 msg << "is not lower triangular;"
44 << " " << name << "[" << stan::error_index::value + m << ","
45 << stan::error_index::value + n << "]=";
46 std::string msg_str(msg.str());
47 domain_error(function, name, y(m, n),
48 msg_str.c_str());
49 return false;
50 }
51 }
52 }
53 return true;
54 }
55
56 }
57 }
58 #endif
stan
Definition: log_sum_exp.hpp:8
stan::math::check_lower_triangular
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.
Definition: check_lower_triangular.hpp:34
stan::error_index::value
Definition: error_index.hpp:7
stan::math::domain_error
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.
Definition: domain_error.hpp:32
Eigen.hpp
domain_error.hpp
error_index.hpp

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