1 #ifndef __STAN__META__TRAITS_HPP__
2 #define __STAN__META__TRAITS_HPP__
5 #include <boost/type_traits.hpp>
6 #include <boost/math/tools/promotion.hpp>
30 enum {
value = boost::is_convertible<T,double>::value };
49 template <
typename T,
int R,
int C>
74 struct is_vector<Eigen::Matrix<T,Eigen::Dynamic,1> > {
79 struct is_vector<Eigen::Matrix<T,1,Eigen::Dynamic> > {
85 template <
bool is_vec,
typename T>
86 struct scalar_type_helper {
91 struct scalar_type_helper<true, T> {
92 typedef typename scalar_type_helper<is_vector<typename T::value_type>::value,
typename T::value_type>::type type;
103 template <
typename T>
105 typedef typename scalar_type_helper<is_vector<T>::value, T>
::type type;
108 template <
typename T>
109 inline T
get(
const T& x,
size_t n) {
112 template <
typename T>
113 inline T
get(
const std::vector<T>& x,
size_t n) {
116 template <
typename T,
int R,
int C>
117 inline T
get(
const Eigen::Matrix<T,R,C>& m,
size_t n) {
118 return m(static_cast<int>(n));
124 template <
typename T>
128 template <
typename T>
132 template <
typename T,
int R,
int C>
133 size_t length(
const Eigen::Matrix<T,R,C>& m) {
137 template<
typename T,
bool is_vec>
151 template <
typename T>
156 template <
typename T1,
typename T2>
158 size_t result =
length(x1);
163 template <
typename T1,
typename T2,
typename T3>
164 size_t max_size(
const T1& x1,
const T2& x2,
const T3& x3) {
165 size_t result =
length(x1);
171 template <
typename T1,
typename T2,
typename T3,
typename T4>
172 size_t max_size(
const T1& x1,
const T2& x2,
const T3& x3,
const T4& x4) {
173 size_t result =
length(x1);
181 template <
typename T>
182 struct scalar_type<Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> > {
186 template <
typename T>
193 template <
typename T>
197 template <
typename T>
199 enum { value =
true };
202 template <
typename T>
207 template <
typename T>
213 template <
typename T,
223 template <
int R,
int C>
229 if (is_array)
return x_[i];
236 template <
typename T,
bool is_array>
247 template <
int R,
int C>
248 VectorView(
const Eigen::Matrix<scalar_t,R,C>& m) : x_(&m(0)) { }
251 if (is_array)
return x_[i];
270 template<
bool used,
bool is_vec>
275 throw std::runtime_error(
"used is false. this should never be called");
293 std::vector<double> x_;
305 template <
typename T1,
306 typename T2 = double,
307 typename T3 = double,
308 typename T4 = double,
309 typename T5 = double,
310 typename T6 =
double>
313 boost::math::tools::promote_args<typename scalar_type<T1>::type,