Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
check_consistent_size.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__ERROR_HANDLING__CHECK_CONSISTENT_SIZE_HPP__
2 #define __STAN__MATH__ERROR_HANDLING__CHECK_CONSISTENT_SIZE_HPP__
3 
5 #include <stan/meta/traits.hpp>
6 
7 namespace stan {
8  namespace math {
9 
10  template <typename T, typename T_result, class Policy>
11  inline bool check_consistent_size(size_t max_size,
12  const char* function,
13  const T& x,
14  const char* name,
15  T_result* result,
16  const Policy&) {
17  size_t x_size = stan::size_of(x);
18  if (is_vector<T>::value && x_size == max_size)
19  return true;
20  if (!is_vector<T>::value && x_size == 1)
21  return true;
22  return dom_err(
23  function,x_size,name,
24  " (max size) is %1%, but must be consistent, 1 or max=",max_size,
25  result,Policy());
26  }
27 
28  }
29 }
30 #endif

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