All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
check_positive_ordered.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_POSITIVE_ORDERED_HPP
#define STAN_MATH_PRIM_MAT_ERR_CHECK_POSITIVE_ORDERED_HPP
#include <stan/math/prim/scal/err/domain_error.hpp>
#include <stan/math/prim/mat/err/check_ordered.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/mat/meta/index_type.hpp>
#include <sstream>
#include <string>
namespace stan {
namespace math {
template <typename T_y>
bool
check_positive_ordered(const char* function,
const char* name,
const Eigen::Matrix<T_y, Eigen::Dynamic, 1>& y) {
using Eigen::Dynamic;
using Eigen::Matrix;
using stan::math::index_type;
typedef typename index_type<Matrix<T_y, Dynamic, 1> >::type size_type;
if (y.size() == 0) {
return true;
}
if (y[0] < 0) {
std::ostringstream msg;
msg << "is not a valid positive_ordered vector."
<< " The element at " << stan::error_index::value
<< " is ";
std::string msg_str(msg.str());
domain_error(function, name, y[0],
msg_str.c_str(), ", but should be postive.");
return false;
}
check_ordered(function, name, y);
return true;
}
}
}
#endif
check_ordered.hpp
stan::math::size_type
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Type for sizes and indexes in an Eigen matrix with double e.
Definition: typedefs.hpp:13
stan::math::index_type
Primary template class for the metaprogram to compute the index type of a container.
Definition: index_type.hpp:19
index_type.hpp
stan::math::check_ordered
bool check_ordered(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, 1 > &y)
Return true if the specified vector is sorted into strictly increasing order.
Definition: check_ordered.hpp:31
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
stan::math::check_positive_ordered
bool check_positive_ordered(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, 1 > &y)
Return true if the specified vector contains non-negative values and is sorted into strictly increasi...
Definition: check_positive_ordered.hpp:32
domain_error.hpp

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