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>
81 struct is_vector<Eigen::Matrix<T,Eigen::Dynamic,1> > {
86 struct is_vector<Eigen::Matrix<T,1,Eigen::Dynamic> > {
92 template <
bool is_vec,
typename T>
93 struct scalar_type_helper {
98 struct scalar_type_helper<true, T> {
99 typedef typename scalar_type_helper<is_vector<typename T::value_type>::value,
typename T::value_type>::type type;
110 template <
typename T>
112 typedef typename scalar_type_helper<is_vector<T>::value, T>
::type type;
115 template <
typename T>
116 inline T
get(
const T& x,
size_t n) {
119 template <
typename T>
120 inline T
get(
const std::vector<T>& x,
size_t n) {
123 template <
typename T,
int R,
int C>
124 inline T
get(
const Eigen::Matrix<T,R,C>& m,
size_t n) {
125 return m(static_cast<int>(n));
131 template <
typename T>
135 template <
typename T>
139 template <
typename T,
int R,
int C>
140 size_t length(
const Eigen::Matrix<T,R,C>& m) {
144 template<
typename T,
bool is_vec>
158 template <
typename T>
163 template <
typename T1,
typename T2>
165 size_t result =
length(x1);
170 template <
typename T1,
typename T2,
typename T3>
171 size_t max_size(
const T1& x1,
const T2& x2,
const T3& x3) {
172 size_t result =
length(x1);
178 template <
typename T1,
typename T2,
typename T3,
typename T4>
179 size_t max_size(
const T1& x1,
const T2& x2,
const T3& x3,
const T4& x4) {
180 size_t result =
length(x1);
188 template <
typename T>
189 struct scalar_type<Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> > {
193 template <
typename T>
200 template <
typename T>
204 template <
typename T>
206 enum { value =
true };
209 template <
typename T>
214 template <
typename T>
220 template <
typename T,
230 template <
int R,
int C>
236 if (is_array)
return x_[i];
243 template <
typename T,
bool is_array>
254 template <
int R,
int C>
255 VectorView(
const Eigen::Matrix<scalar_t,R,C>& m) : x_(&m(0)) { }
258 if (is_array)
return x_[i];
277 template<
bool used,
bool is_vec>
282 throw std::runtime_error(
"used is false. this should never be called");
300 std::vector<double> x_;
312 template <
typename T1,
313 typename T2 = double,
314 typename T3 = double,
315 typename T4 = double,
316 typename T5 = double,
317 typename T6 =
double>
320 boost::math::tools::promote_args<typename scalar_type<T1>::type,