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>
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;
110 template <
typename T>
114 template <
typename T>
119 template <
typename T>
120 size_t length(
const Eigen::Matrix<T,Eigen::Dynamic,1>& v) {
123 template <
typename T>
124 size_t length(
const Eigen::Matrix<T,1,Eigen::Dynamic>& rv) {
128 template<
typename T,
bool is_vec>
142 template <
typename T>
147 template <
typename T1,
typename T2>
149 size_t result =
length(x1);
154 template <
typename T1,
typename T2,
typename T3>
155 size_t max_size(
const T1& x1,
const T2& x2,
const T3& x3) {
156 size_t result =
length(x1);
162 template <
typename T1,
typename T2,
typename T3,
typename T4>
163 size_t max_size(
const T1& x1,
const T2& x2,
const T3& x3,
const T4& x4) {
164 size_t result =
length(x1);
172 template <
typename T>
177 template <
typename T>
184 template <
typename T>
188 template <
typename T>
190 enum { value =
true };
193 template <
typename T>
198 template <
typename T>
204 template <
typename T,
214 template <
int R,
int C>
220 if (is_array)
return x_[i];
227 template <
typename T,
bool is_array>
238 template <
int R,
int C>
239 VectorView(
const Eigen::Matrix<scalar_t,R,C>& m) : x_(&m(0)) { }
242 if (is_array)
return x_[i];
319 template<bool used, typename T = double, bool is_vec = stan::is_vector<T>::value>
324 throw std::runtime_error(
"used is false. this should never be called");
342 std::vector<double> x_;
354 template <
typename T1,
355 typename T2 = double,
356 typename T3 = double,
357 typename T4 = double,
358 typename T5 = double,
359 typename T6 =
double>
362 boost::math::tools::promote_args<typename scalar_type<T1>::type,
internal::traits< Derived >::Scalar value_type
double & operator[](size_t)
double & operator[](size_t i)
DoubleVectorView(size_t n)
double & operator[](size_t)
VectorView(const std::vector< scalar_t > &v)
VectorView(const Eigen::Matrix< scalar_t, R, C > &m)
scalar_type< T >::type scalar_t
VectorView(const scalar_t &c)
VectorView(const scalar_t *x)
const scalar_t operator[](int i) const
double operator[](int) const
scalar_type< T >::type scalar_t
VectorView(Eigen::Matrix< scalar_t, R, C > &m)
VectorView(std::vector< scalar_t > &v)
scalar_t & operator[](int i)
(Expert) Numerical traits for algorithmic differentiation variables.
Probability, optimization and sampling library.
size_t length(const T &x)
size_t size_of(const T &x)
size_t max_size(const T1 &x1, const T2 &x2)
Template specification of functions in std for Stan.
Metaprogram to determine if a type has a base scalar type that can be assigned to type double.
Metaprogramming struct to detect whether a given type is constant in the mathematical sense (not the ...
Metaprogram to calculate the base scalar return type resulting from promoting all the scalar types of...
boost::math::tools::promote_args< typename scalar_type< T1 >::type, typename scalar_type< T2 >::type, typename scalar_type< T3 >::type, typename scalar_type< T4 >::type, typename scalar_type< T5 >::type, typename scalar_type< T6 >::type >::type type
scalar_type< T >::type type
scalar_type< T >::type type
Metaprogram structure to determine the base scalar type of a template argument.
scalar_type_helper< is_vector< T >::value, T >::type type
static size_t size_of(const T &x)
static size_t size_of(const T &x)